From 0f109db6cadfa8bf29d45bfd76278197cf4a37e2 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 28 Sep 2023 14:29:53 +0200 Subject: [PATCH] dyndns/domain_remove: be paranoid and keep the dyndns unsubscribe + cert/dyndns/setting cleanup before the regenconf --- src/domain.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/domain.py b/src/domain.py index a503a129c..79194df2d 100644 --- a/src/domain.py +++ b/src/domain.py @@ -428,6 +428,21 @@ def domain_remove( global domain_list_cache domain_list_cache = [] + # If a password is provided, delete the DynDNS record + if dyndns: + try: + # Actually unsubscribe + domain_dyndns_unsubscribe( + domain=domain, recovery_password=dyndns_recovery_password + ) + except Exception as e: + logger.warning(str(e)) + + 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) + # 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 @@ -454,21 +469,6 @@ def domain_remove( hook_callback("post_domain_remove", args=[domain]) - # If a password is provided, delete the DynDNS record - if dyndns: - try: - # Actually unsubscribe - domain_dyndns_unsubscribe( - domain=domain, recovery_password=dyndns_recovery_password - ) - except Exception as e: - logger.warning(str(e)) - - 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"))