steffen: server/kolab/kolab kolab_bootstrap,1.21,1.22

cvs at intevation.de cvs at intevation.de
Tue May 25 01:34:07 CEST 2004


Author: steffen

Update of /kolabrepository/server/kolab/kolab
In directory doto:/tmp/cvs-serv4958/kolab

Modified Files:
	kolab_bootstrap 
Log Message:
bootstrapping slave servers

Index: kolab_bootstrap
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/kolab_bootstrap,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- kolab_bootstrap	24 May 2004 13:00:24 -0000	1.21
+++ kolab_bootstrap	24 May 2004 23:34:05 -0000	1.22
@@ -66,14 +66,19 @@
    print "Please check $kolab_config (seems to be incomplete)\n";
    die "and run kolab_bootstrap afterwards, manually";
 }
-my $fqdn = `hostname -f`;
+my $fqdn;
+if( $fqhostname =~ /\@\@\@/ ) {
+  $fqdn = `hostname -f`;
+} else {
+  $fqdn = $fqhostname;
+}
 chomp($fqdn);
 
 print "Please enter Hostname [$fqdn]: ";
 my $tmp = ReadLine;
 chomp $tmp;
 if ($tmp) { $fqdn = $tmp; }
-print "proceeding with Hostname $fqdn\n";
+print "Proceeding with Hostname $fqdn\n";
 
 my $tmp;
 if( $is_master eq "false" ) {
@@ -347,16 +352,58 @@
       sleep 5;
       #system("killall -9 slapd >/dev/null 2>&1");
    }
-
-   system("$kolab_prefix/etc/kolab/kolab_sslcert.sh $fqdn");
-   print "kolab should now be ready to run\n";
-   print "please run '$kolab_prefix/bin/openpkg rc all start'\n";
-
-   exit;
  }
 } else {
   ## Slave server setup
-  # TODO
-  print "Not implemented yet!\n";
-  exit -1;
+  ## For now we just connect to the remote slapd
+ SLAVESTART:
+  print "Now some information about the master LDAP server is required:\n\n";
+  print "URI of master LDAP server: ";
+  $ldap_uri = ReadLine;
+  print "Base DN of server: ";
+  $base_dn = ReadLine;
+  print "Manager bind DN: ";
+  $bind_dn = ReadLine;
+  print "Manager password: ";
+  $bind_pw = ReadLine;
+
+  print "Checking server info...\n";
+  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, please check your input\n";
+      goto SLAVESTART;
+    }
+    $php_dn = "cn=nobody,$base_dn";
+    $mesg = $ldap->search(base=> $php_dn, scope=> 'exact', filter=> "(objectclass=*)");
+    if ($mesg && $mesg->count != 1) {
+      print "Nobody object found, please check your input\n";
+      goto SLAVESTART;
+    }
+    my $entry = $mesg->entry(0);
+    $php_pw = $entry->get_value( 'userPassword' );
+
+    $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 "Updating configuration\n\n";
+    system("$kolab_prefix/sbin/kolabconf");
+  }
 }
+
+system("$kolab_prefix/etc/kolab/kolab_sslcert.sh $fqdn");
+print "kolab should now be ready to run\n";
+print "please run '$kolab_prefix/bin/openpkg rc all start'\n";





More information about the commits mailing list