[mod] removes status key from /etc/yunohost/service.yml for generic approach

This commit is contained in:
Laurent Peuch 2018-05-11 04:21:24 +02:00
parent cc240e94ca
commit d32ab073ba
2 changed files with 23 additions and 20 deletions

View file

@ -61,11 +61,17 @@ do_pre_regen() {
_update_services() { _update_services() {
sudo python2 - << EOF sudo python2 - << EOF
import yaml import yaml
with open('services.yml') as f: with open('services.yml') as f:
new_services = yaml.load(f) new_services = yaml.load(f)
with open('/etc/yunohost/services.yml') as f: with open('/etc/yunohost/services.yml') as f:
services = yaml.load(f) services = yaml.load(f)
updated = False updated = False
for service, conf in new_services.items(): for service, conf in new_services.items():
# remove service with empty conf # remove service with empty conf
if conf is None: if conf is None:
@ -73,20 +79,32 @@ for service, conf in new_services.items():
print("removing '{0}' from services".format(service)) print("removing '{0}' from services".format(service))
del services[service] del services[service]
updated = True updated = True
# add new service # add new service
elif not services.get(service, None): elif not services.get(service, None):
print("adding '{0}' to services".format(service)) print("adding '{0}' to services".format(service))
services[service] = conf services[service] = conf
updated = True updated = True
# update service conf # update service conf
else: else:
conffiles = services[service].pop('conffiles', {}) 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: if services[service] != conf:
print("update '{0}' service".format(service)) print("update '{0}' service".format(service))
services[service].update(conf) services[service].update(conf)
updated = True updated = True
if conffiles: if conffiles:
services[service]['conffiles'] = conffiles services[service]['conffiles'] = conffiles
if updated: if updated:
with open('/etc/yunohost/services.yml-new', 'w') as f: with open('/etc/yunohost/services.yml-new', 'w') as f:
yaml.safe_dump(services, f, default_flow_style=False) yaml.safe_dump(services, f, default_flow_style=False)

View file

@ -1,57 +1,42 @@
nginx: nginx:
status: service
log: /var/log/nginx log: /var/log/nginx
avahi-daemon: avahi-daemon:
status: service
log: /var/log/daemon.log log: /var/log/daemon.log
dnsmasq: dnsmasq:
status: service
log: /var/log/daemon.log log: /var/log/daemon.log
fail2ban: fail2ban:
status: service
log: /var/log/fail2ban.log log: /var/log/fail2ban.log
dovecot: dovecot:
status: service
log: [/var/log/mail.log,/var/log/mail.err] log: [/var/log/mail.log,/var/log/mail.err]
postfix: postfix:
status: service
log: [/var/log/mail.log,/var/log/mail.err] log: [/var/log/mail.log,/var/log/mail.err]
rmilter: rmilter:
status: systemctl status rmilter.service
log: /var/log/mail.log log: /var/log/mail.log
rspamd: rspamd:
status: systemctl status rspamd.service
log: /var/log/mail.log log: /var/log/mail.log
redis-server: redis-server:
status: service
log: /var/log/redis/redis-server.log log: /var/log/redis/redis-server.log
mysql: mysql:
status: service
log: [/var/log/mysql.log,/var/log/mysql.err] log: [/var/log/mysql.log,/var/log/mysql.err]
glances: glances: {}
status: service
ssh: ssh:
status: service
log: /var/log/auth.log log: /var/log/auth.log
ssl:
status: null
metronome: metronome:
status: metronomectl status
log: [/var/log/metronome/metronome.log,/var/log/metronome/metronome.err] log: [/var/log/metronome/metronome.log,/var/log/metronome/metronome.err]
slapd: slapd:
status: service
log: /var/log/syslog log: /var/log/syslog
php5-fpm: php5-fpm:
status: service
log: /var/log/php5-fpm.log log: /var/log/php5-fpm.log
yunohost-api: yunohost-api:
status: service
log: /var/log/yunohost/yunohost-api.log log: /var/log/yunohost/yunohost-api.log
yunohost-firewall: yunohost-firewall:
status: service
need_lock: true need_lock: true
nslcd: nslcd:
status: service
log: /var/log/syslog log: /var/log/syslog
nsswitch: {} nsswitch:
status: null
bind9: null bind9: null
tahoe-lafs: null tahoe-lafs: null
memcached: null memcached: null