]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk-activate: auto detect init system
authorSage Weil <sage@inktank.com>
Thu, 14 Feb 2013 00:02:10 +0000 (16:02 -0800)
committerSage Weil <sage@inktank.com>
Fri, 26 Apr 2013 20:40:01 +0000 (13:40 -0700)
Look for an option 'init' in ceph.conf.  Otherwise, check if we're ubuntu.
If so, use upstart.  Otherwise, use sysvinit.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit d1904b2a848af3c02d2065ac2a42abe0e2699d0f)

src/ceph-disk-activate

index 13c83cec864136132117c9e519078c2111633b74..71b5097cf3658c44ae10b8f68f45e003faab7bf3 100755 (executable)
@@ -5,6 +5,7 @@ import errno
 import logging
 import os
 import os.path
+import platform
 import re
 import subprocess
 import stat
@@ -15,6 +16,7 @@ init_systems = [
     'upstart',
     'sysvinit',
     'systemd',
+    'auto',
     ]
 
 log_name = __name__
@@ -582,6 +584,20 @@ def activate(
                 )
 
         if init is not None:
+            if init == 'auto':
+                c = get_conf(
+                    cluster=cluster,
+                    variable='init'
+                    )
+                if c is not None:
+                    init = c
+                else:
+                    (distro, release, codename) = platform.dist()
+                    if distro == 'Ubuntu':
+                        init = 'upstart'
+                    else:
+                        init = 'sysvinit'
+
             log.debug('Marking with init system %s', init)
             with file(os.path.join(path, init), 'w'):
                 pass
@@ -638,6 +654,7 @@ def parse_args():
         '--mark-init',
         metavar='INITSYSTEM',
         help='init system to manage this dir',
+        default='auto',
         choices=init_systems,
         )
     parser.set_defaults(