4 #ZM_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
6 #https://zonomi.com dns api
8 ZM_Api
="https://zonomi.com/app/dns/dyndns.jsp"
10 ######## Public functions #####################
12 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
17 ZM_Key
="${ZM_Key:-$(_readaccountconf_mutable ZM_Key)}"
19 if [ -z "$ZM_Key" ]; then
21 _err
"You don't specify zonomi api key yet."
22 _err
"Please create your key and try again."
26 #save the api key to the account conf file.
27 _saveaccountconf_mutable ZM_Key
"$ZM_Key"
29 _info
"Get existing txt records for $fulldomain"
30 if ! _zm_request
"action=QUERY&name=$fulldomain"; then
35 if _contains
"$response" "<record"; then
36 _debug
"get and update records"
37 _qstr
="action[1]=SET&type[1]=TXT&name[1]=$fulldomain&value[1]=$txtvalue"
39 for t
in $
(echo "$response" |
tr -d "\r\n" | _egrep_o
'<action.*</action>' |
tr "<" "\n" |
grep record |
grep 'type="TXT"' | cut
-d '"' -f 6); do
41 _qstr
="$_qstr&action[$_qindex]=SET&type[$_qindex]=TXT&name[$_qindex]=$fulldomain&value[$_qindex]=$t"
42 _qindex
="$(_math "$_qindex" + 1)"
46 _debug
"Just add record"
47 _zm_request
"action=SET&type=TXT&name=$fulldomain&value=$txtvalue"
57 ZM_Key
="${ZM_Key:-$(_readaccountconf_mutable ZM_Key)}"
58 if [ -z "$ZM_Key" ]; then
60 _err
"You don't specify zonomi api key yet."
61 _err
"Please create your key and try again."
65 _zm_request
"action=DELETE&type=TXT&name=$fulldomain"
69 #################### Private functions below ##################################
74 _debug2
"qstr" "$qstr"
76 _zm_url
="$ZM_Api?api_key=$ZM_Key&$qstr"
77 _debug2
"_zm_url" "$_zm_url"
78 response
="$(_get "$_zm_url")"
80 if [ "$?" != "0" ]; then
83 _debug2 response
"$response"
84 _contains
"$response" "<is_ok>OK:"