mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Fix and improve migration
This commit is contained in:
parent
7afe07018e
commit
756237c051
3 changed files with 8 additions and 20 deletions
|
@ -428,6 +428,8 @@
|
||||||
"migration_0011_update_LDAP_database": "Updating LDAP database…",
|
"migration_0011_update_LDAP_database": "Updating LDAP database…",
|
||||||
"migration_0011_update_LDAP_schema": "Updating LDAP schema…",
|
"migration_0011_update_LDAP_schema": "Updating LDAP schema…",
|
||||||
"migration_0011_failed_to_remove_stale_object": "Could not remove stale object {dn}: {error}",
|
"migration_0011_failed_to_remove_stale_object": "Could not remove stale object {dn}: {error}",
|
||||||
|
"migration_0015_add_new_attributes_in_ldap": "Add new attributes for permissions in LDAP database",
|
||||||
|
"migration_0015_migrate_old_app_settings": "Migrate old apps settings 'skipped_uris', 'unprotected_uris', 'protected_uris' in permissions system.",
|
||||||
"migrations_already_ran": "Those migrations are already done: {ids}",
|
"migrations_already_ran": "Those migrations are already done: {ids}",
|
||||||
"migrations_cant_reach_migration_file": "Could not access migrations files at the path '%s'",
|
"migrations_cant_reach_migration_file": "Could not access migrations files at the path '%s'",
|
||||||
"migrations_dependencies_not_satisfied": "Run these migrations: '{dependencies_id}', before migration {id}.",
|
"migrations_dependencies_not_satisfied": "Run these migrations: '{dependencies_id}', before migration {id}.",
|
||||||
|
|
|
@ -1208,10 +1208,6 @@ def app_ssowatconf():
|
||||||
redirected_regex = {main_domain + '/yunohost[\/]?$': 'https://' + main_domain + '/yunohost/sso/'}
|
redirected_regex = {main_domain + '/yunohost[\/]?$': 'https://' + main_domain + '/yunohost/sso/'}
|
||||||
redirected_urls = {}
|
redirected_urls = {}
|
||||||
|
|
||||||
def _get_setting(settings, name):
|
|
||||||
s = settings.get(name, None)
|
|
||||||
return s.split(',') if s else []
|
|
||||||
|
|
||||||
for app in _installed_apps():
|
for app in _installed_apps():
|
||||||
|
|
||||||
app_settings = read_yaml(APPS_SETTING_PATH + app + '/settings.yml')
|
app_settings = read_yaml(APPS_SETTING_PATH + app + '/settings.yml')
|
||||||
|
|
|
@ -6,8 +6,8 @@ from yunohost.utils.error import YunohostError
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
|
|
||||||
from yunohost.tools import Migration
|
from yunohost.tools import Migration
|
||||||
from yunohost.app import app_setting, app_ssowatconf
|
from yunohost.app import app_setting, app_ssowatconf, _installed_apps
|
||||||
from yunohost.permission import user_permission_list, SYSTEM_PERMS
|
from yunohost.permission import user_permission_list, SYSTEM_PERMS, permission_sync_to_user
|
||||||
|
|
||||||
logger = getActionLogger('yunohost.migration')
|
logger = getActionLogger('yunohost.migration')
|
||||||
|
|
||||||
|
@ -29,10 +29,12 @@ class MyMigration(Migration):
|
||||||
if ldap_regen_conf_status and ldap_regen_conf_status['slapd']['pending']:
|
if ldap_regen_conf_status and ldap_regen_conf_status['slapd']['pending']:
|
||||||
logger.warning(m18n.n("migration_0011_slapd_config_will_be_overwritten", conf_backup_folder=BACKUP_CONF_DIR))
|
logger.warning(m18n.n("migration_0011_slapd_config_will_be_overwritten", conf_backup_folder=BACKUP_CONF_DIR))
|
||||||
|
|
||||||
|
# Update LDAP schema restart slapd
|
||||||
|
logger.info(m18n.n("migration_0011_update_LDAP_schema"))
|
||||||
regen_conf(names=['slapd'], force=True)
|
regen_conf(names=['slapd'], force=True)
|
||||||
|
|
||||||
|
logger.info(m18n.n("migration_0015_add_new_attributes_in_ldap"))
|
||||||
ldap = _get_ldap_interface()
|
ldap = _get_ldap_interface()
|
||||||
|
|
||||||
permission_list = user_permission_list(short=True)["permissions"]
|
permission_list = user_permission_list(short=True)["permissions"]
|
||||||
|
|
||||||
for permission in permission_list:
|
for permission in permission_list:
|
||||||
|
@ -62,18 +64,13 @@ class MyMigration(Migration):
|
||||||
})
|
})
|
||||||
app_setting(permission.split('.')[0], 'label', delete=True)
|
app_setting(permission.split('.')[0], 'label', delete=True)
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
# FIXME : what do we really want to do here ...
|
# FIXME : what do we really want to do here ...
|
||||||
# Imho we should just force-regen the conf in all case, and maybe
|
# Imho we should just force-regen the conf in all case, and maybe
|
||||||
# just display a warning if we detect that the conf was manually modified
|
# just display a warning if we detect that the conf was manually modified
|
||||||
|
|
||||||
# Check if the migration can be processed
|
|
||||||
ldap_regen_conf_status = regen_conf(names=['slapd'], dry_run=True)
|
|
||||||
# By this we check if the have been customized
|
|
||||||
if ldap_regen_conf_status and ldap_regen_conf_status['slapd']['pending']:
|
|
||||||
logger.warning(m18n.n("migration_0011_slapd_config_will_be_overwritten", conf_backup_folder=BACKUP_CONF_DIR))
|
|
||||||
|
|
||||||
# Backup LDAP and the apps settings before to do the migration
|
# Backup LDAP and the apps settings before to do the migration
|
||||||
logger.info(m18n.n("migration_0011_backup_before_migration"))
|
logger.info(m18n.n("migration_0011_backup_before_migration"))
|
||||||
try:
|
try:
|
||||||
|
@ -89,10 +86,6 @@ class MyMigration(Migration):
|
||||||
os.system("systemctl start slapd")
|
os.system("systemctl start slapd")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Update LDAP schema restart slapd
|
|
||||||
logger.info(m18n.n("migration_0011_update_LDAP_schema"))
|
|
||||||
regen_conf(names=['slapd'], force=True)
|
|
||||||
|
|
||||||
# Update LDAP database
|
# Update LDAP database
|
||||||
self.add_new_ldap_attributes()
|
self.add_new_ldap_attributes()
|
||||||
|
|
||||||
|
@ -111,6 +104,3 @@ class MyMigration(Migration):
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
os.system("rm -r " + backup_folder)
|
os.system("rm -r " + backup_folder)
|
||||||
|
|
||||||
logger.info(m18n.n("migration_0011_done"))
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue