mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
settings migration wip
This commit is contained in:
parent
6428417aa0
commit
f3349d4b3d
1 changed files with 32 additions and 0 deletions
32
src/migrations/0024_global_settings_to_configpanel.py
Normal file
32
src/migrations/0024_global_settings_to_configpanel.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import subprocess
|
||||
import time
|
||||
|
||||
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"
|
||||
|
||||
class MyMigration(Migration):
|
||||
|
||||
"Migrate old global settings to the new ConfigPanel global settings"
|
||||
|
||||
dependencies = ["migrate_to_bullseye"]
|
||||
|
||||
def run(self):
|
||||
if not os.path.exists(SETTINGS_PATH):
|
||||
return
|
||||
|
||||
try:
|
||||
old_settings = json.load(open(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)
|
Loading…
Add table
Reference in a new issue