From 7dceec3516dd5ec91151891fb33fefe08fc5413d Mon Sep 17 00:00:00 2001 From: Arnaud Desmons Date: Wed, 21 Aug 2002 10:23:31 +0000 Subject: use of drakconnect db and bug fixes --- postfix_wizard/scripts/Postfixconf.pm | 39 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'postfix_wizard') diff --git a/postfix_wizard/scripts/Postfixconf.pm b/postfix_wizard/scripts/Postfixconf.pm index 9ca428db..03c5658e 100644 --- a/postfix_wizard/scripts/Postfixconf.pm +++ b/postfix_wizard/scripts/Postfixconf.pm @@ -2,23 +2,15 @@ package Postfixconf; require "__WIZ_HOME__/common/scripts/Vareqval.pm"; +require "__WIZ_HOME__/common/scripts/DrakconnectConf.pm"; use MDK::Common; use strict; +my $o = DrakconnectConf->new(); + sub do_it { - my $file = "/etc/sysconfig/mdk_serv"; - my %mdk = Vareqval->get($file); - my $wiz_domain_name = $mdk{wiz_domain_name} if defined $mdk{wiz_domain_name} or - die "wiz_domain_name not in $file"; - my $wiz_host_name = $mdk{wiz_host_name} if defined $mdk{wiz_host_name} or - die "wiz_host_name not in $file"; - my $wiz_device = $mdk{wiz_device} if defined $mdk{wiz_device} or - die "wiz_device not in $file"; - $mdk{wiz_ext_mail_relay} = $ENV{wiz_ext_mail_relay} if defined $ENV{wiz_ext_mail_relay} or - die "wiz_ext_mail_relay not in env"; - $mdk{wiz_mail_masquerade} = $ENV{wiz_mail_masquerade} if defined $ENV{wiz_mail_masquerade} or - die "wiz_mail_masquerade not in env"; - Vareqval->commit($file, \%mdk); + my $wiz_domain_name = $o->get("DomainName"); + my $wiz_host_name = $o->get("SystemName"); my @conf = qw(/etc/postfix/aliases /etc/postfix/canonical /etc/postfix/main.cf @@ -27,7 +19,7 @@ sub do_it { foreach (@conf) { (-f $_) and MDK::Common::cp_af($_, $_.".orig"); } - @conf = ("myhostname = $wiz_host_name", + @conf = ("myhostname = $wiz_host_name.$wiz_domain_name", 'myorigin = $mydomain', 'inet_interfaces = all', 'mydestination = $myhostname, localhost.$mydomain, $mydomain', @@ -42,18 +34,17 @@ sub do_it { system("postconf -e \'$_\'"); } if (defined $ENV{wiz_ext_mail_relay}) { - $file = "/etc/postfix/canonical"; - open(CANONICAL, "< $file"); - while () { - if (/\@$ENV{wiz_domain_name}\s*\@$ENV{wiz_mail_masquerade}/){ - goto NOUPDATE; + my $file = "/etc/postfix/canonical"; + my $canon = "\n\@$wiz_domain_name \@$ENV{wiz_mail_masquerade}"; + my $t; + foreach (cat_($file)) { + if (/^\s*(?!\#)\s*\@.*\@.*\@.*\..*/) { + $t = $_; + last; } } - close(CANONICAL); - open(CANONICAL, ">> $file"); - print CANONICAL "\n\@$ENV{wiz_domain_name} \@$ENV{wiz_mail_masquerade}"; - NOUPDATE: - close(CANONICAL); + if ($t) { substInFile { s|$t|\#$&$canon|} $file } + else { append_to_file($canon) } } system("postmap /etc/postfix/canonical"); system("postmap /etc/postfix/virtual"); -- cgit v1.2.1