[PATCH 03/16] Debianize service restarting tools ("/usr/sbin/service") and start-sequence integration ("/usr/sbin/update-rc.d");

Johannes Graumann johannes_graumann at web.de
Mon Oct 1 16:38:24 CEST 2012


Additionally (temporary?) fix dirsrv startup script bug which prevents "service dirsrv restart", as the 389 port is not yet freed
when the new process is starting;
---
 pykolab/setup/setup_ldap.py |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/pykolab/setup/setup_ldap.py b/pykolab/setup/setup_ldap.py
index d93e1d8..cf1c76a 100644
--- a/pykolab/setup/setup_ldap.py
+++ b/pykolab/setup/setup_ldap.py
@@ -23,6 +23,7 @@ import os
 import shutil
 import subprocess
 import tempfile
+import time
 
 import components
 
@@ -289,12 +290,23 @@ ServerAdminPwd = %(admin_pass)s
 
     if os.path.isfile('/bin/systemctl'):
         subprocess.call(['/bin/systemctl', 'restart', 'dirsrv.target'])
-        subprocess.call(['/bin/systemctl', 'enable', 'dirsrv.target'])
     elif os.path.isfile('/sbin/service'):
         subprocess.call(['/sbin/service', 'dirsrv', 'restart'])
+    elif os.path.isfile('/usr/sbin/service'):
+	subprocess.call(['/usr/sbin/service','dirsrv','stop'])
+	time.sleep(20)
+	subprocess.call(['/usr/sbin/service','dirsrv','start'])
+    else:
+        log.error(_("Could not start the directory server service."))
+
+    if os.path.isfile('/bin/systemctl'):
+        subprocess.call(['/bin/systemctl', 'enable', 'dirsrv.target'])
+    elif os.path.isfile('/sbin/chkconfig'):
         subprocess.call(['/sbin/chkconfig', 'dirsrv', 'on'])
+    elif os.path.isfile('/usr/sbin/update-rc.d'):
+        subprocess.call(['/usr/sbin/update-rc.d', 'dirsrv', 'defaults'])
     else:
-        log.error(_("Could not start and configure to start on boot, the " + \
+        log.error(_("Could not configure to start on boot, the " + \
                 "directory server service."))
 
     if ask_questions:
@@ -529,8 +541,10 @@ ServerAdminPwd = %(admin_pass)s
 
     if os.path.isfile('/bin/systemctl'):
         subprocess.call(['/bin/systemctl', 'enable', 'dirsrv-admin.service'])
-    elif os.path.isfile('/sbin/service'):
+    elif os.path.isfile('/sbin/chkconfig'):
         subprocess.call(['/sbin/chkconfig', 'dirsrv-admin', 'on'])
+    elif os.path.isfile('/usr/sbin/update-rc.d'):
+        subprocess.call(['/usr/sbin/update-rc.d', 'dirsrv-admin', 'defaults'])
     else:
         log.error(_("Could not start and configure to start on boot, the " + \
                 "directory server admin service."))
-- 
1.7.10.4




More information about the devel mailing list