This commit is contained in:
neilpang 2019-07-20 17:09:36 +08:00
parent ccc2142b45
commit 93d29a9733

View File

@ -1,9 +1,9 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# #
# Hexonet_Username="username" # Hexonet_Login="username!roleId"
# #
# Hexonet_Password="password" # Hexonet_Password="rolePassword"
Hexonet_Api="https://coreapi.1api.net/api/call.cgi" Hexonet_Api="https://coreapi.1api.net/api/call.cgi"
@ -14,23 +14,23 @@ dns_hexonet_add() {
fulldomain=$1 fulldomain=$1
txtvalue=$2 txtvalue=$2
Hexonet_Username="${Hexonet_Username:-$(_readaccountconf_mutable Hexonet_Username)}" Hexonet_Login="${Hexonet_Login:-$(_readaccountconf_mutable Hexonet_Login)}"
Hexonet_Password="${Hexonet_Password:-$(_readaccountconf_mutable Hexonet_Password)}" Hexonet_Password="${Hexonet_Password:-$(_readaccountconf_mutable Hexonet_Password)}"
if [ -z "$Hexonet_Username" ] || [ -z "$Hexonet_Password" ]; then if [ -z "$Hexonet_Login" ] || [ -z "$Hexonet_Password" ]; then
Hexonet_Username="" Hexonet_Login=""
Hexonet_Password="" Hexonet_Password=""
_err "You must export variables: Hexonet_Username and Hexonet_Password" _err "You must export variables: Hexonet_Login and Hexonet_Password"
return 1 return 1
fi fi
if ! _contains "$Hexonet_Username" "!"; then if ! _contains "$Hexonet_Login" "!"; then
_err "It seems that the Hexonet_Username=$Hexonet_Username is not a restrivteed user." _err "It seems that the Hexonet_Login=$Hexonet_Login is not a restrivteed user."
_err "Please check and retry." _err "Please check and retry."
return 1 return 1
fi fi
#save the username and password to the account conf file. #save the username and password to the account conf file.
_saveaccountconf_mutable Hexonet_Username "$Hexonet_Username" _saveaccountconf_mutable Hexonet_Login "$Hexonet_Login"
_saveaccountconf_mutable Hexonet_Password "$Hexonet_Password" _saveaccountconf_mutable Hexonet_Password "$Hexonet_Password"
_debug "First detect the root zone" _debug "First detect the root zone"
@ -69,12 +69,12 @@ dns_hexonet_rm() {
fulldomain=$1 fulldomain=$1
txtvalue=$2 txtvalue=$2
Hexonet_Username="${Hexonet_Username:-$(_readaccountconf_mutable Hexonet_Username)}" Hexonet_Login="${Hexonet_Login:-$(_readaccountconf_mutable Hexonet_Login)}"
Hexonet_Password="${Hexonet_Password:-$(_readaccountconf_mutable Hexonet_Password)}" Hexonet_Password="${Hexonet_Password:-$(_readaccountconf_mutable Hexonet_Password)}"
if [ -z "$Hexonet_Username" ] || [ -z "$Hexonet_Password" ]; then if [ -z "$Hexonet_Login" ] || [ -z "$Hexonet_Password" ]; then
Hexonet_Username="" Hexonet_Login=""
Hexonet_Password="" Hexonet_Password=""
_err "You must export variables: Hexonet_Username and Hexonet_Password" _err "You must export variables: Hexonet_Login and Hexonet_Password"
return 1 return 1
fi fi
@ -145,7 +145,7 @@ _hexonet_rest() {
query_params="$1" query_params="$1"
_debug "$query_params" _debug "$query_params"
response="$(_get "${Hexonet_Api}?s_login=${Hexonet_Username}&s_pw=${Hexonet_Password}&${query_params}")" response="$(_get "${Hexonet_Api}?s_login=${Hexonet_Login}&s_pw=${Hexonet_Password}&${query_params}")"
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
_err "error $query_params" _err "error $query_params"