From 97c2cdc593966b554ad792fd54d33af6be3d84dd Mon Sep 17 00:00:00 2001 From: axolotle Date: Mon, 25 Sep 2023 13:55:01 +0200 Subject: [PATCH] domain: move domain files removal so dyndns API key still exists while trying to unsubscribe --- src/domain.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/domain.py b/src/domain.py index 8fc9799cd..40e8b50d0 100644 --- a/src/domain.py +++ b/src/domain.py @@ -342,6 +342,7 @@ def domain_remove( dyndns_recovery_password -- Recovery password used at the creation of the DynDNS domain ignore_dyndns -- If we just remove the DynDNS domain, without unsubscribing """ + import glob from yunohost.hook import hook_callback from yunohost.app import app_ssowatconf, app_info, app_remove from yunohost.utils.ldap import _get_ldap_interface @@ -427,15 +428,6 @@ def domain_remove( global domain_list_cache domain_list_cache = [] - stuff_to_delete = [ - f"/etc/yunohost/certs/{domain}", - f"/etc/yunohost/dyndns/K{domain}.+*", - f"{DOMAIN_SETTINGS_DIR}/{domain}.yml", - ] - - for stuff in stuff_to_delete: - rm(stuff, force=True, recursive=True) - # Sometime we have weird issues with the regenconf where some files # appears as manually modified even though they weren't touched ... # There are a few ideas why this happens (like backup/restore nginx @@ -469,6 +461,11 @@ def domain_remove( domain=domain, recovery_password=dyndns_recovery_password ) + rm(f"/etc/yunohost/certs/{domain}", force=True, recursive=True) + for key_file in glob.glob(f"/etc/yunohost/dyndns/K{domain}.+*"): + rm(key_file, force=True) + rm(f"{DOMAIN_SETTINGS_DIR}/{domain}.yml", force=True) + logger.success(m18n.n("domain_deleted"))