domain remove: Improve file/folder cleanup code

This commit is contained in:
Alexandre Aubin 2021-08-28 17:58:58 +02:00
parent 46b51b84f3
commit 808a69ca64

View file

@ -281,13 +281,14 @@ def domain_remove(operation_logger, domain, remove_apps=False, force=False):
except Exception as e: except Exception as e:
raise YunohostError("domain_deletion_failed", domain=domain, error=e) raise YunohostError("domain_deletion_failed", domain=domain, error=e)
os.system("rm -rf /etc/yunohost/certs/%s" % domain) stuff_to_delete = [
f"/etc/yunohost/certs/{domain}",
f"/etc/yunohost/dyndns/K{domain}.+*",
f"{DOMAIN_SETTINGS_DIR}/{domain}.yml",
]
# Delete dyndns keys for this domain (if any) for stuff in stuff_to_delete:
os.system("rm -rf /etc/yunohost/dyndns/K%s.+*" % domain) os.system("rm -rf {stuff}")
# Delete settings file for this domain
os.system(f"rm -rf {DOMAIN_SETTINGS_DIR}/{domain}.yml")
# Sometime we have weird issues with the regenconf where some files # Sometime we have weird issues with the regenconf where some files
# appears as manually modified even though they weren't touched ... # appears as manually modified even though they weren't touched ...