3 #Created by RaidenII, to use DuckDNS's API to add/remove text records
4 #modified by helbgd @ 03/13/2018 to support ddnss.de
5 #modified by mod242 @ 04/24/2018 to support different ddnss domains
6 #Please note: the Wildcard Feature must be turned on for the Host record
7 #and the checkbox for TXT needs to be enabled
9 # Pass credentials before "acme.sh --issue --dns dns_ddnss ..."
11 # export DDNSS_Token="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
15 DDNSS_DNS_API
="https://ddnss.de/upd.php"
17 ######## Public functions #####################
19 #Usage: dns_ddnss_add _acme-challenge.domain.ddnss.de "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
24 DDNSS_Token
="${DDNSS_Token:-$(_readaccountconf_mutable DDNSS_Token)}"
25 if [ -z "$DDNSS_Token" ]; then
26 _err
"You must export variable: DDNSS_Token"
27 _err
"The token for your DDNSS account is necessary."
28 _err
"You can look it up in your DDNSS account."
32 # Now save the credentials.
33 _saveaccountconf_mutable DDNSS_Token
"$DDNSS_Token"
35 # Unfortunately, DDNSS does not seems to support lookup domain through API
36 # So I assume your credentials (which are your domain and token) are correct
37 # If something goes wrong, we will get a KO response from DDNSS
39 if ! _ddnss_get_domain
; then
43 # Now add the TXT record to DDNSS DNS
44 _info
"Trying to add TXT record"
45 if _ddnss_rest GET
"key=$DDNSS_Token&host=$_ddnss_domain&txtm=1&txt=$txtvalue"; then
46 if [ "$response" = "Updated 1 hostname." ]; then
47 _info
"TXT record has been successfully added to your DDNSS domain."
48 _info
"Note that all subdomains under this domain uses the same TXT record."
51 _err
"Errors happened during adding the TXT record, response=$response"
55 _err
"Errors happened during adding the TXT record."
60 #Usage: fulldomain txtvalue
61 #Remove the txt record after validation.
66 DDNSS_Token
="${DDNSS_Token:-$(_readaccountconf_mutable DDNSS_Token)}"
67 if [ -z "$DDNSS_Token" ]; then
68 _err
"You must export variable: DDNSS_Token"
69 _err
"The token for your DDNSS account is necessary."
70 _err
"You can look it up in your DDNSS account."
74 if ! _ddnss_get_domain
; then
78 # Now remove the TXT record from DDNS DNS
79 _info
"Trying to remove TXT record"
80 if _ddnss_rest GET
"key=$DDNSS_Token&host=$_ddnss_domain&txtm=2"; then
81 if [ "$response" = "Updated 1 hostname." ]; then
82 _info
"TXT record has been successfully removed from your DDNSS domain."
85 _err
"Errors happened during removing the TXT record, response=$response"
89 _err
"Errors happened during removing the TXT record."
94 #################### Private functions below ##################################
96 #fulldomain=_acme-challenge.domain.ddnss.de
98 # _ddnss_domain=domain
101 # We'll extract the domain/username from full domain
102 _ddnss_domain
="$(echo "$fulldomain" | _lower_case | _egrep_o '[.][^.][^.]*[.](ddnss|dyn-ip24|dyndns|dyn|dyndns1|home-webserver|myhome-server|dynip)\..*' | cut -d . -f 2-)"
104 if [ -z "$_ddnss_domain" ]; then
105 _err
"Error extracting the domain."
116 _debug param
"$param"
117 url
="$DDNSS_DNS_API?$param"
120 # DDNSS uses GET to update domain info
121 if [ "$method" = "GET" ]; then
122 response
="$(_get "$url" | sed 's/<[a-zA-Z\/][^>]*>//g' | tr -s "\n" | _tail_n 1)"
124 _err
"Unsupported method"
128 _debug2 response
"$response"