mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add test about configuration validity
This commit is contained in:
parent
d879d27208
commit
e15d8e7262
2 changed files with 10 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
nginx:
|
||||
log: /var/log/nginx
|
||||
test-conf: nginx -t
|
||||
avahi-daemon:
|
||||
log: /var/log/daemon.log
|
||||
dnsmasq:
|
||||
|
@ -20,12 +21,14 @@ mysql:
|
|||
alternates: ['mariadb']
|
||||
ssh:
|
||||
log: /var/log/auth.log
|
||||
test-conf: sshd -t
|
||||
metronome:
|
||||
log: [/var/log/metronome/metronome.log,/var/log/metronome/metronome.err]
|
||||
slapd:
|
||||
log: /var/log/syslog
|
||||
php7.0-fpm:
|
||||
log: /var/log/php7.0-fpm.log
|
||||
test-conf: php-fpm7.0 --test
|
||||
yunohost-api:
|
||||
log: /var/log/yunohost/yunohost-api.log
|
||||
yunohost-firewall:
|
||||
|
|
|
@ -297,6 +297,7 @@ def service_status(names=[]):
|
|||
'active_at': "unknown",
|
||||
'description': "Error: failed to get information for this service, it doesn't exists for systemd",
|
||||
'service_file_path': "unknown",
|
||||
'configuration': "unknown",
|
||||
}
|
||||
|
||||
else:
|
||||
|
@ -318,6 +319,7 @@ def service_status(names=[]):
|
|||
'active': str(status.get("ActiveState", "unknown")),
|
||||
'description': description,
|
||||
'service_file_path': str(status.get("FragmentPath", "unknown")),
|
||||
'configuration': "unknown",
|
||||
}
|
||||
|
||||
# Fun stuff™ : to obtain the enabled/disabled status for sysv services,
|
||||
|
@ -335,6 +337,11 @@ def service_status(names=[]):
|
|||
status = os.system(services[name]["test-status"])
|
||||
result[name]["status"] = "running" if status == 0 else "failed"
|
||||
|
||||
# 'test-status' is an optional field to test the status of the service using a custom command
|
||||
if "test-conf" in services[name]:
|
||||
conf = os.system(services[name]["test-conf"] + " &>/dev/null")
|
||||
result[name]["configuration"] = "valid" if conf == 0 else "broken"
|
||||
|
||||
if len(names) == 1:
|
||||
return result[names[0]]
|
||||
return result
|
||||
|
|
Loading…
Add table
Reference in a new issue