mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
settings migration
This commit is contained in:
parent
f3349d4b3d
commit
2156fb402b
2 changed files with 11 additions and 9 deletions
|
@ -485,8 +485,8 @@
|
|||
"log_user_permission_reset": "Reset permission '{}'",
|
||||
"log_user_permission_update": "Update accesses for permission '{}'",
|
||||
"log_user_update": "Update info for user '{}'",
|
||||
"log_settings_set": "Apply setting '{}'",
|
||||
"log_settings_reset": "Reset setting '{}'",
|
||||
"log_settings_set": "Apply settings",
|
||||
"log_settings_reset": "Reset setting",
|
||||
"log_settings_reset_all": "Reset all setting",
|
||||
"mail_alias_remove_failed": "Could not remove e-mail alias '{mail}'",
|
||||
"mail_domain_unknown": "Invalid e-mail address for domain '{domain}'. Please, use a domain administrated by this server.",
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import subprocess
|
||||
import time
|
||||
import urllib
|
||||
|
||||
from yunohost.utils.error import YunohostError
|
||||
from moulinette.utils.log import getActionLogger
|
||||
|
||||
from yunohost.tools import Migration
|
||||
from yunohost.utils.legacy import LEGACY_SETTINGS, translate_legacy_settings_to_configpanel_settings
|
||||
from yunohost.settings import settings_set
|
||||
|
||||
logger = getActionLogger("yunohost.migration")
|
||||
|
||||
SETTINGS_PATH = "/etc/yunohost/settings.json"
|
||||
OLD_SETTINGS_PATH = "/etc/yunohost/settings.json"
|
||||
|
||||
class MyMigration(Migration):
|
||||
|
||||
|
@ -19,14 +19,16 @@ class MyMigration(Migration):
|
|||
dependencies = ["migrate_to_bullseye"]
|
||||
|
||||
def run(self):
|
||||
if not os.path.exists(SETTINGS_PATH):
|
||||
if not os.path.exists(OLD_SETTINGS_PATH):
|
||||
return
|
||||
|
||||
try:
|
||||
old_settings = json.load(open(SETTINGS_PATH))
|
||||
old_settings = json.load(open(OLD_SETTINGS_PATH))
|
||||
except Exception as e:
|
||||
raise YunohostError("global_settings_cant_open_settings", reason=e)
|
||||
|
||||
for key, value in old_settings.items():
|
||||
if key in LEGACY_SETTINGS:
|
||||
settings_set(key=key, value=value)
|
||||
settings = { k: v['values'] for k,v in old_settings.items() }
|
||||
|
||||
args = urllib.parse.urlencode(settings)
|
||||
settings_set(args=args)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue