initial code repo
[stor4nfv.git] / src / ceph / src / ceph-detect-init / ceph_detect_init / debian / __init__.py
diff --git a/src/ceph/src/ceph-detect-init/ceph_detect_init/debian/__init__.py b/src/ceph/src/ceph-detect-init/ceph_detect_init/debian/__init__.py
new file mode 100644 (file)
index 0000000..94217cd
--- /dev/null
@@ -0,0 +1,21 @@
+import os
+import subprocess
+
+distro = None
+release = None
+codename = None
+
+
+def choose_init():
+    """Select a init system
+
+    Returns the name of a init system (upstart, sysvinit ...).
+    """
+    # 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'