martin: server/kolab/kolab kolab_bootstrap,1.44,1.45
cvs at intevation.de
cvs at intevation.de
Mon Jul 12 23:05:36 CEST 2004
Author: martin
Update of /kolabrepository/server/kolab/kolab
In directory doto:/tmp/cvs-serv12383
Modified Files:
kolab_bootstrap
Log Message:
Martin K.: Cleanup
Index: kolab_bootstrap
===================================================================
RCS file: /kolabrepository/server/kolab/kolab/kolab_bootstrap,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- kolab_bootstrap 12 Jul 2004 12:52:36 -0000 1.44
+++ kolab_bootstrap 12 Jul 2004 21:05:33 -0000 1.45
@@ -1,4 +1,4 @@
-#!@l_prefix@/bin/perl
+#!@l_prefix@/bin/perl
# (c) 2004 Steffen Hansen <steffen at klaralvdalens-datakonsult.se>
# (c) 2003,2004 Tassilo Erlewein <tassilo.erlewein at erfrakon.de>
@@ -35,7 +35,7 @@
# Connect to host,port and return 1 on success
sub tryConnect {
my $host = shift;
- my $port = shift;
+ my $port = shift;
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
die "No port" unless $port;
my $iaddr = inet_aton($host) || die "no host: $host";
@@ -65,7 +65,7 @@
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);
@@ -206,7 +206,7 @@
if ($base_dn =~ /\@\@\@/) {
$base_dn = "";
foreach my $dc ((split(/\./,$domain))) {
- $base_dn .= "dc=$dc,";
+ $base_dn .= "dc=$dc,";
}
chop $base_dn;
print " base_dn : $base_dn\n";
@@ -222,7 +222,7 @@
my $tmp = ReadLine;
chomp $tmp;
if ($tmp) {
- $bind_pw = $tmp;
+ $bind_pw = $tmp;
}
print " bind_pw : $bind_pw\n";
}
@@ -234,7 +234,7 @@
chomp $php_pw;
}
-
+
$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";
@@ -266,16 +266,6 @@
last;
}
};
-
- # 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");
my $confname = "$kolab_prefix/etc/sasl/apps/smtpd.conf";
copy("$kolab_prefix/etc/kolab/templates/smtpd.conf.template", $confname) || die "could not write to $confname";
@@ -292,12 +282,12 @@
# 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"
- ."Please stop any running ldap server and bootstrap again\n";
+ ."Please stop any running ldap server and bootstrap again\n";
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";
+ ."Please stop any running kolabd and bootstrap again\n";
if( `ps aux|grep slurpd|grep -v grep` ) {
- print "Error: 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;
}
@@ -306,15 +296,15 @@
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;
-
+
$confname = "$kolab_prefix/etc/openldap/slapd.replicas";
copy( "$kolab_prefix/etc/kolab/templates/slapd.replicas.template", $confname ) || die "Could not write $confname";
# now we must startup slapd
@@ -332,47 +322,30 @@
$ldap->bind($bind_dn, password=> $bind_pw) || warn "could not bind to ldap server $ldap_uri";
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 $dccomp = (split(/\./,$domain))[0];
- chomp $dccomp;
- $mesg = $ldap->add( $base_dn, attr=> [dc=> $dccomp, 'objectclass'=> ['top', 'domain'] ]);
- }
+ print "no $base_dn object found, creating one\n";
+ my $dccomp = (split(/\./,$domain))[0];
+ chomp $dccomp;
+ $mesg = $ldap->add( $base_dn, attr=> [dc=> $dccomp, 'objectclass'=> ['top', 'domain'] ]);
+ }
$mesg && $mesg->code && warn "failed to write basedn entry : ", $mesg->error;
my $ldapobject = newOrExistingLDAPEntry( $ldap, "k=kolab,$base_dn" );
# create kolab config object
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;
-# s/^ *(.*)/$1/g;
-# my @tmp = split / /;
-# my $ip;
-# my $mask;
-# foreach (@tmp) {
-# if (/addr.*:(.*)$/i) { $ip = $1; }
-# if (/mask.*:(.*)$/i) { $mask = $1 }
-# }
-# if ($ip && $mask) {
-# my $tmp = new Net::Netmask ($ip."/".$mask);
-# $mynetworkinterfaces .= ", ".$tmp->base()."/".$tmp->bits();
-# }
-# }
print "mynetworkinterfaces: ".$mynetworkinterfaces."\n";
$ldapobject->replace(
- 'k' => 'kolab',
- 'kolabhost' => \@kolabhosts,
+ 'k' => 'kolab',
+ 'kolabhost' => \@kolabhosts,
'postfix-mydomain' => $domain,
#'postfix-relaydomains' => "",
'postfix-mydestination' => "\$mydomain",
'postfix-mynetworks' => $mynetworkinterfaces,
#'postfix-relayhost' => "",
#'postfix-transport' => "",
- 'postfix-enable-virus-scan' => "TRUE",
+ 'postfix-enable-virus-scan' => "TRUE",
'cyrus-autocreatequota' => 100000,
- 'cyrus-quotawarn' => 80,
+ 'cyrus-quotawarn' => 80,
'cyrus-admins' => "manager",
'cyrus-imap' => "TRUE",
'cyrus-pop3' => "FALSE",
@@ -383,7 +356,7 @@
'proftpd-ftp' => "FALSE",
#'proftpd-defaultquota' => 100000,
#'proftpd-userPassword' => "freebusy",
- 'uid' => "freebusy",
+ 'uid' => "freebusy",
'userPassword' => "freebusy",
'objectclass' => ['top', 'kolab' ] );
# Get rid of fqhostname, it will cause pain and suffering...
@@ -437,7 +410,7 @@
# create manager user
$ldapobject = newOrExistingLDAPEntry( $ldap, $bind_dn );
$ldapobject->replace('cn' => 'manager', 'sn' => 'n/a', 'uid' => 'manager',
- 'userPassword' => $bind_pw, 'objectclass' => ['top','inetOrgPerson']);
+ 'userPassword' => $bind_pw, 'objectclass' => ['top','inetOrgPerson']);
$ldapobject->dn($bind_dn);
$mesg = $ldapobject->update($ldap);
$mesg && $mesg->code && warn "failed to write entry: ", $mesg->error;
@@ -446,7 +419,7 @@
# create php read-only user
$ldapobject = newOrExistingLDAPEntry( $ldap, "cn=nobody,$base_dn" );
$ldapobject->replace('cn' => 'nobody', 'sn' => 'n/a n/a', 'uid' => 'nobody',
- 'userPassword' => $php_pw, 'objectclass' => ['top','inetOrgPerson']);
+ 'userPassword' => $php_pw, 'objectclass' => ['top','inetOrgPerson']);
$ldapobject->dn("cn=nobody,$base_dn");
$mesg = $ldapobject->update($ldap);
$mesg && $mesg->code && warn "failed to write entry: ", $mesg->error;
@@ -464,8 +437,8 @@
}
print "LDAP setup finished\n\n";
-
- print "Create initial config files for postfix, apache, proftpd, cyrus imap, saslauthd\n";
+
+ print "Create initial config files for postfix, apache, proftpd, cyrus imap, saslauthd\n";
my $cfg;
open(FH, "<$kolab_prefix/etc/rc.conf") || die;
@@ -505,14 +478,14 @@
chomp $tmp;
if( lc $tmp eq 'n' ) {
print <<'EOS';
-Skipping certificate creation. Please copy your certificate to
+Skipping certificate creation. Please copy your certificate to
@l_prefix@/etc/kolab/cert.pem and private key to
@l_prefix@/etc/kolab/key.pem when the bootstrap script is finished.
EOS
} else {
print <<'EOS';
-Now we need to create a cerificate authority (CA) for Kolab and a server
+Now we need to create a cerificate authority (CA) for Kolab and a server
certificate. You will be prompted for a passphrase for the CA.
################################################################################
EOS
@@ -559,7 +532,7 @@
$ldap_uri = ReadLine;
chomp $ldap_uri;
my $ldapuri = URI->new($ldap_uri) || warn "error: could not parse given uri";
- if( $ldapuri ) {
+ if( $ldapuri ) {
$base_dn = join( ',', map { "dc=$_" } split /\./, $ldapuri->host() );
}
print "Base DN of server [$base_dn]: ";
@@ -628,17 +601,17 @@
open(FH, "<$kolab_prefix/etc/rc.conf") || die;
$cfg .= $_ while (<FH>);
close(FH);
-
+
$cfg =~ s/\n((openldap_url|sasl_authmech|openldap_enable)\S*=[^\n]*)/#$1\n/sg;
$cfg .= "openldap_enable=\"no\"\nopenldap_url=\"\"\nsasl_authmech=\"ldap\"\n";
-
+
open(FH, ">$kolab_prefix/etc/rc.conf") || die;
print FH $cfg;
close(FH);
undef $cfg;
print <<'EOS';
-If you chose to create a CA on the master server, you will now need to create
+If you chose to create a CA on the master server, you will now need to create
a certificate request and copy it to the master to get it signed. If you already
have a certificate for this server, you can choose to skip this section.
EOS
@@ -653,7 +626,7 @@
EOS
} else {
-
+
print <<'EOS';
Now we need to create a cerificate request for this slave
and then ssh to the master server to have the request signed.
@@ -675,7 +648,7 @@
system("chmod 0640 $kolab_prefix/etc/kolab/key.pem;");
system("chgrp @l_rusr@ $kolab_prefix/etc/kolab/cert.pem;");
system("chmod 0640 $kolab_prefix/etc/kolab/cert.pem;");
-
+
print <<'EOS';
################################################################################
Certificate creation done!
More information about the commits
mailing list