mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[CI] Format code
This commit is contained in:
parent
71293f32a4
commit
a40ecdc986
5 changed files with 102 additions and 33 deletions
|
@ -62,7 +62,12 @@ from yunohost.utils.i18n import _value_for_locale
|
||||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||||
from yunohost.utils.filesystem import free_space_in_directory
|
from yunohost.utils.filesystem import free_space_in_directory
|
||||||
from yunohost.log import is_unit_operation, OperationLogger
|
from yunohost.log import is_unit_operation, OperationLogger
|
||||||
from yunohost.app_catalog import app_catalog, app_search, _load_apps_catalog, app_fetchlist # noqa
|
from yunohost.app_catalog import (
|
||||||
|
app_catalog,
|
||||||
|
app_search,
|
||||||
|
_load_apps_catalog,
|
||||||
|
app_fetchlist,
|
||||||
|
) # noqa
|
||||||
|
|
||||||
logger = getActionLogger("yunohost.app")
|
logger = getActionLogger("yunohost.app")
|
||||||
|
|
||||||
|
@ -393,7 +398,9 @@ def app_change_url(operation_logger, app, domain, path):
|
||||||
|
|
||||||
app_setting_path = os.path.join(APPS_SETTING_PATH, app)
|
app_setting_path = os.path.join(APPS_SETTING_PATH, app)
|
||||||
path_requirement = _guess_webapp_path_requirement(app_setting_path)
|
path_requirement = _guess_webapp_path_requirement(app_setting_path)
|
||||||
_validate_webpath_requirement({"domain": domain, "path": path}, path_requirement, ignore_app=app)
|
_validate_webpath_requirement(
|
||||||
|
{"domain": domain, "path": path}, path_requirement, ignore_app=app
|
||||||
|
)
|
||||||
|
|
||||||
tmp_workdir_for_app = _make_tmp_workdir_for_app(app=app)
|
tmp_workdir_for_app = _make_tmp_workdir_for_app(app=app)
|
||||||
|
|
||||||
|
@ -551,7 +558,9 @@ def app_upgrade(app=[], url=None, file=None, force=False, no_safety_backup=False
|
||||||
app_setting_path = os.path.join(APPS_SETTING_PATH, app_instance_name)
|
app_setting_path = os.path.join(APPS_SETTING_PATH, app_instance_name)
|
||||||
|
|
||||||
# Prepare env. var. to pass to script
|
# Prepare env. var. to pass to script
|
||||||
env_dict = _make_environment_for_app_script(app_instance_name, workdir=extracted_app_folder)
|
env_dict = _make_environment_for_app_script(
|
||||||
|
app_instance_name, workdir=extracted_app_folder
|
||||||
|
)
|
||||||
env_dict["YNH_APP_UPGRADE_TYPE"] = upgrade_type
|
env_dict["YNH_APP_UPGRADE_TYPE"] = upgrade_type
|
||||||
env_dict["YNH_APP_MANIFEST_VERSION"] = str(app_new_version)
|
env_dict["YNH_APP_MANIFEST_VERSION"] = str(app_new_version)
|
||||||
env_dict["YNH_APP_CURRENT_VERSION"] = str(app_current_version)
|
env_dict["YNH_APP_CURRENT_VERSION"] = str(app_current_version)
|
||||||
|
@ -615,7 +624,7 @@ def app_upgrade(app=[], url=None, file=None, force=False, no_safety_backup=False
|
||||||
if upgrade_failed or broke_the_system:
|
if upgrade_failed or broke_the_system:
|
||||||
|
|
||||||
# display this if there are remaining apps
|
# display this if there are remaining apps
|
||||||
if apps[number + 1:]:
|
if apps[number + 1 :]:
|
||||||
not_upgraded_apps = apps[number:]
|
not_upgraded_apps = apps[number:]
|
||||||
logger.error(
|
logger.error(
|
||||||
m18n.n(
|
m18n.n(
|
||||||
|
@ -647,9 +656,13 @@ def app_upgrade(app=[], url=None, file=None, force=False, no_safety_backup=False
|
||||||
# Replace scripts and manifest and conf (if exists)
|
# Replace scripts and manifest and conf (if exists)
|
||||||
# Move scripts and manifest to the right place
|
# Move scripts and manifest to the right place
|
||||||
for file_to_copy in APP_FILES_TO_COPY:
|
for file_to_copy in APP_FILES_TO_COPY:
|
||||||
rm(f'{app_setting_path}/{file_to_copy}', recursive=True, force=True)
|
rm(f"{app_setting_path}/{file_to_copy}", recursive=True, force=True)
|
||||||
if os.path.exists(os.path.join(extracted_app_folder, file_to_copy)):
|
if os.path.exists(os.path.join(extracted_app_folder, file_to_copy)):
|
||||||
cp(f'{extracted_app_folder}/{file_to_copy}', f'{app_setting_path}/{file_to_copy}', recursive=True)
|
cp(
|
||||||
|
f"{extracted_app_folder}/{file_to_copy}",
|
||||||
|
f"{app_setting_path}/{file_to_copy}",
|
||||||
|
recursive=True,
|
||||||
|
)
|
||||||
|
|
||||||
# Clean and set permissions
|
# Clean and set permissions
|
||||||
shutil.rmtree(extracted_app_folder)
|
shutil.rmtree(extracted_app_folder)
|
||||||
|
@ -820,7 +833,11 @@ def app_install(
|
||||||
# Move scripts and manifest to the right place
|
# Move scripts and manifest to the right place
|
||||||
for file_to_copy in APP_FILES_TO_COPY:
|
for file_to_copy in APP_FILES_TO_COPY:
|
||||||
if os.path.exists(os.path.join(extracted_app_folder, file_to_copy)):
|
if os.path.exists(os.path.join(extracted_app_folder, file_to_copy)):
|
||||||
cp(f'{extracted_app_folder}/{file_to_copy}', f'{app_setting_path}/{file_to_copy}', recursive=True)
|
cp(
|
||||||
|
f"{extracted_app_folder}/{file_to_copy}",
|
||||||
|
f"{app_setting_path}/{file_to_copy}",
|
||||||
|
recursive=True,
|
||||||
|
)
|
||||||
|
|
||||||
# Initialize the main permission for the app
|
# Initialize the main permission for the app
|
||||||
# The permission is initialized with no url associated, and with tile disabled
|
# The permission is initialized with no url associated, and with tile disabled
|
||||||
|
@ -835,7 +852,9 @@ def app_install(
|
||||||
)
|
)
|
||||||
|
|
||||||
# Prepare env. var. to pass to script
|
# Prepare env. var. to pass to script
|
||||||
env_dict = _make_environment_for_app_script(app_instance_name, args=args, workdir=extracted_app_folder)
|
env_dict = _make_environment_for_app_script(
|
||||||
|
app_instance_name, args=args, workdir=extracted_app_folder
|
||||||
|
)
|
||||||
|
|
||||||
env_dict_for_logging = env_dict.copy()
|
env_dict_for_logging = env_dict.copy()
|
||||||
for question in questions:
|
for question in questions:
|
||||||
|
@ -896,7 +915,9 @@ def app_install(
|
||||||
logger.warning(m18n.n("app_remove_after_failed_install"))
|
logger.warning(m18n.n("app_remove_after_failed_install"))
|
||||||
|
|
||||||
# Setup environment for remove script
|
# Setup environment for remove script
|
||||||
env_dict_remove = _make_environment_for_app_script(app_instance_name, workdir=extracted_app_folder)
|
env_dict_remove = _make_environment_for_app_script(
|
||||||
|
app_instance_name, workdir=extracted_app_folder
|
||||||
|
)
|
||||||
|
|
||||||
# Execute remove script
|
# Execute remove script
|
||||||
operation_logger_remove = OperationLogger(
|
operation_logger_remove = OperationLogger(
|
||||||
|
@ -1504,7 +1525,9 @@ def app_action_run(operation_logger, app, action, args=None):
|
||||||
|
|
||||||
tmp_workdir_for_app = _make_tmp_workdir_for_app(app=app)
|
tmp_workdir_for_app = _make_tmp_workdir_for_app(app=app)
|
||||||
|
|
||||||
env_dict = _make_environment_for_app_script(app, args=args, args_prefix="ACTION_", workdir=tmp_workdir_for_app)
|
env_dict = _make_environment_for_app_script(
|
||||||
|
app, args=args, args_prefix="ACTION_", workdir=tmp_workdir_for_app
|
||||||
|
)
|
||||||
env_dict["YNH_ACTION"] = action
|
env_dict["YNH_ACTION"] = action
|
||||||
|
|
||||||
_, action_script = tempfile.mkstemp(dir=tmp_workdir_for_app)
|
_, action_script = tempfile.mkstemp(dir=tmp_workdir_for_app)
|
||||||
|
@ -1984,7 +2007,7 @@ def _is_app_repo_url(string: str) -> bool:
|
||||||
string = string.strip()
|
string = string.strip()
|
||||||
|
|
||||||
# Dummy test for ssh-based stuff ... should probably be improved somehow
|
# Dummy test for ssh-based stuff ... should probably be improved somehow
|
||||||
if '@' in string:
|
if "@" in string:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return bool(APP_REPO_URL.match(string))
|
return bool(APP_REPO_URL.match(string))
|
||||||
|
@ -1992,7 +2015,7 @@ def _is_app_repo_url(string: str) -> bool:
|
||||||
|
|
||||||
def _app_quality(src: str) -> str:
|
def _app_quality(src: str) -> str:
|
||||||
"""
|
"""
|
||||||
app may in fact be an app name, an url, or a path
|
app may in fact be an app name, an url, or a path
|
||||||
"""
|
"""
|
||||||
|
|
||||||
raw_app_catalog = _load_apps_catalog()["apps"]
|
raw_app_catalog = _load_apps_catalog()["apps"]
|
||||||
|
@ -2026,13 +2049,15 @@ def _app_quality(src: str) -> str:
|
||||||
return "thirdparty"
|
return "thirdparty"
|
||||||
else:
|
else:
|
||||||
if "http://" in src or "https://" in src:
|
if "http://" in src or "https://" in src:
|
||||||
logger.error(f"{src} is not a valid app url: app url are expected to look like https://domain.tld/path/to/repo_ynh")
|
logger.error(
|
||||||
|
f"{src} is not a valid app url: app url are expected to look like https://domain.tld/path/to/repo_ynh"
|
||||||
|
)
|
||||||
raise YunohostValidationError("app_unknown")
|
raise YunohostValidationError("app_unknown")
|
||||||
|
|
||||||
|
|
||||||
def _extract_app(src: str) -> Tuple[Dict, str]:
|
def _extract_app(src: str) -> Tuple[Dict, str]:
|
||||||
"""
|
"""
|
||||||
src may be an app name, an url, or a path
|
src may be an app name, an url, or a path
|
||||||
"""
|
"""
|
||||||
|
|
||||||
raw_app_catalog = _load_apps_catalog()["apps"]
|
raw_app_catalog = _load_apps_catalog()["apps"]
|
||||||
|
@ -2054,8 +2079,8 @@ def _extract_app(src: str) -> Tuple[Dict, str]:
|
||||||
revision = "HEAD"
|
revision = "HEAD"
|
||||||
# gitlab urls may look like 'https://domain/org/group/repo/-/tree/testing'
|
# gitlab urls may look like 'https://domain/org/group/repo/-/tree/testing'
|
||||||
# compated to github urls looking like 'https://domain/org/repo/tree/testing'
|
# compated to github urls looking like 'https://domain/org/repo/tree/testing'
|
||||||
if '/-/' in url:
|
if "/-/" in url:
|
||||||
url = url.replace('/-/', '/')
|
url = url.replace("/-/", "/")
|
||||||
if "/tree/" in url:
|
if "/tree/" in url:
|
||||||
url, branch = url.split("/tree/", 1)
|
url, branch = url.split("/tree/", 1)
|
||||||
return _extract_app_from_gitrepo(url, branch, revision, {})
|
return _extract_app_from_gitrepo(url, branch, revision, {})
|
||||||
|
@ -2064,7 +2089,9 @@ def _extract_app(src: str) -> Tuple[Dict, str]:
|
||||||
return _extract_app_from_folder(src)
|
return _extract_app_from_folder(src)
|
||||||
else:
|
else:
|
||||||
if "http://" in src or "https://" in src:
|
if "http://" in src or "https://" in src:
|
||||||
logger.error(f"{src} is not a valid app url: app url are expected to look like https://domain.tld/path/to/repo_ynh")
|
logger.error(
|
||||||
|
f"{src} is not a valid app url: app url are expected to look like https://domain.tld/path/to/repo_ynh"
|
||||||
|
)
|
||||||
raise YunohostValidationError("app_unknown")
|
raise YunohostValidationError("app_unknown")
|
||||||
|
|
||||||
|
|
||||||
|
@ -2108,7 +2135,9 @@ def _extract_app_from_folder(path: str) -> Tuple[Dict, str]:
|
||||||
return manifest, extracted_app_folder
|
return manifest, extracted_app_folder
|
||||||
|
|
||||||
|
|
||||||
def _extract_app_from_gitrepo(url: str, branch: str, revision: str, app_info: Dict = {}) -> Tuple[Dict, str]:
|
def _extract_app_from_gitrepo(
|
||||||
|
url: str, branch: str, revision: str, app_info: Dict = {}
|
||||||
|
) -> Tuple[Dict, str]:
|
||||||
|
|
||||||
logger.debug(m18n.n("downloading"))
|
logger.debug(m18n.n("downloading"))
|
||||||
|
|
||||||
|
@ -2237,8 +2266,12 @@ def _guess_webapp_path_requirement(app_folder: str) -> str:
|
||||||
manifest = _get_manifest_of_app(app_folder)
|
manifest = _get_manifest_of_app(app_folder)
|
||||||
raw_questions = manifest.get("arguments", {}).get("install", {})
|
raw_questions = manifest.get("arguments", {}).get("install", {})
|
||||||
|
|
||||||
domain_questions = [question for question in raw_questions if question.get("type") == "domain"]
|
domain_questions = [
|
||||||
path_questions = [question for question in raw_questions if question.get("type") == "path"]
|
question for question in raw_questions if question.get("type") == "domain"
|
||||||
|
]
|
||||||
|
path_questions = [
|
||||||
|
question for question in raw_questions if question.get("type") == "path"
|
||||||
|
]
|
||||||
|
|
||||||
if len(domain_questions) == 0 and len(path_questions) == 0:
|
if len(domain_questions) == 0 and len(path_questions) == 0:
|
||||||
return ""
|
return ""
|
||||||
|
@ -2276,7 +2309,9 @@ def _validate_webpath_requirement(
|
||||||
_assert_no_conflicting_apps(domain, path, ignore_app=ignore_app)
|
_assert_no_conflicting_apps(domain, path, ignore_app=ignore_app)
|
||||||
|
|
||||||
elif path_requirement == "full_domain":
|
elif path_requirement == "full_domain":
|
||||||
_assert_no_conflicting_apps(domain, "/", full_domain=True, ignore_app=ignore_app)
|
_assert_no_conflicting_apps(
|
||||||
|
domain, "/", full_domain=True, ignore_app=ignore_app
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _get_conflicting_apps(domain, path, ignore_app=None):
|
def _get_conflicting_apps(domain, path, ignore_app=None):
|
||||||
|
@ -2341,7 +2376,9 @@ def _assert_no_conflicting_apps(domain, path, ignore_app=None, full_domain=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _make_environment_for_app_script(app, args={}, args_prefix="APP_ARG_", workdir=None):
|
def _make_environment_for_app_script(
|
||||||
|
app, args={}, args_prefix="APP_ARG_", workdir=None
|
||||||
|
):
|
||||||
|
|
||||||
app_setting_path = os.path.join(APPS_SETTING_PATH, app)
|
app_setting_path = os.path.join(APPS_SETTING_PATH, app)
|
||||||
|
|
||||||
|
|
|
@ -1348,7 +1348,11 @@ class RestoreManager:
|
||||||
app_instance_name -- (string) The app name to restore (no app with this
|
app_instance_name -- (string) The app name to restore (no app with this
|
||||||
name should be already install)
|
name should be already install)
|
||||||
"""
|
"""
|
||||||
from yunohost.utils.legacy import _patch_legacy_php_versions, _patch_legacy_php_versions_in_settings, _patch_legacy_helpers
|
from yunohost.utils.legacy import (
|
||||||
|
_patch_legacy_php_versions,
|
||||||
|
_patch_legacy_php_versions_in_settings,
|
||||||
|
_patch_legacy_helpers,
|
||||||
|
)
|
||||||
from yunohost.user import user_group_list
|
from yunohost.user import user_group_list
|
||||||
from yunohost.permission import (
|
from yunohost.permission import (
|
||||||
permission_create,
|
permission_create,
|
||||||
|
@ -1485,7 +1489,9 @@ class RestoreManager:
|
||||||
# Prepare env. var. to pass to script
|
# Prepare env. var. to pass to script
|
||||||
# FIXME : workdir should be a tmp workdir
|
# FIXME : workdir should be a tmp workdir
|
||||||
app_workdir = os.path.join(self.work_dir, "apps", app_instance_name, "settings")
|
app_workdir = os.path.join(self.work_dir, "apps", app_instance_name, "settings")
|
||||||
env_dict = _make_environment_for_app_script(app_instance_name, workdir=app_workdir)
|
env_dict = _make_environment_for_app_script(
|
||||||
|
app_instance_name, workdir=app_workdir
|
||||||
|
)
|
||||||
env_dict.update(
|
env_dict.update(
|
||||||
{
|
{
|
||||||
"YNH_BACKUP_DIR": self.work_dir,
|
"YNH_BACKUP_DIR": self.work_dir,
|
||||||
|
@ -1529,7 +1535,9 @@ class RestoreManager:
|
||||||
remove_script = os.path.join(app_scripts_in_archive, "remove")
|
remove_script = os.path.join(app_scripts_in_archive, "remove")
|
||||||
|
|
||||||
# Setup environment for remove script
|
# Setup environment for remove script
|
||||||
env_dict_remove = _make_environment_for_app_script(app_instance_name, workdir=app_workdir)
|
env_dict_remove = _make_environment_for_app_script(
|
||||||
|
app_instance_name, workdir=app_workdir
|
||||||
|
)
|
||||||
remove_operation_logger = OperationLogger(
|
remove_operation_logger = OperationLogger(
|
||||||
"remove_on_failed_restore",
|
"remove_on_failed_restore",
|
||||||
[("app", app_instance_name)],
|
[("app", app_instance_name)],
|
||||||
|
|
|
@ -32,17 +32,25 @@ def test_repo_url_definition():
|
||||||
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foobar123_ynh")
|
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foobar123_ynh")
|
||||||
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foobar123_ynh/")
|
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foobar123_ynh/")
|
||||||
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foobar123_ynh.git")
|
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foobar123_ynh.git")
|
||||||
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foobar123_ynh/tree/testing")
|
assert _is_app_repo_url(
|
||||||
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foobar123_ynh/tree/testing/")
|
"https://github.com/YunoHost-Apps/foobar123_ynh/tree/testing"
|
||||||
|
)
|
||||||
|
assert _is_app_repo_url(
|
||||||
|
"https://github.com/YunoHost-Apps/foobar123_ynh/tree/testing/"
|
||||||
|
)
|
||||||
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foo-bar-123_ynh")
|
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foo-bar-123_ynh")
|
||||||
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foo_bar_123_ynh")
|
assert _is_app_repo_url("https://github.com/YunoHost-Apps/foo_bar_123_ynh")
|
||||||
assert _is_app_repo_url("https://github.com/YunoHost-Apps/FooBar123_ynh")
|
assert _is_app_repo_url("https://github.com/YunoHost-Apps/FooBar123_ynh")
|
||||||
assert _is_app_repo_url("https://github.com/labriqueinternet/vpnclient_ynh")
|
assert _is_app_repo_url("https://github.com/labriqueinternet/vpnclient_ynh")
|
||||||
assert _is_app_repo_url("https://framagit.org/YunoHost/apps/nodebb_ynh")
|
assert _is_app_repo_url("https://framagit.org/YunoHost/apps/nodebb_ynh")
|
||||||
assert _is_app_repo_url("https://framagit.org/YunoHost/apps/nodebb_ynh/-/tree/testing")
|
assert _is_app_repo_url(
|
||||||
|
"https://framagit.org/YunoHost/apps/nodebb_ynh/-/tree/testing"
|
||||||
|
)
|
||||||
assert _is_app_repo_url("https://gitlab.com/yunohost-apps/foobar_ynh")
|
assert _is_app_repo_url("https://gitlab.com/yunohost-apps/foobar_ynh")
|
||||||
assert _is_app_repo_url("https://code.antopie.org/miraty/qr_ynh")
|
assert _is_app_repo_url("https://code.antopie.org/miraty/qr_ynh")
|
||||||
assert _is_app_repo_url("https://gitlab.domainepublic.net/Neutrinet/neutrinet_ynh/-/tree/unstable")
|
assert _is_app_repo_url(
|
||||||
|
"https://gitlab.domainepublic.net/Neutrinet/neutrinet_ynh/-/tree/unstable"
|
||||||
|
)
|
||||||
assert _is_app_repo_url("git@github.com:YunoHost-Apps/foobar_ynh.git")
|
assert _is_app_repo_url("git@github.com:YunoHost-Apps/foobar_ynh.git")
|
||||||
|
|
||||||
assert not _is_app_repo_url("github.com/YunoHost-Apps/foobar_ynh")
|
assert not _is_app_repo_url("github.com/YunoHost-Apps/foobar_ynh")
|
||||||
|
@ -50,7 +58,9 @@ def test_repo_url_definition():
|
||||||
assert not _is_app_repo_url("https://github.com/YunoHost-Apps/foobar_wat")
|
assert not _is_app_repo_url("https://github.com/YunoHost-Apps/foobar_wat")
|
||||||
assert not _is_app_repo_url("https://github.com/YunoHost-Apps/foobar_ynh_wat")
|
assert not _is_app_repo_url("https://github.com/YunoHost-Apps/foobar_ynh_wat")
|
||||||
assert not _is_app_repo_url("https://github.com/YunoHost-Apps/foobar/tree/testing")
|
assert not _is_app_repo_url("https://github.com/YunoHost-Apps/foobar/tree/testing")
|
||||||
assert not _is_app_repo_url("https://github.com/YunoHost-Apps/foobar_ynh_wat/tree/testing")
|
assert not _is_app_repo_url(
|
||||||
|
"https://github.com/YunoHost-Apps/foobar_ynh_wat/tree/testing"
|
||||||
|
)
|
||||||
assert not _is_app_repo_url("https://framagit.org/YunoHost/apps/")
|
assert not _is_app_repo_url("https://framagit.org/YunoHost/apps/")
|
||||||
assert not _is_app_repo_url("https://framagit.org/YunoHost/apps/pwet")
|
assert not _is_app_repo_url("https://framagit.org/YunoHost/apps/pwet")
|
||||||
assert not _is_app_repo_url("https://framagit.org/YunoHost/apps/pwet_foo")
|
assert not _is_app_repo_url("https://framagit.org/YunoHost/apps/pwet_foo")
|
||||||
|
|
|
@ -1151,7 +1151,11 @@ class Migration(object):
|
||||||
os.system("systemctl stop slapd")
|
os.system("systemctl stop slapd")
|
||||||
cp("/etc/ldap", f"{backup_folder}/ldap_config", recursive=True)
|
cp("/etc/ldap", f"{backup_folder}/ldap_config", recursive=True)
|
||||||
cp("/var/lib/ldap", f"{backup_folder}/ldap_db", recursive=True)
|
cp("/var/lib/ldap", f"{backup_folder}/ldap_db", recursive=True)
|
||||||
cp("/etc/yunohost/apps", f"{backup_folder}/apps_settings", recursive=True)
|
cp(
|
||||||
|
"/etc/yunohost/apps",
|
||||||
|
f"{backup_folder}/apps_settings",
|
||||||
|
recursive=True,
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise YunohostError(
|
raise YunohostError(
|
||||||
"migration_ldap_can_not_backup_before_migration", error=str(e)
|
"migration_ldap_can_not_backup_before_migration", error=str(e)
|
||||||
|
@ -1170,7 +1174,11 @@ class Migration(object):
|
||||||
rm("/etc/ldap/slapd.d", force=True, recursive=True)
|
rm("/etc/ldap/slapd.d", force=True, recursive=True)
|
||||||
cp(f"{backup_folder}/ldap_config", "/etc/ldap", recursive=True)
|
cp(f"{backup_folder}/ldap_config", "/etc/ldap", recursive=True)
|
||||||
cp(f"{backup_folder}/ldap_db", "/var/lib/ldap", recursive=True)
|
cp(f"{backup_folder}/ldap_db", "/var/lib/ldap", recursive=True)
|
||||||
cp(f"{backup_folder}/apps_settings", "/etc/yunohost/apps", recursive=True)
|
cp(
|
||||||
|
f"{backup_folder}/apps_settings",
|
||||||
|
"/etc/yunohost/apps",
|
||||||
|
recursive=True,
|
||||||
|
)
|
||||||
os.system("systemctl start slapd")
|
os.system("systemctl start slapd")
|
||||||
rm(backup_folder, force=True, recursive=True)
|
rm(backup_folder, force=True, recursive=True)
|
||||||
logger.info(m18n.n("migration_ldap_rollback_success"))
|
logger.info(m18n.n("migration_ldap_rollback_success"))
|
||||||
|
|
|
@ -4,7 +4,13 @@ import glob
|
||||||
from moulinette import m18n
|
from moulinette import m18n
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
from moulinette.utils.filesystem import read_file, write_to_file, write_to_json, write_to_yaml, read_yaml
|
from moulinette.utils.filesystem import (
|
||||||
|
read_file,
|
||||||
|
write_to_file,
|
||||||
|
write_to_json,
|
||||||
|
write_to_yaml,
|
||||||
|
read_yaml,
|
||||||
|
)
|
||||||
|
|
||||||
from yunohost.user import user_list
|
from yunohost.user import user_list
|
||||||
from yunohost.app import (
|
from yunohost.app import (
|
||||||
|
|
Loading…
Add table
Reference in a new issue