mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix tests, rely on _get_service_information_from_systemd to fetch service info during service add
This commit is contained in:
parent
6a75716fb5
commit
f8e5ea4652
1 changed files with 16 additions and 11 deletions
|
@ -75,27 +75,32 @@ def service_add(name, description=None, log=None, log_type=None, test_status=Non
|
||||||
|
|
||||||
service['log'] = log
|
service['log'] = log
|
||||||
|
|
||||||
if description:
|
if not description:
|
||||||
service['description'] = description
|
|
||||||
else:
|
|
||||||
# Try to get the description from systemd service
|
# Try to get the description from systemd service
|
||||||
out = subprocess.check_output("systemctl show %s | grep '^Description='" % name, shell=True).strip()
|
unit, _ = _get_service_information_from_systemd(name)
|
||||||
out = out.replace("Description=", "")
|
description = unit.get("Description", "") if unit is not None else ""
|
||||||
# If the service does not yet exists or if the description is empty,
|
# 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
|
# systemd will anyway return foo.service as default value, so we wanna
|
||||||
# make sure there's actually something here.
|
# make sure there's actually something here.
|
||||||
if out == name + ".service":
|
if description == name + ".service":
|
||||||
logger.warning("/!\\ Packagers! 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.")
|
description = ""
|
||||||
else:
|
|
||||||
service['description'] = out
|
if description:
|
||||||
|
service['description'] = description
|
||||||
|
else:
|
||||||
|
logger.warning("/!\\ Packagers! 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.")
|
||||||
|
|
||||||
if need_lock:
|
if need_lock:
|
||||||
service['need_lock'] = True
|
service['need_lock'] = True
|
||||||
|
|
||||||
if test_status:
|
if test_status:
|
||||||
service["test_status"] = test_status
|
service["test_status"] = test_status
|
||||||
elif subprocess.check_output("systemctl show %s | grep '^Type='" % name, shell=True).strip() == "oneshot":
|
else:
|
||||||
logger.warning("/!\\ Packagers! Please provide a --test_status when adding oneshot-type services in Yunohost, such that it has a reliable way to check if the service is running or not.")
|
# Try to get the description from systemd service
|
||||||
|
_, service = _get_service_information_from_systemd(name)
|
||||||
|
type_ = service.get("Type") if service is not None else ""
|
||||||
|
if type_ == "oneshot":
|
||||||
|
logger.warning("/!\\ Packagers! Please provide a --test_status when adding oneshot-type services in Yunohost, such that it has a reliable way to check if the service is running or not.")
|
||||||
|
|
||||||
if test_conf:
|
if test_conf:
|
||||||
service["test_conf"] = test_conf
|
service["test_conf"] = test_conf
|
||||||
|
|
Loading…
Add table
Reference in a new issue