2 commits - pykolab/setup

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Fri Apr 12 18:40:44 CEST 2013


 pykolab/setup/setup_ldap.py |   41 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 37 insertions(+), 4 deletions(-)

New commits:
commit 2f989a0b931b78cb0a4e5696d1b8393c32012778
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Apr 12 18:40:20 2013 +0200

    Pull the 389 Directory Server setup returncode and act accordingly

diff --git a/pykolab/setup/setup_ldap.py b/pykolab/setup/setup_ldap.py
index be3b38a..34e6111 100644
--- a/pykolab/setup/setup_ldap.py
+++ b/pykolab/setup/setup_ldap.py
@@ -288,7 +288,24 @@ ServerAdminPwd = %(admin_pass)s
 
     (stdoutdata, stderrdata) = setup_389.communicate()
 
-    # TODO: Get the return code and display output if not successful.
+    if not setup_389.returncode == 0:
+        print >> sys.stderr, utils.multiline_message(
+                _("""
+                        An error was detected in the setup procedure for 389
+                        Directory Server. This setup will write out stderr and
+                        stdout to /var/log/kolab/setup.error.log and
+                        /var/log/kolab/setup.out.log respectively, before it
+                        exits.
+                    """)
+            )
+
+        fp = open('/var/log/kolab/setup.error.log', 'w')
+        fp.write(stderrdata)
+        fp.close()
+
+        fp = open('/var/log/kolab/setup.out.log', 'w')
+        fp.write(stderrdata)
+        fp.close()
 
     log.debug(_("Setup DS stdout:"), level=8)
     log.debug(stdoutdata, level=8)
@@ -296,9 +313,8 @@ ServerAdminPwd = %(admin_pass)s
     log.debug(_("Setup DS stderr:"), level=8)
     log.debug(stderrdata, level=8)
 
-    # TODO: Fails when ran a second time.
-
-    # TODO: When fail, fail gracefully.
+    if not setup_389.returncode == 0:
+        sys.exit(1)
 
     # Find the kolab schema. It's installed as %doc in the kolab-schema package.
     # TODO: Chown nobody, nobody, chmod 440
@@ -317,6 +333,7 @@ ServerAdminPwd = %(admin_pass)s
                             os.path.basename(schema_file)
                         )
                 )
+
             schema_error = False
         except:
             log.error(_("Could not copy the LDAP extensions for Kolab"))


commit 7329ac9b1ebe66522ddec7f11644703e065a5056
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Apr 12 18:32:40 2013 +0200

    Make sure there is not already an LDAP instance configured.

diff --git a/pykolab/setup/setup_ldap.py b/pykolab/setup/setup_ldap.py
index a7cedba..be3b38a 100644
--- a/pykolab/setup/setup_ldap.py
+++ b/pykolab/setup/setup_ldap.py
@@ -69,6 +69,22 @@ def execute(*args, **kw):
     if not conf.config_file == conf.defaults.config_file:
         ask_questions = False
 
+    # Pre-execution checks
+    for path, directories, files in os.walk('/etc/dirsrv/'):
+        for direct in directories:
+            if direct.startswith('slapd-'):
+                print >> sys.stderr, utils.multiline_message(
+                        _("""
+                                It seems 389 Directory Server has an existing
+                                instance configured. This setup script does not
+                                intend to destroy or overwrite your data. Please
+                                make sure /etc/dirsrv/ and /var/lib/dirsrv/ are
+                                clean so that this setup does not have to worry.
+                            """)
+                    )
+
+                sys.exit(1)
+
     _input = {}
 
     if ask_questions:





More information about the commits mailing list