[pkg-kolab] r1411 - pkg-kolab_testsuite

Mathieu Parent sathieu at alioth.debian.org
Tue Nov 17 22:44:23 UTC 2009


Author: sathieu
Date: 2009-11-17 22:44:22 +0000 (Tue, 17 Nov 2009)
New Revision: 1411

Modified:
   pkg-kolab_testsuite/testsuite
Log:
- Using Expect to install kolab
- More verbose output (step by step)
- No install yet on slaves


Modified: pkg-kolab_testsuite/testsuite
===================================================================
--- pkg-kolab_testsuite/testsuite	2009-11-17 21:05:19 UTC (rev 1410)
+++ pkg-kolab_testsuite/testsuite	2009-11-17 22:44:22 UTC (rev 1411)
@@ -101,6 +101,9 @@
     'bridge' => 'br0',
     'dnsdomain' => 'local.tld',
     
+    'kolab_manager_password' => '12345',
+    'ca_passphrase' => '12345678',
+    
 );
 
 #disable buffer
@@ -193,7 +196,7 @@
     my $domname = shift;
     my $domip = domain_ip($domid, $domname);
     
-    $Expect::Log_Stdout = 0;
+    #$Expect::Log_Stdout = 0;
     return Expect->spawn("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip")
 }
 
@@ -409,20 +412,262 @@
     my $domname = shift;
     my $domip = domain_ip($domid, $domname);
     
-    #/etc/hosts file
+    if($domid != 0) {
+        print "* Installing slaves is not supported yet\n";
+        return;
+    }
+    
+    print "* Copying /etc/hosts file:\n";
     my $hosts = hosts_file();
     system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'cat <<EOF >> /etc/hosts
 $hosts
 EOF'");
-    #package repository
+    print "* Updating APT:\n";
     system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'cat <<EOF > /etc/apt/sources.list.d/kolab.list
 #kolab
 deb http://pkg-kolab.alioth.debian.org/packages kolab-snapshots/
 deb http://pkg-kolab.alioth.debian.org/packages UNRELEASED/
 EOF'");
     system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'apt-get -qq update'");
