123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- #!/usr/bin/env sh
- DDNSS_DNS_API="https://ddnss.de/upd.php"
- dns_ddnss_add() {
- fulldomain=$1
- txtvalue=$2
- DDNSS_Token="${DDNSS_Token:-$(_readaccountconf_mutable DDNSS_Token)}"
- if [ -z "$DDNSS_Token" ]; then
- _err "You must export variable: DDNSS_Token"
- _err "The token for your DDNSS account is necessary."
- _err "You can look it up in your DDNSS account."
- return 1
- fi
-
- _saveaccountconf_mutable DDNSS_Token "$DDNSS_Token"
-
-
-
- if ! _ddnss_get_domain; then
- return 1
- fi
-
- _info "Trying to add TXT record"
- if _ddnss_rest GET "key=$DDNSS_Token&host=$_ddnss_domain&txtm=1&txt=$txtvalue"; then
- if [ "$response" = "Updated 1 hostname." ]; then
- _info "TXT record has been successfully added to your DDNSS domain."
- _info "Note that all subdomains under this domain uses the same TXT record."
- return 0
- else
- _err "Errors happened during adding the TXT record, response=$response"
- return 1
- fi
- else
- _err "Errors happened during adding the TXT record."
- return 1
- fi
- }
- dns_ddnss_rm() {
- fulldomain=$1
- txtvalue=$2
- DDNSS_Token="${DDNSS_Token:-$(_readaccountconf_mutable DDNSS_Token)}"
- if [ -z "$DDNSS_Token" ]; then
- _err "You must export variable: DDNSS_Token"
- _err "The token for your DDNSS account is necessary."
- _err "You can look it up in your DDNSS account."
- return 1
- fi
- if ! _ddnss_get_domain; then
- return 1
- fi
-
- _info "Trying to remove TXT record"
- if _ddnss_rest GET "key=$DDNSS_Token&host=$_ddnss_domain&txtm=1&txt=."; then
- if [ "$response" = "Updated 1 hostname." ]; then
- _info "TXT record has been successfully removed from your DDNSS domain."
- return 0
- else
- _err "Errors happened during removing the TXT record, response=$response"
- return 1
- fi
- else
- _err "Errors happened during removing the TXT record."
- return 1
- fi
- }
- _ddnss_get_domain() {
-
- _ddnss_domain="$(echo "$fulldomain" | _lower_case | _egrep_o '[.][^.][^.]*[.](ddnss|dyn-ip24|dyndns|dyn|dyndns1|home-webserver|myhome-server|dynip)\..*' | cut -d . -f 2-)"
- if [ -z "$_ddnss_domain" ]; then
- _err "Error extracting the domain."
- return 1
- fi
- return 0
- }
- _ddnss_rest() {
- method=$1
- param="$2"
- _debug param "$param"
- url="$DDNSS_DNS_API?$param"
- _debug url "$url"
-
- if [ "$method" = "GET" ]; then
- response="$(_get "$url" | sed 's/<[a-zA-Z\/][^>]*>//g' | _tail_n 1)"
- else
- _err "Unsupported method"
- return 1
- fi
- _debug2 response "$response"
- return 0
- }
|