]> Frank Brehm's Git Trees - my-stuff/postfix.git/commitdiff
Postfix reload und Testmodus dazu
authorFrank Brehm <frank@brehm-online.com>
Mon, 10 Nov 2008 13:51:40 +0000 (13:51 +0000)
committerFrank Brehm <frank@brehm-online.com>
Mon, 10 Nov 2008 13:51:40 +0000 (13:51 +0000)
git-svn-id: http://svn.brehm-online.com/svn/my-stuff/postfix@29 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa

get-lookup-tables.pl

index fe0e172a3d5a25df973c6361ca95ef09b8a1bae4..cc8720d4798e4674e2c928cc824d1c33f658ec7e 100755 (executable)
@@ -28,6 +28,8 @@ my $pidfile = '/var/run/get-lookup-tables.pid';
 my $pidfile_written = undef;
 my $dbh;
 
+my $testmode = 0;
+
 my $postalias = '/usr/sbin/postalias';
 my $postmap   = '/usr/sbin/postmap';
 
@@ -56,6 +58,7 @@ END {
 
 GetOptions(
     "verbose+"              => \$verbose,
+    "testmode|test|t"       => \$testmode,
     "conf-file|conf|c=s"    => \$cfg_file,
 );
 
@@ -63,6 +66,8 @@ unless ( -d $postfix_dir ) {
     fatal( "Verzeichnis '$postfix_dir' existiert nicht." );
 }
 
+debug( 0, 'TESTMODUS - es werden keine scharfen Aktionen durchgeführt.' ) if $testmode;
+
 fatal( "Datei '$cfg_file' existiert nicht." ) unless -f $cfg_file;
 my $config = read_config($cfg_file);
 
@@ -75,6 +80,20 @@ for my $l ( sort { lc($a) cmp lc($b) } keys %{$config->{'lookup'}} ) {
     perform_lookup($l);
 }
 
+if ( $do_postfix_reload ) {
+
+    my $cmd = $binary->{'postfix'};
+    my @Args = ( $cmd, "reload" );
+
+    debug( 1, 'Führe Kommando aus: ', join( " ", @Args ) );
+    unless ( $testmode ) {
+        unless ( system(@Args) == 0 ) {
+            fatal( "Fehler beim Ausführen von '" . join( ' ', @Args ) . "'." );
+        }
+    }
+
+}
+
 exit 0;
 
 #--------------------------------------------------------------------------------------
@@ -162,16 +181,18 @@ sub perform_lookup {
 
         debug( 0, "Aktualisiere Lookup-Tabelle '" . $lookup . "'." );
         debug( 1, "Kopiere '" . $new_file . "' nach '" . $cur_file . "' ..." );
-        copy $new_file, $cur_file;
+        copy $new_file, $cur_file unless $testmode;
         debug( 1, "Kopiere '" . $new_file . "' als Backup nach '" . $backup_file . "' ..." );
-        copy $new_file, $backup_file;
+        copy $new_file, $backup_file unless $testmode;
 
         if ( $type eq 'btree' or $type eq 'dbm' or $type eq 'hash' ) {
             my $cmd = $map_type eq 'aliases' ? $binary->{'postalias'} : $binary->{'postmap'};
             my @Args = ( $cmd, $type . ":" . $cur_file );
             debug( 1, 'Führe Kommando aus: ', join( " ", @Args ) );
-            unless ( system(@Args) == 0 ) {
-                fatal( "Fehler beim Ausführen von '" . join( ' ', @Args ) . "'." );
+            unless ( $testmode ) {
+                unless ( system(@Args) == 0 ) {
+                    fatal( "Fehler beim Ausführen von '" . join( ' ', @Args ) . "'." );
+                }
             }
         }
         else {