mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add migration for services.yml on existing instance
This commit is contained in:
parent
96bd6f8deb
commit
0ebbb83191
3 changed files with 57 additions and 6 deletions
|
@ -20,8 +20,6 @@ mysql:
|
|||
glances: {}
|
||||
ssh:
|
||||
log: /var/log/auth.log
|
||||
ssl:
|
||||
status: null
|
||||
metronome:
|
||||
log: [/var/log/metronome/metronome.log,/var/log/metronome/metronome.err]
|
||||
slapd:
|
||||
|
@ -34,10 +32,9 @@ yunohost-firewall:
|
|||
need_lock: true
|
||||
nslcd:
|
||||
log: /var/log/syslog
|
||||
nsswitch:
|
||||
status: null
|
||||
yunohost:
|
||||
status: null
|
||||
nsswitch: null
|
||||
ssl: null
|
||||
yunohost: null
|
||||
bind9: null
|
||||
tahoe-lafs: null
|
||||
memcached: null
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
import os
|
||||
|
||||
from moulinette import m18n
|
||||
from moulinette.utils.log import getActionLogger
|
||||
|
||||
from moulinette.utils.filesystem import read_file
|
||||
from yunohost.service import _get_services, _save_services
|
||||
from yunohost.regenconf import _update_conf_hashes
|
||||
|
||||
from yunohost.tools import Migration
|
||||
|
||||
logger = getActionLogger('yunohost.migration')
|
||||
|
||||
|
||||
class MyMigration(Migration):
|
||||
"""
|
||||
Decouple the regen conf mechanism from the concept of services
|
||||
"""
|
||||
|
||||
def migrate(self):
|
||||
|
||||
if "conffiles" not in read_file("/etc/yunohost/services.yml") \
|
||||
or os.path.exists("/etc/yunohost/regenconf.yml"):
|
||||
logger.warning(m18n.n("migration_0009_not_needed"))
|
||||
return
|
||||
|
||||
# For all services
|
||||
services = _get_services()
|
||||
for service, infos in services.items():
|
||||
# If there are some conffiles (file hashes)
|
||||
if "conffiles" in infos.keys():
|
||||
# Save them using the new regen conf thingy
|
||||
_update_conf_hashes(service, infos["conffiles"])
|
||||
# And delete the old conffile key from the service infos
|
||||
del services[service]["conffiles"]
|
||||
|
||||
# (Actually save the modification of services)
|
||||
_save_services(services)
|
||||
|
||||
def backward(self):
|
||||
|
||||
pass
|
|
@ -31,6 +31,7 @@ from datetime import datetime
|
|||
|
||||
from moulinette import m18n
|
||||
from moulinette.utils import log, filesystem
|
||||
from moulinette.utils.filesystem import read_file
|
||||
|
||||
from yunohost.utils.error import YunohostError
|
||||
from yunohost.log import is_unit_operation
|
||||
|
@ -60,6 +61,17 @@ def regen_conf(operation_logger, names=[], with_diff=False, force=False, dry_run
|
|||
list_pending -- List pending configuration files and exit
|
||||
|
||||
"""
|
||||
|
||||
# Legacy code to automatically run the migration
|
||||
# This is required because regen_conf is called before the migration call
|
||||
# in debian's postinst script
|
||||
if os.path.exists("/etc/yunohost/installed") \
|
||||
and ("conffiles" in read_file("/etc/yunohost/services.yml") \
|
||||
or not os.path.exists("/etc/yunohost/regenconf.yml")):
|
||||
from yunohost.tools import _get_migration_by_name
|
||||
migration = _get_migration_by_name("decouple_regenconf_from_services")
|
||||
migration.migrate()
|
||||
|
||||
result = {}
|
||||
|
||||
# Return the list of pending conf
|
||||
|
|
Loading…
Add table
Reference in a new issue