mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Custom service description: let's be a bit smarter and use the one from the systemd service if it exists
This commit is contained in:
parent
fea733ce31
commit
c97a839630
1 changed files with 10 additions and 1 deletions
|
@ -79,7 +79,16 @@ def service_add(name, description=None, log=None, log_type="file", test_status=N
|
||||||
if description:
|
if description:
|
||||||
services[name]['description'] = description
|
services[name]['description'] = description
|
||||||
else:
|
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:
|
if need_lock:
|
||||||
services[name]['need_lock'] = True
|
services[name]['need_lock'] = True
|
||||||
|
|
Loading…
Add table
Reference in a new issue