From 103ae86f65823c30ee8c7ae97bd7784fa3ed175b Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 4 Nov 2008 23:14:12 +0000 Subject: [PATCH] =?utf8?q?mit=20=C3=84nderungen=20einpflegen=20weitergemac?= =?utf8?q?ht?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.brehm-online.com/svn/my-stuff/postfix@25 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- get-lookup-tables.pl | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/get-lookup-tables.pl b/get-lookup-tables.pl index a9d7ee7..98ae51d 100755 --- a/get-lookup-tables.pl +++ b/get-lookup-tables.pl @@ -9,6 +9,7 @@ use warnings; use File::Spec::Functions; use Config::General; use File::Basename; +use File::Copy; use Cwd qw( abs_path ); use Data::Dumper; use Getopt::Long; @@ -89,7 +90,7 @@ sub perform_lookup { my $l = $config->{'lookup'}{$lookup}; my $sql = $l->{'query'}; - my $type = $l->{'type'} || $default_database_type; + my $type = lc($l->{'type'}) || $default_database_type; my $map_type = 'map'; $map_type = 'aliases' if $l->{'map_type'} =~ /^\s*alias(?:es)?\s*$/; unless ( $sql ) { @@ -120,7 +121,8 @@ sub perform_lookup { } $max_length += 1 if $map_type eq 'aliases'; - my $new_file = catfile( $workdir, $lookup . ".new" ); + my $new_file = catfile( $workdir, $lookup ); + my $cur_file = catfile( $lookup_dir, $lookup ); debug( 1, "Schreibe Ergebnisse in Datei '" . $new_file . "' ..." ); unless ( open FILE, ">", $new_file ) { @@ -147,6 +149,30 @@ sub perform_lookup { close FILE; + my $changed = 0; + + $changed = 1 unless -f $cur_file; + + if ( $changed ) { + + debug( 0, "Aktualisiere Lookup-Tabelle '" . $lookup . "'." ); + debug( 1, "Kopiere '" . $new_file . "' nach '" . $cur_file . "' ..." ); + copy $new_file, $cur_file; + + 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 ) . "'." ); + } + } + else { + $do_postfix_reload = 1; + } + + } + } #-------------------------------------------------------------------------------------- -- 2.39.5