]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/ceph-detect-init/ceph_detect_init/debian/__init__.py
update sources to v12.1.0
[ceph.git] / ceph / src / ceph-detect-init / ceph_detect_init / debian / __init__.py
index 73a7851a3fc9ab21d3c8ad73f0c94aa630358250..94217cdfa263b554c8446cfbacebc7dd4654654f 100644 (file)
@@ -1,3 +1,6 @@
+import os
+import subprocess
+
 distro = None
 release = None
 codename = None
@@ -8,14 +11,11 @@ def choose_init():
 
     Returns the name of a init system (upstart, sysvinit ...).
     """
-    assert(distro and codename)
-    if distro.lower() in ('ubuntu', 'linuxmint'):
-        if codename >= 'vivid':
-            return 'systemd'
-        else:
-            return 'upstart'
-    if distro.lower() == 'debian':
-        if codename in ('squeeze', 'wheezy'):
-            return 'sysvinit'
-        else:
-            return 'systemd'
+    # yes, this is heuristics
+    if os.path.isdir('/run/systemd/system'):
+        return 'systemd'
+    if not subprocess.call('. /lib/lsb/init-functions ; init_is_upstart',
+                           shell=True):
+        return 'upstart'
+    if os.path.isfile('/sbin/init') and not os.path.islink('/sbin/init'):
+        return 'sysvinit'