steffen: server/kolab/kolab kolab.conf, 1.3, 1.4 kolab.schema, 1.10, 1.11 kolab_bootstrap, 1.20, 1.21 kolabd, 1.1, 1.2 session_vars.php.template, 1.6, 1.7
cvs at intevation.de
cvs at intevation.de
Mon May 24 15:00:26 CEST 2004
Author: steffen
Update of /kolabrepository/server/kolab/kolab
In directory doto:/tmp/cvs-serv27504/kolab/kolab
Modified Files:
kolab.conf kolab.schema kolab_bootstrap kolabd
session_vars.php.template
Log Message:
added hostname to conf and removed it from the ldap schema, started improving on the bootstrap script
Index: kolab.conf
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/kolab.conf,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- kolab.conf 22 May 2003 18:49:51 -0000 1.3
+++ kolab.conf 24 May 2004 13:00:24 -0000 1.4
@@ -1,6 +1,8 @@
# This program is Free Software under the GNU General Public License (>=v2).
# Read the file COPYING that comes with this packages for details.
+fqhostname : @@@fqhostname@@@
+is_master : @@@is_master@@@
base_dn : @@@kolab_basedn@@@
bind_dn : cn=manager,@@@kolab_basedn@@@
bind_pw : @@@kolab_passwd@@@
Index: kolab.schema
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/kolab.schema,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- kolab.schema 19 May 2004 16:36:20 -0000 1.10
+++ kolab.schema 24 May 2004 13:00:24 -0000 1.11
@@ -707,8 +707,7 @@
DESC 'Kolab server config'
MUST k
SUP top STRUCTURAL
- MAY ( fqhostname $
- postfix-mydomain $
+ MAY ( postfix-mydomain $
postfix-relaydomains $
postfix-mydestination $
postfix-mynetworks $
Index: kolab_bootstrap
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/kolab_bootstrap,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- kolab_bootstrap 25 Apr 2004 22:15:25 -0000 1.20
+++ kolab_bootstrap 24 May 2004 13:00:24 -0000 1.21
@@ -1,12 +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 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.91
+# kolab_bootstrap Version 0.92
# create unix configuration files from data source (files or LDAP)
# and templates
@@ -27,6 +29,19 @@
my $kolab_prefix = "@l_prefix@";
my $kolab_config = $kolab_prefix."/etc/kolab/kolab.conf";
+# Fetch entry from ldap server or create new entry of none exist
+sub newOrExistingLDAPEntry {
+ my $ldap = shift;
+ my $dn = shift;
+
+ my $mesg = $ldap->search( base => $dn, scope => 'exact', filter => '(objectClass=*)' );
+ if( $mesg && $mesg->count() > 0 ) {
+ return $mesg->entry(0);
+ } else {
+ return Net::LDAP::Entry->new;
+ }
+}
+
print "\nKOLAB BOOTSTRAP\n\n";
my $fd = IO::File->new($kolab_config, "r")
@@ -38,6 +53,8 @@
}
}
undef $fd;
+my $fqhostname = $kolab_config{'fqhostname'} || die "could not read fqhostname from $kolab_config";
+my $is_master = $kolab_config{'is_master'} || "true";
my $bind_dn = $kolab_config{'bind_dn'} || die "could not read bind_dn from $kolab_config";
my $bind_pw = $kolab_config{'bind_pw'} || die "could not read bind_pw from $kolab_config";
my $ldap_uri = $kolab_config{'ldap_uri'} || die "could not read ldap_uri from $kolab_config";
@@ -52,82 +69,111 @@
my $fqdn = `hostname -f`;
chomp($fqdn);
-print "Please enter Hostname [$fqdn]:";
+print "Please enter Hostname [$fqdn]: ";
my $tmp = ReadLine;
chomp $tmp;
if ($tmp) { $fqdn = $tmp; }
print "proceeding with Hostname $fqdn\n";
-(my $dummy, my $domain) = split(/\./, $fqdn, 2);
-if (!$domain) { $domain = $fqdn; }
+my $tmp;
+if( $is_master eq "false" ) {
+ $tmp = "2";
+} else {
+ $tmp = "1";
+}
-print "Please enter your Maildomain [$domain]:";
-my $tmp = ReadLine;
-chomp $tmp;
-if ($tmp) { $domain = $tmp; }
-print "proceeding with Maildomain $domain\n";
+print "Do you want to set up (1) a master Kolab server or (2) a slave [$tmp]: ";
+my $tmp2 = ReadLine;
+if ( $tmp2 == 2 || ( !$tmp2 && $tmp == 2 ) ) {
+ $is_master = "false";
+ print "Proceeding with slave server setup\n\n";
+} else {
+ $is_master = "true";
+ print "Proceeding with master server setup\n\n";
+}
-if ($base_dn =~ /\@\@\@/ || $bind_dn =~ /\@\@\@/ || $bind_pw =~ /\@\@\@/) {
- print "Generating default configuration:\n";
- if ($base_dn =~ /\@\@\@/) {
+if ( $is_master eq "true" ) {
+ ### Master server setup
+ (my $dummy, my $domain) = split(/\./, $fqdn, 2);
+ if (!$domain) {
+ $domain = $fqdn;
+ }
+
+ print "Please enter your Maildomain [$domain]: ";
+ my $tmp = ReadLine;
+ chomp $tmp;
+ if ($tmp) {
+ $domain = $tmp;
+ }
+ print "proceeding with Maildomain $domain\n";
+
+ if ($base_dn =~ /\@\@\@/ || $bind_dn =~ /\@\@\@/ || $bind_pw =~ /\@\@\@/ ) {
+ print "Generating default configuration:\n";
+ if ($base_dn =~ /\@\@\@/) {
$base_dn = "";
- foreach my $dc ((split(/\./,$fqdn))) { $base_dn .= "dc=$dc,"; }
+ foreach my $dc ((split(/\./,$fqdn))) {
+ $base_dn .= "dc=$dc,";
+ }
chop $base_dn;
print " base_dn : $base_dn\n";
- }
- if ($bind_dn =~ /\@\@\@/) {
+ }
+ if ($bind_dn =~ /\@\@\@/) {
$bind_dn =~ s/\@\@\@kolab_basedn\@\@\@/$base_dn/g;
print " bind_dn : $bind_dn\n";
- }
- if ($bind_pw =~ /\@\@\@/) {
+ }
+ if ($bind_pw =~ /\@\@\@/) {
$bind_pw = `@l_prefix@/bin/openssl passwd kolab`;
chomp $bind_pw;
- print "Please choose a manager password [$bind_pw]:";
+ print "Please choose a manager password [$bind_pw]: ";
my $tmp = ReadLine;
chomp $tmp;
- if ($tmp) { $bind_pw = $tmp; }
+ if ($tmp) {
+ $bind_pw = $tmp;
+ }
print " bind_pw : $bind_pw\n";
- }
- if ($php_dn =~ /\@\@\@/) {
+ }
+ if ($php_dn =~ /\@\@\@/) {
$php_dn =~ s/\@\@\@kolab_basedn\@\@\@/$base_dn/g;
- }
- if ($php_pw =~ /\@\@\@/) {
+ }
+ if ($php_pw =~ /\@\@\@/) {
$php_pw = `@l_prefix@/bin/openssl passwd nobody`;
chomp $php_pw;
- }
+ }
- $fd = IO::File->new($kolab_config, "w+") || die "could not open $kolab_config";
- print $fd "base_dn : $base_dn\n";
- print $fd "bind_dn : $bind_dn\n";
- print $fd "bind_pw : $bind_pw\n";
- print $fd "ldap_uri : $ldap_uri\n";
- print $fd "php_dn : $php_dn\n";
- print $fd "php_pw : $php_pw\n";
- undef $fd;
- print "done modifying $kolab_config\n\n";
- chmod 0600, $kolab_config;
- print "IMPORTANT NOTE:\n";
- print "use login=manager and passwd=$bind_pw when you log into the webinterface!\n\n";
-}
+ $fd = IO::File->new($kolab_config, "w+") || die "could not open $kolab_config";
+ print $fd "fqhostname : $fqdn\n";
+ print $fd "is_master : $is_master\n";
+ print $fd "base_dn : $base_dn\n";
+ print $fd "bind_dn : $bind_dn\n";
+ print $fd "bind_pw : $bind_pw\n";
+ print $fd "ldap_uri : $ldap_uri\n";
+ print $fd "php_dn : $php_dn\n";
+ print $fd "php_pw : $php_pw\n";
+ undef $fd;
+ print "done modifying $kolab_config\n\n";
+ chmod 0600, $kolab_config;
+ print "IMPORTANT NOTE:\n";
+ print "use login=manager and passwd=$bind_pw when you log into the webinterface!\n\n";
+ }
-# remove all application specific fsl config files as these are yet to be done
-# having invalid files there hinders applications from starting up properly
-# we delay this until there's a better understanding of the fsl stuff
+ # remove all application specific fsl config files as these are yet to be done
+ # having invalid files there hinders applications from starting up properly
+ # we delay this until there's a better understanding of the fsl stuff
-#unlink("$kolab_prefix/etc/fsl/fsl.postfix");
-#unlink("$kolab_prefix/kolab/etc/fsl/fsl.sasl");
-#unlink("$kolab_prefix/etc/fsl/fsl.apache");
-#unlink("$kolab_prefix/etc/fsl/fsl.slapd");
-#unlink("$kolab_prefix/kolab/etc/fsl/fsl.imapd");
+ #unlink("$kolab_prefix/etc/fsl/fsl.postfix");
+ #unlink("$kolab_prefix/kolab/etc/fsl/fsl.sasl");
+ #unlink("$kolab_prefix/etc/fsl/fsl.apache");
+ #unlink("$kolab_prefix/etc/fsl/fsl.slapd");
+ #unlink("$kolab_prefix/kolab/etc/fsl/fsl.imapd");
-my $confname = "$kolab_prefix/etc/sasl/apps/smtpd.conf";
-copy("$kolab_prefix/etc/kolab/smtpd.conf.template", $confname) || die "could not write to $confname";
+ my $confname = "$kolab_prefix/etc/sasl/apps/smtpd.conf";
+ copy("$kolab_prefix/etc/kolab/smtpd.conf.template", $confname) || die "could not write to $confname";
-getopts('b');
+ getopts('b');
-if ($opt_b) {
- print "prepare LDAP database...\n";
- if ($ldap_uri =~ /127\.0\.0\.1/ || $ldap_uri =~ /localhost/) {
+ 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/etc/rc openldap stop");
sleep 1;
@@ -137,11 +183,11 @@
my $slpd = IO::File->new("$kolab_prefix/etc/openldap/slapd.conf","w+") || die "could not write to $kolab_prefix/etc/openldap/slapd.conf";
chmod (0640,"$kolab_prefix/etc/openldap/slapd.conf");
foreach (<$tmpl>) {
- s/\@\@\@base_dn\@\@\@/$base_dn/g;
- s/\@\@\@bind_dn\@\@\@/$bind_dn/g;
- s/\@\@\@bind_pw\@\@\@/$bind_pw/g;
- s/TLSCertificate/\#TLSCertificate/g;
- print $slpd $_;
+ s/\@\@\@base_dn\@\@\@/$base_dn/g;
+ s/\@\@\@bind_dn\@\@\@/$bind_dn/g;
+ s/\@\@\@bind_pw\@\@\@/$bind_pw/g;
+ s/TLSCertificate/\#TLSCertificate/g;
+ print $slpd $_;
}
undef $slpd;
undef $tmpl;
@@ -150,35 +196,28 @@
$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");
sleep 3;
- }
+ }
- my $ldapuri = URI->new($ldap_uri) || warn "error: could not parse given uri";
- my $ldap = Net::LDAP->new($ldapuri->host, port=> $ldapuri->port) || warn "could not connect ldap server";
- if ($ldap) {
+ my $ldapuri = URI->new($ldap_uri) || warn "error: could not parse given uri";
+ my $ldap = Net::LDAP->new($ldapuri->host, port=> $ldapuri->port) || warn "could not connect ldap server";
+ if ($ldap) {
$ldap->bind($bind_dn, password=> $bind_pw) || warn "could not bind to ldap";
my $mesg = $ldap->search(base=> "$base_dn", scope=> 'exact', filter=> "(objectclass=*)");
if ($mesg && $mesg->count != 1) {
- print "no $base_dn object found, creating one\n";
- my $hostname = (split(/\./,$fqdn))[0];
- chomp $hostname;
- $mesg = $ldap->add( $base_dn, attr=> [dc=> $hostname, 'objectclass'=> ['top', 'domain'] ]);
+ print "no $base_dn object found, creating one\n";
+ my $hostname = (split(/\./,$fqdn))[0];
+ chomp $hostname;
+ $mesg = $ldap->add( $base_dn, attr=> [dc=> $hostname, 'objectclass'=> ['top', 'domain'] ]);
}
$mesg && $mesg->code && warn "failed to write basedn entry : ", $mesg->error;
- $mesg = $ldap->search(base=> "k=kolab,$base_dn", scope=> 'exact', filter=> "(objectclass=*)");
- if ($mesg && $mesg->count != 1) {
- print "no kolab config object in ldap, generating a reasonable default\n";
- } else {
- print "modifying existing kolab config object\n";
- }
-
+ my $ldapobject = newOrExistingLDAPEntry( $ldap, "k=kolab,$base_dn" );
# create kolab config object
- my $ldapobject = Net::LDAP::Entry->new;
my $mynetworkinterfaces = "127.0.0.0/8";
my @net=`/sbin/ifconfig -a | grep -v 127.0.0 | grep -i \"inet\"`;
chomp @net;
foreach (@net) {
- /127\.0\.0/ && next;
+ /127\.0\.0/ && next;
s/^ *(.*)/$1/g;
my @tmp = split / /;
my $ip;
@@ -196,7 +235,6 @@
$ldapobject->replace(
'k' => 'kolab',
- 'fqhostname' => $fqdn,
'postfix-mydomain' => $domain,
#'postfix-relaydomains' => "",
'postfix-mydestination' => "\$mydomain",
@@ -219,13 +257,15 @@
'uid' => "freebusy",
'userPassword' => "freebusy",
'objectclass' => ['top', 'kolab' ] );
+ # Get rid of fqhostname, it will cause pain and suffering...
+ #$ldapobject->delete( 'fqhostname' );
$ldapobject->dn("k=kolab,$base_dn");
$mesg = $ldapobject->update($ldap);
$mesg && $mesg->code && warn "failed to write entry: ", $mesg->error;
undef $ldapobject;
# create internal user topnode
- $ldapobject = Net::LDAP::Entry->new;
+ $ldapobject = newOrExistingLDAPEntry( $ldap, "cn=internal,$base_dn" );
$ldapobject->replace('cn' => 'internal', 'objectclass' => ['top','namedObject']);
$ldapobject->dn("cn=internal,$base_dn");
$mesg = $ldapobject->update($ldap);
@@ -233,7 +273,7 @@
undef $ldapobject;
# create external user topnode
- $ldapobject = Net::LDAP::Entry->new;
+ $ldapobject = newOrExistingLDAPEntry( $ldap, "cn=external,$base_dn" );
$ldapobject->replace('cn' => 'external', 'objectclass' => ['top','namedObject']);
$ldapobject->dn("cn=external,$base_dn");
$mesg = $ldapobject->update($ldap);
@@ -241,7 +281,7 @@
undef $ldapobject;
# create admin group
- $ldapobject = Net::LDAP::Entry->new;
+ $ldapobject = newOrExistingLDAPEntry( $ldap, "cn=admin,$base_dn" );
$ldapobject->replace('cn' => 'admin', 'objectclass' => ['top','groupOfNames'],
'member' => "cn=manager,$base_dn");
$ldapobject->dn("cn=admin,$base_dn");
@@ -250,7 +290,7 @@
undef $ldapobject;
# create manager user
- $ldapobject = Net::LDAP::Entry->new;
+ $ldapobject = newOrExistingLDAPEntry( $ldap, $bind_dn );
$ldapobject->replace('cn' => 'manager', 'sn' => 'n/a', 'uid' => 'manager',
'userPassword' => $bind_pw, 'objectclass' => ['top','inetOrgPerson']);
$ldapobject->dn($bind_dn);
@@ -259,7 +299,7 @@
undef $ldapobject;
# create php read-only user
- $ldapobject = Net::LDAP::Entry->new;
+ $ldapobject = newOrExistingLDAPEntry( $ldap, "cn=nobody,$base_dn" );
$ldapobject->replace('cn' => 'nobody', 'sn' => 'n/a n/a', 'uid' => 'nobody',
'userPassword' => $php_pw, 'objectclass' => ['top','inetOrgPerson']);
$ldapobject->dn("cn=nobody,$base_dn");
@@ -268,7 +308,7 @@
undef $ldapobject;
# create mainainter group
- $ldapobject = Net::LDAP::Entry->new;
+ $ldapobject = newOrExistingLDAPEntry( $ldap, "cn=maintainer,$base_dn" );
$ldapobject->replace('cn' => 'maintainer', 'objectclass' => ['top','groupOfNames']);
$ldapobject->dn("cn=maintainer,$base_dn");
$mesg = $ldapobject->update($ldap);
@@ -277,6 +317,7 @@
$ldap->unbind;
}
+
print "LDAP setup finished\n\n";
print "Create initial config files for postfix, apache, proftpd, cyrus imap, saslauthd\n";
@@ -312,5 +353,10 @@
print "please run '$kolab_prefix/bin/openpkg rc all start'\n";
exit;
+ }
+} else {
+ ## Slave server setup
+ # TODO
+ print "Not implemented yet!\n";
+ exit -1;
}
-
Index: kolabd
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/kolabd,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- kolabd 31 Mar 2004 13:23:12 -0000 1.1
+++ kolabd 24 May 2004 13:00:24 -0000 1.2
@@ -130,6 +130,7 @@
print 'kolabd - Kolab Backend Daemon
+ Copyright (c) 2004 Klaraelvdalens Datakonsult AB
Copyright (c) 2003 Code Fusion cc
Copyright (c) 2003 Tassilo Erlewein, Martin Konold, Achim Frank
Index: session_vars.php.template
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/session_vars.php.template,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- session_vars.php.template 16 Apr 2004 10:17:28 -0000 1.6
+++ session_vars.php.template 24 May 2004 13:00:24 -0000 1.7
@@ -8,6 +8,7 @@
*/
session_start();
+$_SESSION['fqhostname'] = "@@@fqhostname@@@";
$_SESSION['ldap_server'] = "@@@ldap_ip@@@";
$_SESSION['ldap_port'] = @@@ldap_port@@@;
$_SESSION['base_dn'] = "@@@base_dn@@@";
More information about the commits
mailing list