#! /usr/bin/perl -w $^W = 1; # same as -w above # (C) Copyright 2003 Rahul Dhesi, All rights reserved. # # "As is" -- No warranty. # # Copying, use, and modification are permitted, governed by # the GNU General Public License, by only those who agree # to use this program at their own risk. use strict; # unbuffered output is usually desired $| = 1; # $Source: /mi/maincvs/mail/pfdiff,v $ # $Id: pfdiff,v 1.7 2003/01/20 09:21:26 dhesi Exp $ # # Give a diff of two Postfix instances $::myname = $0; $::myname =~ s|.*/||; $::RCSHEADER = '$Source: /mi/maincvs/mail/pfdiff,v $' . "\n" . '$Id: pfdiff,v 1.7 2003/01/20 09:21:26 dhesi Exp $'; # suppresss perl warnings $::debug = $::opt_x = undef; $::ddebug = $::opt_X = undef; $::verbose = $::opt_v = undef; $::trace = $::opt_t = undef; $::opt_h = undef; $::opt_u = undef; $::opt_c = undef; $::opt_s = undef; $::opt_b = undef; $::usage = "usage: $::myname [-vtx] cfdir1 cfdir2 (or -h for help)"; if (@ARGV && $ARGV[0] =~ "^-.+" ) { local($^W) = 0; # suppress annoying undef warnings require "getopts.pl"; &Getopts("vtxXhucsbZ"); # Z will suppress perl warning } $::ddebug = $::opt_X; # debug $::debug = $::opt_x || $::ddebug; # extended debug $::trace = $::opt_t; $::verbose = $::debug || $::trace || $::opt_v; if ($::opt_h) { &givehelp(); exit(0); } (@ARGV != 2) && &usage_error; # program goes here my $t1 = "/tmp/pfdifft1$$"; my $t2 = "/tmp/pfdifft2$$"; END { defined($t1) && unlink $t1; defined($t2) && unlink $t2; } my $d1 = shift; my $d2 = shift; -d $d1 || die "$::myname: error: $d1: not a directory\n"; -d $d2 || die "$::myname: error: $d2: not a directory\n"; -e "$d1/main.cf" || die "$::myname: error: $d1/main.cf: $!\n"; -e "$d2/main.cf" || die "$::myname: error: $d2/main.cf: $!\n"; my $sort = $::opt_s ? '| sort' : ''; my $sed = q(sed -e 's/[, ][, ]*/ /g'); system "postconf -n -c $d1 | $sed $sort | cat > $t1"; system "postconf -n -c $d2 | $sed $sort | cat > $t2"; my @options = (); $::opt_b && push(@options, '-b'); $::opt_u && push(@options, '-u'); $::opt_c && push(@options, '-c'); system "diff @options $t1 $t2"; sub usage_error { my($msg) = @_; if ($msg) { die "$msg\n"; } else { die "$::usage\n"; } } sub givehelp { ## require 'local/page.pl'; ## &page(<