From 6305fd053b5c6938fea04ea17f73be56db7e21d0 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Sun, 16 Jun 2024 14:24:23 +0200 Subject: [PATCH] fix systemd test --- bin/sau | 2 +- sau/gentoo.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/sau b/bin/sau index 383d385..426bee2 100755 --- a/bin/sau +++ b/bin/sau @@ -48,7 +48,7 @@ def fork_and_reboot(): log = logging.getLogger(sau.LOGNAME) if os.path.exist('/proc/1/comm'): with open('/proc/1/comm', 'r') as f: - if f.readline() == 'systemd': + if f.readline().strip() == 'systemd': os.execl('/usr/bin/systemctl', 'reboot') log.error("Failed to execl?") sys.exit(1) diff --git a/sau/gentoo.py b/sau/gentoo.py index f1b8fe7..e77d52e 100644 --- a/sau/gentoo.py +++ b/sau/gentoo.py @@ -22,7 +22,7 @@ def identify_service_from_bin(exe): log = logging.getLogger(sau.LOGNAME) with open('/proc/1/comm', 'r') as f: - if f.readline() == 'systemd': + if f.readline().strip() == 'systemd': init_script_re = re.compile(r'[^/]*(.*)\.service$') else: init_script_re = re.compile(r'/etc/init\.d/(.*)') @@ -61,7 +61,7 @@ def identify_service_from_bin(exe): def restart_service(service): log = logging.getLogger(sau.LOGNAME) with open('/proc/1/comm', 'r') as f: - if f.readline() == 'systemd': + if f.readline().strip() == 'systemd': cmd = [ SYSTEMCTL, 'restart', service ] else: cmd = [ RC_SERVICE_PATH, service, 'restart' ]