3 #ACTIVE24_Token="sdfsdfsdfljlbjkljlkjsdfoiwje"
5 ACTIVE24_Api
="https://api.active24.com"
7 ######## Public functions #####################
9 # Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
10 # Used to add txt record
17 _info
"Adding txt record"
18 if _active24_rest POST
"dns/$_domain/txt/v1" "{\"name\":\"$_sub_domain\",\"text\":\"$txtvalue\",\"ttl\":0}"; then
19 if _contains
"$response" "errors"; then
20 _err
"Add txt record error."
27 _err
"Add txt record error."
31 # Usage: fulldomain txtvalue
32 # Used to remove the txt record after validation
39 _debug
"Getting txt records"
40 _active24_rest GET
"dns/$_domain/records/v1"
42 if _contains
"$response" "errors"; then
47 hash_ids
=$
(echo "$response" | _egrep_o
"[^{]+${txtvalue}[^}]+" | _egrep_o
"hashId\":\"[^\"]+" | cut
-c10-)
49 for hash_id
in $hash_ids; do
50 _debug
"Removing hash_id" "$hash_id"
51 if _active24_rest DELETE
"dns/$_domain/$hash_id/v1" ""; then
52 if _contains
"$response" "errors"; then
53 _err
"Unable to remove txt record."
56 _info
"Removed txt record."
62 _err
"No txt records found."
66 #################### Private functions below ##################################
67 #_acme-challenge.www.domain.com
69 # _sub_domain=_acme-challenge.www
71 # _domain_id=sdjkglgdfewsdfg
75 if ! _active24_rest GET
"dns/domains/v1"; then
82 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
89 if _contains
"$response" "\"$h\"" >/dev
/null
; then
90 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
106 export _H1
="Authorization: Bearer $ACTIVE24_Token"
108 if [ "$m" != "GET" ]; then
109 _debug
"data" "$data"
110 response
="$(_post "$data" "$ACTIVE24_Api/$ep" "" "$m" "application
/json
")"
112 response
="$(_get "$ACTIVE24_Api/$ep")"
115 if [ "$?" != "0" ]; then
119 _debug2 response
"$response"
124 ACTIVE24_Token
="${ACTIVE24_Token:-$(_readaccountconf_mutable ACTIVE24_Token)}"
125 if [ -z "$ACTIVE24_Token" ]; then
127 _err
"You didn't specify a Active24 api token yet."
128 _err
"Please create the token and try again."
132 _saveaccountconf_mutable ACTIVE24_Token
"$ACTIVE24_Token"
134 _debug
"First detect the root zone"
135 if ! _get_root
"$fulldomain"; then
136 _err
"invalid domain"
139 _debug _sub_domain
"$_sub_domain"
140 _debug _domain
"$_domain"