summaryrefslogtreecommitdiffstats
path: root/postfix_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'postfix_wizard')
-rwxr-xr-xpostfix_wizard/Postfix.pm158
1 files changed, 112 insertions, 46 deletions
diff --git a/postfix_wizard/Postfix.pm b/postfix_wizard/Postfix.pm
index b03c070c..b3f15bbb 100755
--- a/postfix_wizard/Postfix.pm
+++ b/postfix_wizard/Postfix.pm
@@ -27,13 +27,14 @@ use lib qw(/usr/lib/libDrakX); # required for service package
use common;
use MDK::Wizard::Wizcommon;
+use MDK::Wizard::Varspaceval;
+
my $wiz = new MDK::Wizard::Wizcommon;
my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME");
my $wiz_host_name = $wiz->{net}->network_get("HOSTNAME");
-
my $o = {
name => N("Postfix wizard"),
var => {
@@ -41,19 +42,43 @@ my $o = {
wiz_ext_mail_relay => '',
wiz_myorigin => $wiz_domain_name,
},
+ init => sub {
+ check_sendmail();
+ my $t =grep { /$wiz_host_name/ } cat_("/etc/hosts");
+ if ($t == 0) {
+ return 0, N("Error, can't find your hostname in /etc/hosts. Exiting.")
+ }
+ 1
+ },
needed_rpm => [ 'postfix' ],
defaultimage => "$ENV{__WIZ_HOME__}postfix_wizard/images/courrier.png"
};
-$o->{pages} = {
+
+my %level = (
+ 1 => N("External Mail server"),
+ 2 => N("Internal Mail server"),
+ );
+
+
+$o->{pages} = {
welcome => {
- name => N("Internet Mail Configuration Wizard") . "\n\n" . N("This wizard will help you configuring the Internet Mail services for your network."),
+ name => N("Internet Mail Configuration Wizard") . "\n\n" . N("This wizard will help you configuring the Internet Mail services for your network, or configure an Internet Mail server."),
no_back => 1,
- next => 'isp',
- next => 'config',
- post => \&check_sendmail,
+ pre => sub {
+ $o->{var}{wiz_level} ||= 1;
+ },
+ post => sub {
+ if ($o->{var}{wiz_level} == 2) {
+ return 'originext' }
+ },
+ data => [
+ { label => N("What do you want to do:"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } },
+ ],
+
+ next => 'external',
},
- config => {
+ external => {
name => N("Outgoing Mail Address") . "\n\n" . N("You can select the kind of address that outgoing mail will show in the \"From:\" and \"Reply-to\" field.") . "\n\n" . N("This should be chosen consistently with the address you use for incoming mail."),
pre => sub {
$o->{var}{wiz_mail_masquerade} ||= get_mail_masquerade();
@@ -62,15 +87,22 @@ $o->{pages} = {
data => [
{ label => N("Masquerade domain name:"), val => \$o->{var}{wiz_mail_masquerade} },
],
- next => 'isp'
+ next => 'isp',
},
+ internal => {
+ name => N("tata"),
+ data => [
+ { label => N("aa"), val => \$o->{var}{tata} },
+ ],
+ next => 'summaryint',
+ },
warning => {
name => N("Warning:") . "\n\n" . N("You entered an empty address for the mail gateway.") . "\n\n" . N("Your choice can be accepted, but this will not allow you to send mail outside your local network. Press next to continue, or back to enter a value."),
- next => 'summary'
+ next => 'summaryext',
},
masquerade_not_good => {
name => N("Error.") . "\n\n" . N("Masquerade not good!"),
- next => 'config'
+ next => 'external'
},
error_sendmail => {
name => N("Error, sendmail is installed, please remove it before install and configure Postfix"),
@@ -87,30 +119,34 @@ $o->{pages} = {
data => [
{ label => N("Mail Server Name:"), val => \$o->{var}{wiz_ext_mail_relay} },
],
- next => 'origin'
+ next => 'originext',
},
- origin => {
- name => N("The myorigin parameter specifies the domain that locally-posted mail appears to come from") . "\n\n" . N("The default is to append \$myhostname which is fine for small sites."),
- pre => sub {
- $o->{var}{wiz_myorigin} ||= get_myorigin();
- },
- data => [
- { label => N("myorigin:"), val => \$o->{var}{wiz_myorigin} },
- ],
- next => 'summary',
+ originext => {
+ name => N("The myorigin parameter specifies the domain that locally-posted mail appears to come from") . "\n\n" . N("The default is to append myhostname which is fine for small sites."),
+ pre => sub {
+ $o->{var}{wiz_myorigin} ||= get_myorigin();
+ },
+ data => [
+ { label => N("myorigin:"), val => \$o->{var}{wiz_myorigin} },
+ ],
+ post => sub {
+ if ($o->{var}{wiz_level} == 2) {
+ next => 'summaryint' }
+ },
+ next => 'summaryext',
},
- summary => {
+ summaryext => {
name => N("Configuring the Internet Mail") . "\n\n" . N("The wizard collected the following parameters needed to configure your Internet Mail Service:") . "\n\n" . N("To accept these values, and configure your server, click the Next button or use the Back button to correct them."),
data => [
{ label => N("Internet Mail Gateway"), fixed_val => \$o->{var}{wiz_ext_mail_relay} },
{ label => N("Form of the Address"), fixed_val => \$o->{var}{wiz_mail_masquerade} },
{ label => N("myorigin"), fixed_val => \$o->{var}{wiz_myorigin} },
],
- post => \&do_it,
- next => 'end'
+ post => \&do_it_external,
+ next => 'endext'
},
- end => {
- name => N("Congratulations") . "\n\n" . N("The wizard successfully configured your Internet Mail service of your server."),
+ endext => {
+ name => N("Congratulations") . "\n\n" . N("The wizard successfully configured your Internet Mail service of your server."),
end => 1,
next => 0
},
@@ -125,7 +161,7 @@ sub new {
sub check_sendmail {
my $in = 'interactive'->vnew('su', 'Check sendmail');
- my $w = $in->wait_message(N("Postfix Server"), N("Check if sendmail is installed...."));
+ my $w = $in->wait_message(N("Postfix Server"), N("Check if sendmail is installed, to avoid conflict...."));
my $test = grep { /sendmail/ } system("rpm -qa sendmail");
!$test or return 'error_sendmail';
undef $w;
@@ -162,10 +198,7 @@ sub get_myorigin {
$myorigin;
}
-sub do_it {
- $::testing and return;
- my $in = 'interactive'->vnew('su', 'postfix configuration');
- my $w = $in->wait_message(N("Postfix Server"), N("Configuring your Postfix server."));
+sub save_config {
my @conf = qw(/etc/postfix/aliases
/etc/postfix/canonical
/etc/postfix/main.cf
@@ -174,25 +207,67 @@ sub do_it {
foreach (@conf) {
-f $_ and MDK::Common::cp_af($_, $_.".orig");
}
+}
- @conf = ("myhostname = $wiz_host_name",
+sub cmd_needed {
+ system("/usr/sbin/postmap -r -w /etc/postfix/canonical");
+ system("/usr/sbin/postmap /etc/postfix/virtual");
+ system("/usr/sbin/postalias /etc/postfix/aliases");
+ system("/usr/sbin/postfix check");
+ require services;
+ if (services::is_service_running('postfix')) {
+ services::restart('postfix')
+ } else {
+ services::start('postfix')
+ }
+}
+
+sub do_it_internal {
+ $::testing and return;
+ my $in = 'interactive'->vnew('su', 'postfix configuration');
+ my $w = $in->wait_message(N("Postfix Server"), N("Configuring your Postfix server....."));
+ save_config();
+ my @conf = ("myhostname = $wiz_host_name",
'inet_interfaces = $myhostname',
'mydestination = $myhostname, localhost.$mydomain',
'alias_maps = hash:/etc/postfix/aliases',
'alias_database = hash:/etc/postfix/aliases',
'virtual_maps = hash:/etc/postfix/virtual',
'canonical_maps = hash:/etc/postfix/canonical',
- "mydomain = $o->{var}{wiz_domain_name}",
- "relayhost = $o->{var}{wiz_ext_mail_relay}",
+ "mydomain = $wiz_domain_name",
+ "masquerade_domains = $wiz_domain_name",
);
-
-# "myorigin = $o->{var}{wiz_myorigin}",
-# "masquerade_domains = $o->{var}{wiz_mail_masquerade}",
# example of internal mail working confoguration
#myhostname = xp2400.guibland.com
#virtual_maps = hash:/etc/postfix/virtual
#canonical_maps = hash:/etc/postfix/canonical
#masquerade_domains = guibland.com
+ foreach (@conf) {
+ system("/usr/sbin/postconf -e '$_'");
+ }
+ cmd_needed();
+ undef $w;
+}
+
+sub do_it_external {
+ $::testing and return;
+ my $in = 'interactive'->vnew('su', 'postfix configuration');
+ my $w = $in->wait_message(N("Postfix Server"), N("Configuring your Postfix server....."));
+ save_config();
+
+ my @conf = ("myhostname = $wiz_host_name",
+ 'inet_interfaces = $myhostname',
+ 'mydestination = $myhostname, localhost.$mydomain',
+ 'alias_maps = hash:/etc/postfix/aliases',
+ 'alias_database = hash:/etc/postfix/aliases',
+ 'virtual_maps = hash:/etc/postfix/virtual',
+ 'canonical_maps = hash:/etc/postfix/canonical',
+ "mydomain = $wiz_domain_name",
+ "relayhost = $o->{var}{wiz_ext_mail_relay}",
+ );
+
+# "myorigin = $o->{var}{wiz_myorigin}",
+# "masquerade_domains = $o->{var}{wiz_mail_masquerade}",
foreach (@conf) {
system("/usr/sbin/postconf -e '$_'");
@@ -210,16 +285,7 @@ sub do_it {
if ($t) { substInFile { s|$t|| } }
else { append_to_file($file, $canon) }
}
- system("/usr/sbin/postmap -r -w /etc/postfix/canonical");
- system("/usr/sbin/postmap /etc/postfix/virtual");
- system("/usr/sbin/postalias /etc/postfix/aliases");
- system("/usr/sbin/postfix check");
- require services;
- if (services::is_service_running('postfix')) {
- services::restart('postfix')
- } else {
- services::start('postfix')
- }
+ cmd_needed();
undef $w;
}