aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Quigley <bryan.quigley@canonical.com>2020-02-11 15:03:16 -0800
committerBryan Quigley <bryan.quigley@canonical.com>2020-02-11 15:03:16 -0800
commit285873a4f753822a88d475a1b030ab622bf4c72e (patch)
tree2c22fadcd5679e4fa4a44cb17b18c66a411914a4
parent4a77a4a872fd7b9defdda2fc8b6c65f5dde9247e (diff)
downloadsos-285873a4f753822a88d475a1b030ab622bf4c72e.tar.gz
[policies] Detect systemd use instead of hardcoding it
This just has us the builtin option to determine if we are on systemd or not. https://www.freedesktop.org/software/systemd/man/sd_booted.html Resolves: #1936 Signed-off-by: Bryan Quigley <bryan.quigley@canonical.com>
-rw-r--r--sos/policies/__init__.py3
-rw-r--r--sos/policies/redhat.py1
2 files changed, 2 insertions, 2 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 651abc6c..f1a88b90 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -842,7 +842,8 @@ class LinuxPolicy(Policy):
def __init__(self, sysroot=None):
super(LinuxPolicy, self).__init__(sysroot=sysroot)
self.init_kernel_modules()
- if self.init == 'systemd':
+
+ if os.path.isdir("/run/systemd/system/"):
self.init_system = SystemdInit()
else:
self.init_system = InitSystem()
diff --git a/sos/policies/redhat.py b/sos/policies/redhat.py
index d555441c..99d7b501 100644
--- a/sos/policies/redhat.py
+++ b/sos/policies/redhat.py
@@ -36,7 +36,6 @@ class RedHatPolicy(LinuxPolicy):
_host_sysroot = '/'
default_scl_prefix = '/opt/rh'
name_pattern = 'friendly'
- init = 'systemd'
def __init__(self, sysroot=None):
super(RedHatPolicy, self).__init__(sysroot=sysroot)