diff options
Diffstat (limited to 'postfix_wizard/scripts')
-rw-r--r-- | postfix_wizard/scripts/Postfixconf.pm | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/postfix_wizard/scripts/Postfixconf.pm b/postfix_wizard/scripts/Postfixconf.pm index 176795ac..e34234d9 100644 --- a/postfix_wizard/scripts/Postfixconf.pm +++ b/postfix_wizard/scripts/Postfixconf.pm @@ -1,18 +1,32 @@ #!/usr/bin/perl package Postfixconf; +use lib '/usr/lib/libDrakX'; require "__WIZ_HOME__/common/scripts/Vareqval.pm"; require "__WIZ_HOME__/common/scripts/IFCFG.pm"; use MDK::Common; +use services; use strict; my $o = IFCFG->new(); my $wiz_domain_name = $o->network_get("DOMAINNAME"); my $wiz_host_name = $o->network_get("HOSTNAME"); +sub check_masquerade { + $ENV{wiz_mail_masquerade} or return 1; + $ENV{wiz_mail_masquerade} =~ /@(\S+)$/ or return 1; + return 10 +} + +sub check_relay { + $ENV{wiz_ext_mail_relay} or return 1; + $ENV{wiz_ext_mail_relay} =~ /(\S+)\.(\S+)$/ or return 1; + return 10; +} + sub get_mail_masquerade { my $login = `logname`; - my $relayhost = `postconf -h relayhost`; + my $relayhost = `/usr/sbin/postconf -h relayhost`; chomp($relayhost); ($relayhost) = $relayhost =~ /.*\.(.*\..*)/; !length $relayhost and $relayhost = $wiz_domain_name; @@ -21,7 +35,7 @@ sub get_mail_masquerade { } sub get_mail_relay { - my $relayhost = `postconf -h relayhost`; + my $relayhost = `/usr/sbin/postconf -h relayhost`; chomp $relayhost; !length $relayhost and $relayhost = "smtp.$wiz_domain_name"; $relayhost; @@ -36,7 +50,7 @@ sub do_it { foreach (@conf) { (-f $_) and MDK::Common::cp_af($_, $_.".orig"); } - @conf = ("myhostname = $wiz_host_name.$wiz_domain_name", + @conf = ("myhostname = $wiz_host_name", 'myorigin = $mydomain', 'inet_interfaces = all', 'mydestination = $myhostname, localhost.$mydomain', @@ -48,7 +62,7 @@ sub do_it { "relayhost = $ENV{wiz_ext_mail_relay}" ); foreach (@conf) { - system("postconf -e \'$_\'"); + system("/usr/sbin/postconf -e \'$_\'"); } if (defined $ENV{wiz_ext_mail_relay}) { my $file = "/etc/postfix/canonical"; @@ -63,12 +77,16 @@ sub do_it { if ($t) { substInFile { s|$t|\#$&$canon|} $file } else { append_to_file($file, $canon) } } - system("postmap /etc/postfix/canonical"); - system("postmap /etc/postfix/virtual"); - system("postalias /etc/postfix/aliases"); - system("postfix check"); - system("service postfix restart"); - system("service xinetd restart"); + system("/usr/sbin/postmap /etc/postfix/canonical"); + system("/usr/sbin/postmap /etc/postfix/virtual"); + system("/usr/sbin/postalias /etc/postfix/aliases"); + system("/usr/sbin/postfix check"); + if (services::is_service_running('postfix')) { + services::restart('postfix') + } else { + services::start('postfix') + } + services::is_service_running('xinetd') and services::restart('xinetd'); 10; } |