4 # Hexonet_Login="username!roleId"
6 # Hexonet_Password="rolePassword"
8 Hexonet_Api
="https://coreapi.1api.net/api/call.cgi"
10 ######## Public functions #####################
12 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
17 Hexonet_Login
="${Hexonet_Login:-$(_readaccountconf_mutable Hexonet_Login)}"
18 Hexonet_Password
="${Hexonet_Password:-$(_readaccountconf_mutable Hexonet_Password)}"
19 if [ -z "$Hexonet_Login" ] ||
[ -z "$Hexonet_Password" ]; then
22 _err
"You must export variables: Hexonet_Login and Hexonet_Password"
26 if ! _contains
"$Hexonet_Login" "!"; then
27 _err
"It seems that the Hexonet_Login=$Hexonet_Login is not a restrivteed user."
28 _err
"Please check and retry."
32 #save the username and password to the account conf file.
33 _saveaccountconf_mutable Hexonet_Login
"$Hexonet_Login"
34 _saveaccountconf_mutable Hexonet_Password
"$Hexonet_Password"
36 _debug
"First detect the root zone"
37 if ! _get_root
"$fulldomain"; then
41 _debug _sub_domain
"$_sub_domain"
42 _debug _domain
"$_domain"
44 _debug
"Getting txt records"
45 _hexonet_rest
"command=QueryDNSZoneRRList&dnszone=${h}.&RRTYPE=TXT"
47 if ! _contains
"$response" "CODE=200"; then
53 if _hexonet_rest
"command=UpdateDNSZone&dnszone=${_domain}.&addrr0=${_sub_domain}%20IN%20TXT%20${txtvalue}"; then
54 if _contains
"$response" "CODE=200"; then
58 _err
"Add txt record error."
62 _err
"Add txt record error."
72 Hexonet_Login
="${Hexonet_Login:-$(_readaccountconf_mutable Hexonet_Login)}"
73 Hexonet_Password
="${Hexonet_Password:-$(_readaccountconf_mutable Hexonet_Password)}"
74 if [ -z "$Hexonet_Login" ] ||
[ -z "$Hexonet_Password" ]; then
77 _err
"You must export variables: Hexonet_Login and Hexonet_Password"
81 _debug
"First detect the root zone"
82 if ! _get_root
"$fulldomain"; then
87 _debug _sub_domain
"$_sub_domain"
88 _debug _domain
"$_domain"
90 _debug
"Getting txt records"
91 _hexonet_rest
"command=QueryDNSZoneRRList&dnszone=${h}.&RRTYPE=TXT&RR=${_sub_domain}%20IN%20TXT%20\"${txtvalue}\""
93 if ! _contains
"$response" "CODE=200"; then
98 count
=$
(printf "%s\n" "$response" | _egrep_o
"PROPERTY[TOTAL][0]=" | cut
-d = -f 2)
100 if [ "$count" = "0" ]; then
101 _info
"Don't need to remove."
103 if ! _hexonet_rest
"command=UpdateDNSZone&dnszone=${_domain}.&delrr0=${_sub_domain}%20IN%20TXT%20\"${txtvalue}\""; then
104 _err
"Delete record error."
107 _contains
"$response" "CODE=200"
112 #################### Private functions below ##################################
113 #_acme-challenge.www.domain.com
115 # _sub_domain=_acme-challenge.www
122 h
=$
(printf "%s" "$domain" | cut
-d .
-f $i-100)
129 if ! _hexonet_rest
"command=QueryDNSZoneRRList&dnszone=${h}."; then
133 if _contains
"$response" "CODE=200"; then
134 _sub_domain
=$
(printf "%s" "$domain" | cut
-d .
-f 1-$p)
146 _debug
"$query_params"
148 response
="$(_get "${Hexonet_Api}?s_login=${Hexonet_Login}&s_pw=${Hexonet_Password}&${query_params}")"
150 if [ "$?" != "0" ]; then
151 _err
"error $query_params"
154 _debug2 response
"$response"