From d32ab073ba2719170bb3d5254d772d8100be9445 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 11 May 2018 04:21:24 +0200 Subject: [PATCH] [mod] removes status key from /etc/yunohost/service.yml for generic approach --- data/hooks/conf_regen/01-yunohost | 18 ++++++++++++++++++ data/templates/yunohost/services.yml | 25 +++++-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/data/hooks/conf_regen/01-yunohost b/data/hooks/conf_regen/01-yunohost index e1daa7c3d..faf041110 100755 --- a/data/hooks/conf_regen/01-yunohost +++ b/data/hooks/conf_regen/01-yunohost @@ -61,11 +61,17 @@ do_pre_regen() { _update_services() { sudo python2 - << EOF import yaml + + with open('services.yml') as f: new_services = yaml.load(f) + with open('/etc/yunohost/services.yml') as f: services = yaml.load(f) + updated = False + + for service, conf in new_services.items(): # remove service with empty conf if conf is None: @@ -73,20 +79,32 @@ for service, conf in new_services.items(): print("removing '{0}' from services".format(service)) del services[service] updated = True + # add new service elif not services.get(service, None): print("adding '{0}' to services".format(service)) services[service] = conf updated = True + # update service conf else: conffiles = services[service].pop('conffiles', {}) + + # status need to be removed + if "status" not in conf and "status" in services[service]: + print("update '{0}' service status access".format(service)) + del services[service]["status"] + updated = True + if services[service] != conf: print("update '{0}' service".format(service)) services[service].update(conf) updated = True + if conffiles: services[service]['conffiles'] = conffiles + + if updated: with open('/etc/yunohost/services.yml-new', 'w') as f: yaml.safe_dump(services, f, default_flow_style=False) diff --git a/data/templates/yunohost/services.yml b/data/templates/yunohost/services.yml index fb8c076f9..b4c9ab362 100644 --- a/data/templates/yunohost/services.yml +++ b/data/templates/yunohost/services.yml @@ -1,57 +1,42 @@ nginx: - status: service log: /var/log/nginx avahi-daemon: - status: service log: /var/log/daemon.log dnsmasq: - status: service log: /var/log/daemon.log fail2ban: - status: service log: /var/log/fail2ban.log dovecot: - status: service log: [/var/log/mail.log,/var/log/mail.err] postfix: - status: service log: [/var/log/mail.log,/var/log/mail.err] rmilter: - status: systemctl status rmilter.service log: /var/log/mail.log rspamd: - status: systemctl status rspamd.service log: /var/log/mail.log redis-server: - status: service log: /var/log/redis/redis-server.log mysql: - status: service log: [/var/log/mysql.log,/var/log/mysql.err] -glances: - status: service +glances: {} ssh: - status: service log: /var/log/auth.log +ssl: + status: null metronome: - status: metronomectl status log: [/var/log/metronome/metronome.log,/var/log/metronome/metronome.err] slapd: - status: service log: /var/log/syslog php5-fpm: - status: service log: /var/log/php5-fpm.log yunohost-api: - status: service log: /var/log/yunohost/yunohost-api.log yunohost-firewall: - status: service need_lock: true nslcd: - status: service log: /var/log/syslog -nsswitch: {} +nsswitch: + status: null bind9: null tahoe-lafs: null memcached: null