dyndns: add postinstall recovery password handling

This commit is contained in:
axolotle 2023-09-24 18:11:28 +02:00
parent 67e28567ff
commit 65843bda6d

View file

@ -157,7 +157,7 @@ def tools_postinstall(
overwrite_root_password=True, overwrite_root_password=True,
): ):
from yunohost.dyndns import _dyndns_available from yunohost.dyndns import _dyndns_available
from yunohost.utils.dns import is_yunohost_dyndns_domain from yunohost.utils.dns import is_yunohost_dyndns_domain, dyndns_unsubscribe
from yunohost.utils.password import ( from yunohost.utils.password import (
assert_password_is_strong_enough, assert_password_is_strong_enough,
assert_password_is_compatible, assert_password_is_compatible,
@ -218,6 +218,13 @@ def tools_postinstall(
) )
else: else:
if not available: if not available:
if dyndns_recovery_password:
# Try to unsubscribe the domain so it can be subscribed again
# If successful, it will be resubscribed with the same recovery password
dyndns_unsubscribe(
domain=domain, recovery_password=dyndns_recovery_password
)
else:
raise YunohostValidationError("dyndns_unavailable", domain=domain) raise YunohostValidationError("dyndns_unavailable", domain=domain)
if os.system("iptables -V >/dev/null 2>/dev/null") != 0: if os.system("iptables -V >/dev/null 2>/dev/null") != 0: