#!/usr/bin/perl # # Drakwizard # Copyright (C) 2003 Florent Villard # Copyright (C) 2004 Antoine Ginies # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package MDK::Wizard::Kolab; use strict; use common; use MDK::Wizard::IFCFG; use MDK::Wizard::Wizcommon; use MDK::Wizard::Wizcommon_gtk2; my $wiz = new MDK::Wizard::Wizcommon; my $HOSTNAME = chomp_(`hostname`); my $IPSERVER = $wiz->{net}->itf_get("IPADDR"); if (!$IPSERVER) { my $interface = 'eth0'; ($IPSERVER) = `/sbin/ip addr show dev $interface` =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/m; } my $DOMAINNAME = chomp_(`dnsdomainname`); #my $kolab_config = "/etc/kolab/kolab.conf"; my $CAYESORNO; my $o = { name => N("Kolab configuration wizard"), init => sub { my ($err, $msg) = test_host_domain($SHORTHOSTNAME, $DOMAINNAME); if (!$err) { $in->ask_warn(N('Error'), $msg); die 'wizcancel'; } }, var => { hostname => $HOSTNAME, ip1 => $IPSERVER, domain => $DOMAINNAME, password => '', capasswd => '', keypasswd => '', }, needed_rpm => [ 'proftpd', 'openldap-servers', 'kolab' ], # defaultimage => /usr/share/wizards/, }; $::Wizard_pix_up = "/usr/share/mcc/themes/default/kolab-mdk.png"; my %type = ( 1 => N("Master kolab server"), # 2 => N("Slave kolab server"), ); $o->{pages} = { welcome => { name => N("Welcome to the Kolab Groupware server configuration Wizard.") . "\n\n" . N("Kolab is a secure, scalable and reliable groupware server. Some of the major features include: a web administration interface, a shared address book with provision for mailbox users as well as contacts and a POP3 as well as IMAP4(rev1) access to mail") . "\n\n" . N("Warning: Kolab needs to configure many other services: Proftpd, LDAP, Cyrus, Postfix, Imap, Saslauth. Wizard will make a backup of all your previous configuration files for these services."), no_back => 1, next => 'masterslave', }, masterslave => { name => N("Master or slave Kolab server"), post => sub { if ($o->{var}{wiz_type} == 1) { $o->{var}{masterslave} = "1"; return 'slaveserver'; } else { $o->{var}{masterslave} = "2"; return 'domain'; } }, data => [ { label => "", val => \$o->{var}{wiz_type}, type => 'list', list => [ sort keys %type ], format => sub { $type{$_[0]} } }, ], }, master => { name => N("You choose a Master Kolab server"), next => 'slaveserver', }, slaveserver => { name => N("You choose to configure a master Kolab server.") . "\n\n" . N("Enter fully qualified hostname of slave kolab server e.g. thishost.domain.tld (leave empty if none)."), data => [ { label => N("Slave kolab server:"), val => \$o->{var}{slaveserver} }, ], next => 'domain', no_back => 1, }, domain => { name => N("Kolab Domain") . "\n\n" . N("Please enter your Maildomain - if you do not know your mail domain use the FQDN from above. Kolab primary email addresses will be of the type user\@yourdomain"), pre => sub { $o->{var}{domain} = $DOMAINNAME; }, data => [ { label => N("Domain:"), val => \$o->{var}{domain} }, ], next => 'password', complete => sub { if (!$o->{var}{domain}) { $::in->ask_warn(N("Error"), N("You need a Kolab domain")); return 1; } else { return 0 } }, }, password => { name => N("Enter password for the 'manager' account of Kolab server."), complete => sub { if ($o->{var}{password} ne $o->{var}{password2} || $o->{var}{password} eq "") { $::in->ask_warn(N("Error:"), N("Password mismatch, or null password, please correct.")); return 1; } }, data => [ { label => N("Password:"), val => \$o->{var}{password}, hidden => 1 }, { label => N("Password again:"), val => \$o->{var}{password2}, hidden => 1 }, ], next => 'organame', }, organame => { name => N("Enter organisation name and organisational unit"), pre => sub { $o->{var}{wiz_organame} = "kolab"; $o->{var}{wiz_orgaunit} = "Test_CA"; }, data => [ { label => N("Organisation name:"), val => \$o->{var}{wiz_organame} }, { label => N("Organisational unit:"), val => \$o->{var}{wiz_orgaunit} }, ], complete => sub { if (!$o->{var}{wiz_orgaunit} || !$o->{var}{wiz_organame}) { $::in->ask_warn(N("Error"), N("You need to enter an Organisation name and an organisational unit")); return 1; } else { return 0 } }, next => 'summary', }, cayesorno => { name => N("Kolab can create and manage a certificate authority that can be used to create SSL certificates for use within the Kolab environment.") . "\n\n" . N("You can choose to skip this section if you already have certificates for the Kolab server."), post => sub { if ($o->{var}{cayesorno}) { $CAYESORNO = "y"; return 'capassword'; } else { $CAYESORNO = "n"; return 'summary_noca'; } }, pre => sub { $o->{var}{cayesorno} = 1; }, data => [ { label => "Do you want to create CA and certificates:", type => 'bool', val => \$o->{var}{cayesorno} }, ], }, capassword => { name => N("Kolab can create and manage a certificate authority that can be used to create SSL certificates for use within the \Kolab environment. Enter the passphrase for CA, and the passphrase for the RSA key."), complete => sub { if ($o->{var}{capasswd} ne $o->{var}{capasswd2} || $o->{var}{capasswd} eq "") { $::in->ask_warn(N("Error:"), N("Password mismatch, or null password, please correct.")); return 1; } if ($o->{var}{keycapasswd} ne $o->{var}{keycapasswd2} || $o->{var}{keycapasswd} eq "") { $::in->ask_warn(N("Error:"), N("Password mismatch, or null password, please correct.")); return 1; } }, pre => sub { foreach ($o->{var}{capasswd}, $o->{var}{capasswd2}, $o->{var}{keycapasswd}, $o->{var}{keycapasswd2}) { $_ = "rrrrrrrrrr"; } }, data => [ { label => N("CA passphrase:"), val => \$o->{var}{capasswd}, hidden => 1 }, { label => N("CA passphrase again:"), val => \$o->{var}{capasswd2}, hidden => 1 }, { label => ' ', }, { label => N("RSA key passphrase:"), val => \$o->{var}{keycapasswd}, hidden => 1 }, { label => N("RSA key passphrase:"), val => \$o->{var}{keycapasswd2}, hidden => 1 }, ], next => 'summary', }, summary => { name => N("The wizard will now configure Kolab server with these parameters"), data => [ { label => N("Hostname:"), fixed_val => \$o->{var}{hostname} }, { label => N("Domain:"), fixed_val => \$o->{var}{domain} }, { label => "" }, { label => N("Organisation name:"), fixed_val => \$o->{var}{wiz_organame} }, { label => N("Organisationnal unit:"), fixed_val => \$o->{var}{wiz_orgaunit} }, { label => N("With CA") }, ], post => \&do_it_master, next => 'end', }, summary_noca => { name => N("The wizard will now configure Kolab server with these parameters"), data => [ { label => N("Hostname:"), fixed_val => \$o->{var}{hostname} }, { label => N("Domain:"), fixed_val => \$o->{var}{domain} }, { label => "" }, { label => N("Organisation name:"), fixed_val => \$o->{var}{wiz_organame} }, { label => N("Organisationnal unit:"), fixed_val => \$o->{var}{wiz_orgaunit} }, ], post => \&do_it_master_withoutca, next => 'end', }, end => { name => N("Done") . "\n\n" . N("The kolab server is now configured. Log in as 'manager' with the password you entered at https://127.0.0.1/kolab/admin/"), end => 1, next => 0, }, }; sub new { my ($class) = @_; bless $o, $class; } sub do_it_master_withoutca { return if $::testing; my $in = 'interactive'->vnew('su', 'Kolab server'); my $w = $in->wait_message(N("Kolab server"), N("Configuring Kolab server on your system...")); } sub do_it_master { return if $::testing; my $oldconf; -f "/etc/kolab/.kolab2_configured" and $oldconf = "y"; MDK::Wizard::Wizcommon_gtk2::gtk_log("service kolab stop", "Kolab stop..."); my $in = 'interactive'->vnew('su', 'Kolab server'); my $w = $in->wait_message(N("Kolab server"), N("Configuring Kolab server on your system...")); system("rm -rf /etc/kolab/*.pem"); system("rm -rf /etc/kolab/*.kolabtmp"); system("rm -rf /etc/kolab/ca/*"); substInFile { s|\$REQ -new -x509 -keyout \${CATOP}/private/\$CAKEY.*|\$REQ -new -x509 -keyout \${CATOP}/private/\$CAKEY -passout pass\:\$PASSKOLAB \\|; s|\$CA -policy policy_anything.*|\$CA -policy policy_anything -batch -out \${outfile} -passin pass\:\$PASSKOLAB -infiles \${infile}|; } "/etc/kolab/kolab_ca.sh"; $ENV{PASSKOLAB} = $o->{var}{password}; my $F; open($F, "|/usr/sbin/kolab_bootstrap -b\n"); print $F "$oldconf $o->{var}{hostname} $o->{var}{masterslave} $o->{var}{domain} $o->{var}{password} $o->{var}{slaveserver} $CAYESORNO $o->{var}{wiz_organame} $o->{var}{wiz_orgaunit} y "; close $F; undef $w; MDK::Wizard::Wizcommon_gtk2::gtk_log("service kolab start", "Kolab start..."); } 1;