3 Zilore_API
="https://api.zilore.com/dns/v1"
4 # Zilore_Key="YOUR-ZILORE-API-KEY"
6 ######## Public functions #####################
13 _debug fulldomain
"$fulldomain"
14 _debug txtvalue
"$txtvalue"
16 Zilore_Key
="${Zilore_Key:-$(_readaccountconf_mutable Zilore_Key)}"
17 if [ -z "$Zilore_Key" ]; then
19 _err
"Please define Zilore API key"
22 _saveaccountconf_mutable Zilore_Key
"$Zilore_Key"
24 if ! _get_root
"$fulldomain"; then
25 _err
"Unable to determine root domain"
28 _debug _domain
"$_domain"
31 if _zilore_rest POST
"domains/$_domain/records?record_type=TXT&record_ttl=600&record_name=$fulldomain&record_value=\"$txtvalue\""; then
32 if _contains
"$response" '"added"' >/dev
/null
; then
33 _info
"Added TXT record, waiting for validation"
36 _debug response
"$response"
37 _err
"Error while adding DNS records"
50 _debug fulldomain
"$fulldomain"
51 _debug txtvalue
"$txtvalue"
53 Zilore_Key
="${Zilore_Key:-$(_readaccountconf_mutable Zilore_Key)}"
54 if [ -z "$Zilore_Key" ]; then
56 _err
"Please define Zilore API key"
59 _saveaccountconf_mutable Zilore_Key
"$Zilore_Key"
61 if ! _get_root
"$fulldomain"; then
62 _err
"Unable to determine root domain"
65 _debug _domain
"$_domain"
68 _debug
"Getting TXT records"
69 _zilore_rest GET
"domains/${_domain}/records?search_text=$txtvalue&search_record_type=TXT"
70 _debug response
"$response"
72 if ! _contains
"$response" '"ok"' >/dev
/null
; then
73 _err
"Error while getting records list"
76 _record_id
=$
(printf "%s\n" "$response" | _egrep_o
"\"record_id\":\"[^\"]+\"" | cut
-d : -f 2 |
tr -d \" | _head_n
1)
77 if [ -z "$_record_id" ]; then
78 _err
"Cannot determine _record_id"
81 _debug _record_id
"$_record_id"
83 if ! _zilore_rest DELETE
"domains/${_domain}/records?record_id=$_record_id"; then
84 _err
"Error while deleting chosen record"
87 _contains
"$response" '"ok"'
91 #################### Private functions below ##################################
97 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
104 if ! _zilore_rest GET
"domains?search_text=$h"; then
108 if _contains
"$response" "\"$h\"" >/dev
/null
; then
112 _debug
"$h not found"
124 export _H1
="X-Auth-Key: $Zilore_Key"
126 if [ "$method" != "GET" ]; then
127 response
="$(_post "$data" "$Zilore_API/$param" "" "$method")"
129 response
="$(_get "$Zilore_API/$param")"
132 if [ "$?" != "0" ]; then
137 _debug2 response
"$response"