Added yunohost domain dyndns list command

This commit is contained in:
theo@manjaro 2022-07-05 11:30:40 +02:00
parent cf6eaf364d
commit e4c631c171
3 changed files with 24 additions and 0 deletions

View file

@ -620,6 +620,10 @@ domain:
extra:
pattern: *pattern_password
### domain_dyndns_list()
list:
action_help: List all subscribed DynDNS domains
config:
subcategory_help: Domain settings
actions:

View file

@ -377,6 +377,14 @@ def domain_dyndns_unsubscribe(**kwargs):
dyndns_unsubscribe(**kwargs)
def domain_dyndns_list():
"""
Returns all currently subscribed DynDNS domains
"""
from yunohost.dyndns import dyndns_list
return dyndns_list()
def domain_dyndns_update(**kwargs):
"""
Update a DynDNS domain

View file

@ -236,6 +236,18 @@ def dyndns_unsubscribe(operation_logger, domain, password=None):
elif r.status_code == 404: # Invalid domain
raise YunohostError("dyndns_unsubscribe_wrong_domain")
def dyndns_list():
"""
Returns all currently subscribed DynDNS domains ( deduced from the key files )
"""
files = glob.glob("/etc/yunohost/dyndns/K*key")
# Get the domain names
for i in range(len(files)):
files[i] = files[i].split(".+",1)[0]
files[i] = files[i].split("/etc/yunohost/dyndns/K")[1]
return {"domains":files}
@is_unit_operation()
def dyndns_update(