-    print "TODO: follow https://wiki.kolab.org/index.php/Debian_-_Administrators_-_Kolab_Installation\n";
-    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip");
+    print "* Following https://wiki.kolab.org/index.php/Debian_-_Administrators_-_Kolab_Installation\n";
+
+    print "* Installing:\n";
+    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'DEBIAN_FRONTEND=noninteractive apt-get -y install kolabd postfix slapd'");
+    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/apache2 stop'");
+    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/kolabd stop'");
+    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/kolab-cyrus stop'");
+    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/postfix stop'");
+    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/saslauthd stop'");
+    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/slapd stop'");
+    system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip '/etc/init.d/amavis stop #optionally'");
+
+    print "* Kolab bootstrap:\n";
+    my $exp = console_create($domid, $domname);
+    $exp->log_file("$domname.log");
+    my $step = 0;
+    $exp->expect(60, # 60 seconds (wait for OpenLDAP to start)
+        [
+            '-re', qr'[#>] $',#prompt
+            sub {
+                my $fh = shift;
+                if( $step == 0 ) {
+                    $fh->send("kolab_bootstrap -b\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step (should be 0)\n";
+                }
+            },
+        ],
+        [
+            qr'Continue \[n\] \(y/n\): $',
+            sub {
+                my $fh = shift;
+                if( $step == 1 ) {
+                    $fh->send("y\n");
+                    $step++;
+                    exp_continue;
+                } else {
+                    print "Step is $step (should be 1)\n";
+                }
+            },
+        ],
+        [
+            qr'Please enter Hostname including Domain Name \(e.g. thishost.domain.tld\) \['.$domname.".".$config{'dnsdomain'}.'\]: $',
+            sub {
+                my $fh = shift;
+                $step++ if $step == 1; #Confirmation is skipped if "LDAP repository is empty"
+                if( $step == 2 ) {
+                    $fh->send("\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step (should be 2)\n";
+                }
+            },
+        ],
+        #Proceeding with Hostname kolab_test_master.local.tld
+        [
+            qr'Do you want to set up \(1\) a master Kolab server or \(2\) a slave \[1\] \(1/2\): $',
+            sub {
+                my $fh = shift;
+                if( $step == 3 ) {
+                    if($domid == 0) {
+                        $fh->send("1\n");
+                    } else {
+                        $fh->send("2\n");
+                    }
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step (should be 3)\n";
+                }
+            },
+        ],
+        [
+            qr'Please enter your Maildomain - if you do not know your mail domain use the fqdn from above \['.$config{'dnsdomain'}.'\]: $',
+            sub {
+                my $fh = shift;
+                if( $step == 4 ) {
+                    $fh->send("\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step (should be 4)\n";
+                }
+            },
+        ],
+        [
+            qr'Top level DN for Kolab \[dc=local,dc=tld\]: $',
+            sub {
+                my $fh = shift;
+                if( $step == 5 ) {
+                    $fh->send("\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'Please choose a manager password \[.+\]: $',
+            sub {
+                my $fh = shift;
+                if( $step == 6 ) {
+                    $fh->send($config{'kolab_manager_password'}."\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'Enter fully qualified hostname of slave kolab server e.g. thishost.domain.tld \[empty when done\]: $',
+            sub {
+                my $fh = shift;
+                if( ($step >= 7) and ($step < 7 + $config{'slave_count'})) {
+                    $fh->send("kolab_test_slave".($step-6).".".$config{'dnsdomain'}."\n");
+                    $step++;
+                    return exp_continue;
+                }
+                if($step == 7 + $config{'slave_count'}) {
+                    $fh->send("\n"); #empty when done
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'Do you want to create CA and certificates \[y\] \(y/n\): $',
+            sub {
+                my $fh = shift;
+                if( $step == 8 + $config{'slave_count'} ) {
+                    $fh->send("y\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'Enter organization name \[Kolab\]: $',
+            sub {
+                my $fh = shift;
+                if( $step == 9 + $config{'slave_count'} ) {
+                    $fh->send("\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'Enter organizational unit \[Test-CA\]: $',
+            sub {
+                my $fh = shift;
+                if( $step == 10 + $config{'slave_count'} ) {
+                    $fh->send("\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'CA certificate filename \(or enter to create\)\s$',
+            sub {
+                my $fh = shift;
+                if( $step == 11 + $config{'slave_count'} ) {
+                    $fh->send("\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'^Enter PEM pass phrase:$'m,
+            sub {
+                my $fh = shift;
+                if( $step == 12 + $config{'slave_count'} ) {
+                    $fh->send($config{'ca_passphrase'}."\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'^Verifying - Enter PEM pass phrase:$'m,
+            sub {
+                my $fh = shift;
+                if( $step == 13 + $config{'slave_count'} ) {
+                    $fh->send($config{'ca_passphrase'}."\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'Enter pass phrase for /etc/kolab/ca/private/cakey.pem:$',
+            sub {
+                my $fh = shift;
+                if( $step == 14 + $config{'slave_count'} ) {
+                    $fh->send($config{'ca_passphrase'}."\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+        [
+            qr'Sign the certificate\? \[y/n\]:$',
+            sub {
+                my $fh = shift;
+                if( $step == 15 + $config{'slave_count'} ) {
+                    $fh->send("y\n");
+                    $step++;
+                    return exp_continue;
+                } else {
+                    print "Step is $step\n";
+                }
+            },
+        ],
+    );
+
+    print "* Installing PHP Unit:\n";
     system("ssh -i '".$config{'storagepooldir'}."/key' root\@$domip 'apt-get -qy install phpunit'");
 }
 




More information about the pkg-kolab-devel mailing list