martin: server/kolab/kolab ChangeLog, 1.1, 1.2 kolab_bootstrap, 1.43, 1.44 kolabconf, 1.4, 1.5
cvs at intevation.de
cvs at intevation.de
Mon Jul 12 14:52:38 CEST 2004
Author: martin
Update of /kolabrepository/server/kolab/kolab
In directory doto:/tmp/cvs-serv5997/kolab
Modified Files:
ChangeLog kolab_bootstrap kolabconf
Log Message:
Martin K.: Bootstrapping is now much more robust
Index: ChangeLog
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/ChangeLog,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ChangeLog 31 Mar 2004 13:23:12 -0000 1.1
+++ ChangeLog 12 Jul 2004 12:52:36 -0000 1.2
@@ -1,3 +1,6 @@
+2004-07-12 Martin Konold <martin.konold at erfrakon.de>
+ * Added multiple sanity checks (running services etc.)
+
2004-03-18 Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
* Added template files for amavids and clamav
Index: kolab_bootstrap
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/kolab_bootstrap,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- kolab_bootstrap 8 Jul 2004 02:13:50 -0000 1.43
+++ kolab_bootstrap 12 Jul 2004 12:52:36 -0000 1.44
@@ -1,16 +1,14 @@
#!@l_prefix@/bin/perl
# (c) 2004 Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
-# (c) 2003 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>
-# (c) 2004 Martin Konold <martin.konold at erfrakon.de>
+# (c) 2003,2004 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>
+# (c) 2003.2004 Martin Konold <martin.konold at erfrakon.de>
# (c) 2003 Achim Frank <achim.frank at erfrakon.de>
#
# This program is Free Software under the GNU General Public License (>=v2).
# Read the file COPYING that comes with this packages for details.
-# kolab_bootstrap Version 0.92
-# create unix configuration files from data source (files or LDAP)
-# and templates
+# kolab_bootstrap Version 0.93
use strict;
use vars qw($opt_b $opt_f);
@@ -26,9 +24,10 @@
use Getopt::Std;
use Sys::Hostname;
use Term::ReadKey;
+use Time::Local;
+use Time::localtime;
my $kolab_prefix = "@l_prefix@";
-#my $kolab_prefix = "/kolab";
my $kolab_config = $kolab_prefix."/etc/kolab/kolab.conf";
##### Utility Functions
@@ -48,6 +47,20 @@
return $retval;
}
+# Check for running service
+sub checkPort {
+ my $name = shift; # Name of the service e.g. webserver
+ my $port = shift; # tcp Port of the named service
+ print ("Check for running $name on port $port\n");
+ if (tryConnect("localhost",$port) == 1) {
+ print ("Error: Found $name running on Port $port\n");
+ print ("Check your installation!\n");
+ print ("You must stop the service $name before running Kolab\n");
+ print ("You may try to execute \"$kolab_prefix/bin/openpkg rc all stop\" initially\n");
+ exit 1;
+ }
+}
+
# Fetch entry from ldap server or create new entry of none exist
sub newOrExistingLDAPEntry {
my $ldap = shift;
@@ -61,9 +74,62 @@
}
}
-##### Read config file
print "\nKOLAB BOOTSTRAP\n\n";
+# Check for already running services preventing proper operation of kolab_bootstrap and Kolab
+checkPort("webserver",80);
+checkPort("webserver",443);
+checkPort("imap server",143);
+checkPort("imap server",220);
+checkPort("imap server",585);
+checkPort("imap server",993);
+checkPort("pop server",109);
+checkPort("pop server",110);
+checkPort("pop server",473);
+checkPort("pop server",995);
+checkPort("smtp server",25);
+checkPort("smtp server",465);
+checkPort("ftp server",21);
+checkPort("Amavis Virus Scanner Interface",10024);
+checkPort("Kolab daemon",9999);
+checkPort("OpenLDAP server",636);
+checkPort("OpenLDAP server",389);
+checkPort("Sieve server",2000);
+
+print ("Excellent all required Ports are available!\n");
+
+system($kolab_prefix."/sbin/slapcat >/dev/null 2>&1");
+if ($?==0) {
+ print ("\nFound existing configuration\n");
+ print "\nBootstrapping Kolab will overwrite old configuration\n";
+ print "\nContinue n/y [n]: ";
+ my $tmp = ReadLine;
+ chomp $tmp;
+ if( (lc $tmp eq 'n') || ($tmp eq '') ) {
+ print "Bootstrapping aborted - not creating new configuration\n";
+ exit 0;
+ }
+ print ("Creating backup of old configuration (LDAP, kolab.conf and certificates\n");
+ my $epochseconds = timelocal(gmtime);
+ my $backupdir=$kolab_prefix."/etc/kolab/backup".$epochseconds;
+ mkdir($backupdir,0700) || die "cannot mkdir : $!";
+ print ("creating backup of LDAP repository\n");
+ system("cp -ra ".$kolab_prefix."/var/openldap/openldap-data/ ".$backupdir."/openldap-data");
+ system("rm -f ".$kolab_prefix."/var/openldap/openldap-data/*");
+ print ("creating backup of CA data\n");
+ system("mv ".$kolab_prefix."/etc/kolab/ca ".$backupdir);
+ system("mv ".$kolab_prefix."/etc/kolab/*.pem ".$backupdir);
+ print ("deleteing old kolab.conf\n");
+ copy($kolab_config, $backupdir."/kolab.conf");
+ system("rm -f ".$kolab_prefix."/var/openldap/openldap-data/*");
+} else {
+ print ("LDAP repository is empty - assuming fresh install\n");
+}
+
+
+# fetch fresh template
+copy($kolab_prefix."/etc/kolab/templates/kolab.conf.template", $kolab_config);
+
my $fd = IO::File->new($kolab_config, "r")
|| die "could not open $kolab_config";
my %kolab_config;
@@ -219,11 +285,10 @@
if ($opt_b) {
print "prepare LDAP database...\n";
if ($ldap_uri =~ /127\.0\.0\.1/ || $ldap_uri =~ /localhost/) {
- print "stop running slapd (if any)\n";
- system("$kolab_prefix/bin/openpkg rc openldap stop");
- sleep 1;
- system("$kolab_prefix/bin/openpkg rc openldap stop");
- sleep 1;
+# This cannot happen anymore
+# print "stop running slapd (if any)\n";
+# system("$kolab_prefix/bin/openpkg rc openldap stop");
+# sleep 5;
# Make sure that no rouge demons are running
tryConnect( '127.0.0.1', 389 ) && die "A process is already listening to port 389 (ldap)\n"
@@ -231,8 +296,9 @@
tryConnect( '127.0.0.1', 9999 ) && die "A process is already listening to port 9999 (kolabd)\n"
."Please stop any running kolabd and bootstrap again\n";
if( `ps aux|grep slurpd|grep -v grep` ) {
- print "WARNING: Detected running slurpd processes.\n";
- print " Please make sure the OpenLDAP server is stopped properly!\n";
+ print "Error: Detected running slurpd processes.\n";
+ print "Please make sure the OpenLDAP server is stopped properly!\n";
+ exit 1;
}
# Creating slapd.conf from template
@@ -255,7 +321,9 @@
print "temporarily starting slapd\n";
$ldap_uri = "ldap://127.0.0.1:389/";
(system("$kolab_prefix/libexec/openldap/slapd -h ldap://127.0.0.1:389/ -f $kolab_prefix/etc/openldap/slapd.conf") == 0 ) || die( "Could not start temporary slapd" );
- sleep 3;
+ print ("Waiting for OpenLDAP to start\n");
+ sleep 10;
+
}
my $ldapuri = URI->new($ldap_uri) || warn "error: could not parse given uri";
@@ -422,7 +490,7 @@
print "\nkill temporary slapd\n\n";
system("$kolab_prefix/etc/rc openldap stop");
sleep 5;
- #system("killall -9 slapd >/dev/null 2>&1");
+ system("killall -9 slapd >/dev/null 2>&1");
}
}
print <<'EOS';
@@ -622,5 +690,7 @@
}
#system("$kolab_prefix/etc/kolab/kolab_sslcert.sh $fqdn");
-print "kolab should now be ready to run\n";
+print "kolab is now ready to run!\n";
print "please run '$kolab_prefix/bin/openpkg rc all start'\n";
+print ("Use login=manager and passwd=$bind_pw when you log into\n");
+print ("the webinterface https://localhost/admin !\n");
Index: kolabconf
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/kolabconf,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- kolabconf 8 Jul 2004 01:49:32 -0000 1.4
+++ kolabconf 12 Jul 2004 12:52:36 -0000 1.5
@@ -3,15 +3,15 @@
##
## Copyright (c) 2003 Code Fusion cc
##
-## Writen by Stuart Binge <s.binge at codefusion.co.za>
+## Written by Stuart Binge <s.binge at codefusion.co.za>
## Portions based on work by the following people:
##
-## (c) 2003 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>
+## (c) 2003 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>
## (c) 2003 Martin Konold <martin.konold at erfrakon.de>
## (c) 2003 Achim Frank <achim.frank at erfrakon.de>
##
##
-## This program is free software; you can redistribute it and/or modify
+## 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 of the License, or
## (at your option) any later version.
@@ -64,7 +64,7 @@
Copyright (c) 2004 Klaraelvdalens Datakonsult AB
Copyright (c) 2003 Code Fusion cc
- Copyright (c) 2003 Tassilo Erlewein, Martin Konold, Achim Frank
+ Copyright (c) 2003 Tassilo Erlewein, Martin Konold, Achim Frank, erfrakon
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
More information about the commits
mailing list