X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fceph-detect-init%2Fceph_detect_init%2Fgentoo%2F__init__.py;fp=src%2Fceph%2Fsrc%2Fceph-detect-init%2Fceph_detect_init%2Fgentoo%2F__init__.py;h=c6f4e1e2429f871948aca5a654082d4c72f8dae1;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/ceph-detect-init/ceph_detect_init/gentoo/__init__.py b/src/ceph/src/ceph-detect-init/ceph_detect_init/gentoo/__init__.py new file mode 100644 index 0000000..c6f4e1e --- /dev/null +++ b/src/ceph/src/ceph-detect-init/ceph_detect_init/gentoo/__init__.py @@ -0,0 +1,34 @@ +import os +distro = None +release = None +codename = None + + +# From ceph-disk, but there is no way to access it since it's not in a module +def is_systemd(): + """ + Detect whether systemd is running; + WARNING: not mutually exclusive with openrc + """ + with open('/proc/1/comm') as i: + return 'systemd' in i.read() + + +def is_openrc(): + """ + Detect whether openrc is running. + """ + OPENRC_CGROUP = '/sys/fs/cgroup/openrc' + return os.path.isdir(OPENRC_CGROUP) + + +def choose_init(): + """Select a init system + + Returns the name of a init system (upstart, sysvinit ...). + """ + if is_openrc(): + return 'openrc' + if is_systemd(): + return 'systemd' + return 'unknown'