3 # united-domains Reselling (https://www.ud-reselling.com/) DNS API
4 # Author: Andreas Scherer (https://github.com/andischerer)
7 # Set the environment variables as below:
9 # export UDR_USER="your_username_goes_here"
10 # export UDR_PASS="some_password_goes_here"
13 UDR_API
="https://api.domainreselling.de/api/call.cgi"
16 ######## Public functions #####################
18 #Usage: add _acme-challenge.www.domain.com "some_long_string_of_characters_go_here_from_lets_encrypt"
23 UDR_USER
="${UDR_USER:-$(_readaccountconf_mutable UDR_USER)}"
24 UDR_PASS
="${UDR_PASS:-$(_readaccountconf_mutable UDR_PASS)}"
25 if [ -z "$UDR_USER" ] ||
[ -z "$UDR_PASS" ]; then
28 _err
"You didn't specify an UD-Reselling username and password yet"
31 # save the username and password to the account conf file.
32 _saveaccountconf_mutable UDR_USER
"$UDR_USER"
33 _saveaccountconf_mutable UDR_PASS
"$UDR_PASS"
34 _debug
"First detect the root zone"
35 if ! _get_root
"$fulldomain"; then
40 _debug _dnszone
"${_dnszone}"
42 _debug
"Getting txt records"
43 if ! _udr_rest
"QueryDNSZoneRRList" "dnszone=${_dnszone}"; then
47 rr
="${fulldomain}. ${UDR_TTL} IN TXT ${txtvalue}"
48 _debug resource_record
"${rr}"
49 if _contains
"$response" "$rr" >/dev
/null
; then
50 _err
"Error, it would appear that this record already exists. Please review existing TXT records for this domain."
55 if ! _udr_rest
"UpdateDNSZone" "dnszone=${_dnszone}&addrr0=${rr}"; then
56 _err
"Adding the record did not succeed, please verify/check."
68 UDR_USER
="${UDR_USER:-$(_readaccountconf_mutable UDR_USER)}"
69 UDR_PASS
="${UDR_PASS:-$(_readaccountconf_mutable UDR_PASS)}"
70 if [ -z "$UDR_USER" ] ||
[ -z "$UDR_PASS" ]; then
73 _err
"You didn't specify an UD-Reselling username and password yet"
77 _debug
"First detect the root zone"
78 if ! _get_root
"$fulldomain"; then
82 _debug _dnszone
"${_dnszone}"
84 _debug
"Getting txt records"
85 if ! _udr_rest
"QueryDNSZoneRRList" "dnszone=${_dnszone}"; then
89 rr
="${fulldomain}. ${UDR_TTL} IN TXT ${txtvalue}"
90 _debug resource_record
"${rr}"
91 if _contains
"$response" "$rr" >/dev
/null
; then
92 if ! _udr_rest
"UpdateDNSZone" "dnszone=${_dnszone}&delrr0=${rr}"; then
93 _err
"Deleting the record did not succeed, please verify/check."
99 _info
"Text record is not present, will not delete anything."
104 #################### Private functions below ##################################
105 #_acme-challenge.www.domain.com
107 # _sub_domain=_acme-challenge.www
113 if ! _udr_rest
"QueryDNSZoneList" ""; then
118 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
126 if _contains
"${response}" "${h}." >/dev
/null
; then
127 _dnszone
=$
(echo "$response" | _egrep_o
"${h}")
128 if [ "$_dnszone" ]; then
145 _debug data
"${data}"
146 response
="$(_post "${data}" "${UDR_API}?s_login=${UDR_USER}&s_pw=${UDR_PASS}" "" "POST
")"
148 _code
=$
(echo "$response" | _egrep_o
"code = ([0-9]+)" | _head_n
1 | cut
-d = -f 2 |
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
149 _description
=$
(echo "$response" | _egrep_o
"description = .*" | _head_n
1 | cut
-d = -f 2 |
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
151 _debug response_code
"$_code"
152 _debug response_description
"$_description"
154 if [ ! "$_code" = "200" ]; then
155 _err
"DNS-API-Error: $_description"