mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
yunohost domain remove
auto-detects DynDNS domains
and now uses --unsubscribe and --no-unsubscribe
This commit is contained in:
parent
986b42fc1d
commit
840bed5222
2 changed files with 24 additions and 9 deletions
|
@ -484,11 +484,16 @@ domain:
|
||||||
full: --force
|
full: --force
|
||||||
help: Do not ask confirmation to remove apps
|
help: Do not ask confirmation to remove apps
|
||||||
action: store_true
|
action: store_true
|
||||||
-p:
|
-n:
|
||||||
full: --password
|
full: --no-unsubscribe
|
||||||
|
help: If removing a DynDNS domain, only remove the domain, without unsubscribing from the DynDNS service
|
||||||
|
action: store_true
|
||||||
|
-u:
|
||||||
|
full: --unsubscribe
|
||||||
|
metavar: PASSWORD
|
||||||
nargs: "?"
|
nargs: "?"
|
||||||
const: 0
|
const: 0
|
||||||
help: Password used to delete the domain from DynDNS
|
help: If removing a DynDNS domain, unsubscribe from the DynDNS service with a password
|
||||||
extra:
|
extra:
|
||||||
pattern: *pattern_password
|
pattern: *pattern_password
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,8 @@ def domain_add(operation_logger, domain, subscribe=None, no_subscribe=False):
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
domain -- Domain name to add
|
domain -- Domain name to add
|
||||||
dyndns -- Subscribe to DynDNS
|
dyndns -- Subscribe to DynDNS
|
||||||
password -- Password used to later unsubscribe from DynDNS
|
subscribe -- Password used to later unsubscribe from DynDNS
|
||||||
|
no_unsubscribe -- If we want to just add the DynDNS domain to the list, without subscribing
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_callback
|
from yunohost.hook import hook_callback
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
|
@ -166,7 +167,6 @@ def domain_add(operation_logger, domain, subscribe=None, no_subscribe=False):
|
||||||
# DynDNS domain
|
# DynDNS domain
|
||||||
dyndns = is_yunohost_dyndns_domain(domain)
|
dyndns = is_yunohost_dyndns_domain(domain)
|
||||||
if dyndns:
|
if dyndns:
|
||||||
print(subscribe,no_subscribe)
|
|
||||||
if ((subscribe==None) == (no_subscribe==False)):
|
if ((subscribe==None) == (no_subscribe==False)):
|
||||||
raise YunohostValidationError("domain_dyndns_instruction_unclear")
|
raise YunohostValidationError("domain_dyndns_instruction_unclear")
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ def domain_add(operation_logger, domain, subscribe=None, no_subscribe=False):
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation()
|
||||||
def domain_remove(operation_logger, domain, remove_apps=False, force=False, password=None):
|
def domain_remove(operation_logger, domain, remove_apps=False, force=False, unsubscribe=None,no_unsubscribe=False):
|
||||||
"""
|
"""
|
||||||
Delete domains
|
Delete domains
|
||||||
|
|
||||||
|
@ -247,7 +247,8 @@ def domain_remove(operation_logger, domain, remove_apps=False, force=False, pass
|
||||||
remove_apps -- Remove applications installed on the domain
|
remove_apps -- Remove applications installed on the domain
|
||||||
force -- Force the domain removal and don't not ask confirmation to
|
force -- Force the domain removal and don't not ask confirmation to
|
||||||
remove apps if remove_apps is specified
|
remove apps if remove_apps is specified
|
||||||
password -- Recovery password used at the creation of the DynDNS domain
|
unsubscribe -- Recovery password used at the creation of the DynDNS domain
|
||||||
|
no_unsubscribe -- If we just remove the DynDNS domain, without unsubscribing
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_callback
|
from yunohost.hook import hook_callback
|
||||||
from yunohost.app import app_ssowatconf, app_info, app_remove
|
from yunohost.app import app_ssowatconf, app_info, app_remove
|
||||||
|
@ -312,9 +313,18 @@ def domain_remove(operation_logger, domain, remove_apps=False, force=False, pass
|
||||||
"domain_uninstall_app_first",
|
"domain_uninstall_app_first",
|
||||||
apps="\n".join([x[1] for x in apps_on_that_domain]),
|
apps="\n".join([x[1] for x in apps_on_that_domain]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# DynDNS domain
|
||||||
|
dyndns = is_yunohost_dyndns_domain(domain)
|
||||||
|
if dyndns:
|
||||||
|
if ((unsubscribe==None) == (no_unsubscribe==False)):
|
||||||
|
raise YunohostValidationError("domain_dyndns_instruction_unclear")
|
||||||
|
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
|
|
||||||
|
if not dyndns and (unsubscribe!=None or no_unsubscribe!=False):
|
||||||
|
logger.warning("This domain is not a DynDNS one, no need for the --unsubscribe or --no-unsubscribe option")
|
||||||
|
|
||||||
ldap = _get_ldap_interface()
|
ldap = _get_ldap_interface()
|
||||||
try:
|
try:
|
||||||
ldap.remove("virtualdomain=" + domain + ",ou=domains")
|
ldap.remove("virtualdomain=" + domain + ",ou=domains")
|
||||||
|
@ -360,9 +370,9 @@ def domain_remove(operation_logger, domain, remove_apps=False, force=False, pass
|
||||||
hook_callback("post_domain_remove", args=[domain])
|
hook_callback("post_domain_remove", args=[domain])
|
||||||
|
|
||||||
# If a password is provided, delete the DynDNS record
|
# If a password is provided, delete the DynDNS record
|
||||||
if password!=None:
|
if dyndns and not no_unsubscribe:
|
||||||
# Actually unsubscribe
|
# Actually unsubscribe
|
||||||
domain_dyndns_unsubscribe(domain=domain,password=password)
|
domain_dyndns_unsubscribe(domain=domain,password=unsubscribe)
|
||||||
|
|
||||||
logger.success(m18n.n("domain_deleted"))
|
logger.success(m18n.n("domain_deleted"))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue