From e65c0f896a3938738e861325f39b87d6e1114442 Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Thu, 22 Oct 2015 22:26:51 +0200 Subject: [PATCH 1/2] simpler way to check if systemd is the init system According to http://www.freedesktop.org/software/systemd/man/sd_booted.html check if the directory /run/systemd/system/ exists. --- system/service.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/system/service.py b/system/service.py index f9a8b1e24c1..227d34c1463 100644 --- a/system/service.py +++ b/system/service.py @@ -403,22 +403,7 @@ class LinuxService(Service): self.svc_initscript = initscript def check_systemd(): - # verify systemd is installed (by finding systemctl) - if not location.get('systemctl', False): - return False - - # Check if init is the systemd command, using comm as cmdline could be symlink - try: - f = open('/proc/1/comm', 'r') - except IOError, err: - # If comm doesn't exist, old kernel, no systemd - return False - - for line in f: - if 'systemd' in line: - return True - - return False + return os.path.exists("/run/systemd/system/") # Locate a tool to enable/disable a service if location.get('systemctl',False) and check_systemd(): From 6233e72001c4c8d785b7e82123ee6fb4c8c93a6e Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Sat, 24 Oct 2015 00:18:43 +0200 Subject: [PATCH 2/2] added earlier paths to systemd https://github.com/systemd/systemd/commit/2b583ce6576d4a074ce6f1570b3e60b65c64ae7d https://github.com/systemd/systemd/commit/b925e72633bf98438f56a140520e07ec8c959e46 --- system/service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/service.py b/system/service.py index 227d34c1463..d08b6cd6746 100644 --- a/system/service.py +++ b/system/service.py @@ -403,7 +403,7 @@ class LinuxService(Service): self.svc_initscript = initscript def check_systemd(): - return os.path.exists("/run/systemd/system/") + return os.path.exists("/run/systemd/system/") or os.path.exists("/dev/.run/systemd/") or os.path.exists("/dev/.systemd/") # Locate a tool to enable/disable a service if location.get('systemctl',False) and check_systemd():