+import os
+import subprocess
+
distro = None
release = None
codename = None
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'