From: Sage Weil Date: Thu, 14 Feb 2013 00:02:10 +0000 (-0800) Subject: ceph-disk-activate: auto detect init system X-Git-Tag: v0.58~51^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d1904b2a848af3c02d2065ac2a42abe0e2699d0f;p=ceph.git ceph-disk-activate: auto detect init system 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 --- diff --git a/src/ceph-disk-activate b/src/ceph-disk-activate index 13c83cec8641..71b5097cf365 100755 --- a/src/ceph-disk-activate +++ b/src/ceph-disk-activate @@ -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(