From c97a839630e0011442a588b7f56eb0ca8f7a974b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sun, 1 Dec 2019 18:41:47 +0100 Subject: [PATCH] Custom service description: let's be a bit smarter and use the one from the systemd service if it exists --- src/yunohost/service.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/yunohost/service.py b/src/yunohost/service.py index f8553fbf7..748037df6 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -79,7 +79,16 @@ def service_add(name, description=None, log=None, log_type="file", test_status=N if description: services[name]['description'] = description else: - logger.warning("/!\\ Packager ! You added a custom service without specifying a description. Please add --description to explain what the service does in a similar fashion to existing services.") + # Try to get the description from systemd service + out = subprocess.check_output("systemctl show %s | grep '^Description='" % name, shell=True) + out = out.replace("Description=", "") + # If the service does not yet exists or if the description is empty, + # systemd will anyway return foo.service as default value, so we wanna + # make sure there's actually something here. + if out == name + ".service": + logger.warning("/!\\ Packager ! You added a custom service without specifying a description. Please add a proper Description in the systemd configuration, or use --description to explain what the service does in a similar fashion to existing services.") + else: + services[name]['description'] = out if need_lock: services[name]['need_lock'] = True