From 69d2ad9a8ad8c9fbd95b7a0bb87b19656b12793d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Wed, 3 Apr 2019 16:56:29 +0200 Subject: [PATCH] Fix loaded status for sysv services --- src/yunohost/service.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/yunohost/service.py b/src/yunohost/service.py index 896090228..b139c0b6d 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -31,6 +31,7 @@ import subprocess import shutil import hashlib +from glob import glob from difflib import unified_diff from datetime import datetime @@ -330,6 +331,12 @@ def service_status(names=[]): 'description': description, 'service_file_path': str(status.get("FragmentPath", "unknown")), } + + # Fun stuff™ : to obtain the enabled/disabled status for sysv services, + # gotta do this ... cf code of /lib/systemd/systemd-sysv-install + if result[name]["loaded"] == "generated": + result[name]["loaded"] = "enabled" if glob("/etc/rc[S5].d/S??"+name) else "disabled" + if "ActiveEnterTimestamp" in status: result[name]['active_at'] = datetime.utcfromtimestamp(status["ActiveEnterTimestamp"] / 1000000) else: