3 #NederHost_Key="sdfgikogfdfghjklkjhgfcdcfghjk"
5 NederHost_Api
="https://api.nederhost.nl/dns/v1"
7 ######## Public functions #####################
9 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
14 NederHost_Key
="${NederHost_Key:-$(_readaccountconf_mutable NederHost_Key)}"
15 if [ -z "$NederHost_Key" ]; then
17 _err
"You didn't specify a NederHost api key."
18 _err
"You can get yours from https://www.nederhost.nl/mijn_nederhost"
22 #save the api key and email to the account conf file.
23 _saveaccountconf_mutable NederHost_Key
"$NederHost_Key"
25 _debug
"First detect the root zone"
26 if ! _get_root
"$fulldomain"; then
30 _debug _sub_domain
"$_sub_domain"
31 _debug _domain
"$_domain"
34 if _nederhost_rest PATCH
"zones/$_domain/records/$fulldomain/TXT" "[{\"content\":\"$txtvalue\",\"ttl\":60}]"; then
35 if _contains
"$response" "$fulldomain"; then
39 _err
"Add txt record error."
43 _err
"Add txt record error."
53 NederHost_Key
="${NederHost_Key:-$(_readaccountconf_mutable NederHost_Key)}"
54 if [ -z "$NederHost_Key" ]; then
56 _err
"You didn't specify a NederHost api key."
57 _err
"You can get yours from https://www.nederhost.nl/mijn_nederhost"
61 _debug
"First detect the root zone"
62 if ! _get_root
"$fulldomain"; then
67 _debug _sub_domain
"$_sub_domain"
68 _debug _domain
"$_domain"
70 _debug
"Removing txt record"
71 _nederhost_rest DELETE
"zones/${_domain}/records/$fulldomain/TXT?content=$txtvalue"
75 #################### Private functions below ##################################
76 #_acme-challenge.www.domain.com
78 # _sub_domain=_acme-challenge.www
85 _domain
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
86 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
87 _debug _domain
"$_domain"
88 if [ -z "$_domain" ]; then
93 if _nederhost_rest GET
"zones/${_domain}"; then
94 if [ "${_code}" = "204" ]; then
112 export _H1
="Authorization: Bearer $NederHost_Key"
113 export _H2
="Content-Type: application/json"
115 if [ "$m" != "GET" ]; then
117 response
="$(_post "$data" "$NederHost_Api/$ep" "" "$m")"
119 response
="$(_get "$NederHost_Api/$ep")"
122 _code
="$(grep "^HTTP
" "$HTTP_HEADER" | _tail_n 1 | cut -d " " -f 2 | tr -d "\\r
\\n
")"
123 _debug
"http response code $_code"
125 if [ "$?" != "0" ]; then
129 _debug2 response
"$response"