diff --git a/data/templates/yunohost/services.yml b/data/templates/yunohost/services.yml index 1c0ee031f..a9948fc69 100644 --- a/data/templates/yunohost/services.yml +++ b/data/templates/yunohost/services.yml @@ -10,6 +10,7 @@ dovecot: log: [/var/log/mail.log,/var/log/mail.err] postfix: log: [/var/log/mail.log,/var/log/mail.err] + test-status: systemctl show postfix@- | grep -q "^SubState=running" rspamd: log: /var/log/rspamd/rspamd.log redis-server: @@ -29,6 +30,7 @@ yunohost-api: log: /var/log/yunohost/yunohost-api.log yunohost-firewall: need_lock: true + test-status: iptables -S | grep "^-A INPUT" | grep " --dport" | grep -q ACCEPT nslcd: log: /var/log/syslog glances: null diff --git a/src/yunohost/service.py b/src/yunohost/service.py index 17a3cc83e..96a7061e3 100644 --- a/src/yunohost/service.py +++ b/src/yunohost/service.py @@ -330,6 +330,11 @@ def service_status(names=[]): else: result[name]['active_at'] = "unknown" + # 'test-status' is an optional field to test the status of the service using a custom command + if "test-status" in services[name]: + status = os.system(services[name]["test-status"]) + result[name]["status"] = "running" if status == 0 else "failed" + if len(names) == 1: return result[names[0]] return result