mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 13:11:41 +00:00
fix shellcheck warnings
This commit is contained in:
parent
031e885e4d
commit
c7b16249b8
10
acme.sh
10
acme.sh
@ -411,7 +411,7 @@ _digest() {
|
||||
|
||||
outputhex="$2"
|
||||
|
||||
if [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ]; then
|
||||
if [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ] || [ "$alg" = "md5" ]; then
|
||||
if [ "$outputhex" ]; then
|
||||
openssl dgst -"$alg" -hex | cut -d = -f 2 | tr -d ' '
|
||||
else
|
||||
@ -2290,10 +2290,10 @@ _findHook() {
|
||||
_hookcat="$2"
|
||||
_hookname="$3"
|
||||
|
||||
if [ -f "$_SCRIPT_HOME/$_hookdomain/$_hookname" ]; then
|
||||
d_api="$_SCRIPT_HOME/$_hookdomain/$_hookname"
|
||||
elif [ -f "$_SCRIPT_HOME/$_hookdomain/$_hookname.sh" ]; then
|
||||
d_api="$_SCRIPT_HOME/$_hookdomain/$_hookname.sh"
|
||||
if [ -f "$_SCRIPT_HOME/$_hookcat/$_hookname" ]; then
|
||||
d_api="$_SCRIPT_HOME/$_hookcat/$_hookname"
|
||||
elif [ -f "$_SCRIPT_HOME/$_hookcat/$_hookname.sh" ]; then
|
||||
d_api="$_SCRIPT_HOME/$_hookcat/$_hookname.sh"
|
||||
elif [ -f "$LE_WORKING_DIR/$_hookdomain/$_hookname" ]; then
|
||||
d_api="$LE_WORKING_DIR/$_hookdomain/$_hookname"
|
||||
elif [ -f "$LE_WORKING_DIR/$_hookdomain/$_hookname.sh" ]; then
|
||||
|
@ -25,7 +25,7 @@ dns_cf_add() {
|
||||
_saveaccountconf CF_Email "$CF_Email"
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root $fulldomain; then
|
||||
if ! _get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
@ -36,7 +36,7 @@ dns_cf_add() {
|
||||
_debug "Getting txt records"
|
||||
_cf_rest GET "zones/${_domain_id}/dns_records?type=TXT&name=$fulldomain"
|
||||
|
||||
if ! printf "$response" | grep \"success\":true >/dev/null; then
|
||||
if ! printf "%s" "$response" | grep \"success\":true >/dev/null; then
|
||||
_err "Error"
|
||||
return 1
|
||||
fi
|
||||
@ -46,7 +46,7 @@ dns_cf_add() {
|
||||
if [ "$count" = "0" ]; then
|
||||
_info "Adding record"
|
||||
if _cf_rest POST "zones/$_domain_id/dns_records" "{\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"ttl\":120}"; then
|
||||
if printf -- "%s" "$response" | grep $fulldomain >/dev/null; then
|
||||
if printf -- "%s" "$response" | grep "$fulldomain" >/dev/null; then
|
||||
_info "Added, sleeping 10 seconds"
|
||||
sleep 10
|
||||
#todo: check if the record takes effect
|
||||
@ -60,7 +60,7 @@ dns_cf_add() {
|
||||
else
|
||||
_info "Updating record"
|
||||
record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \" | head -n 1)
|
||||
_debug "record_id" $record_id
|
||||
_debug "record_id" "$record_id"
|
||||
|
||||
_cf_rest PUT "zones/$_domain_id/dns_records/$record_id" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"zone_id\":\"$_domain_id\",\"zone_name\":\"$_domain\"}"
|
||||
if [ "$?" = "0" ]; then
|
||||
@ -91,8 +91,8 @@ _get_root() {
|
||||
domain=$1
|
||||
i=2
|
||||
p=1
|
||||
while [ '1' ]; do
|
||||
h=$(printf $domain | cut -d . -f $i-100)
|
||||
while true; do
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
if [ -z "$h" ]; then
|
||||
#not valid
|
||||
return 1
|
||||
@ -102,17 +102,17 @@ _get_root() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf $response | grep \"name\":\"$h\" >/dev/null; then
|
||||
if printf "%s" "$response" | grep "\"name\":\"$h\"" >/dev/null; then
|
||||
_domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | head -n 1 | cut -d : -f 2 | tr -d \")
|
||||
if [ "$_domain_id" ]; then
|
||||
_sub_domain=$(printf $domain | cut -d . -f 1-$p)
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_domain=$h
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
p=$i
|
||||
i=$(expr $i + 1)
|
||||
i=$(_math "$i" + 1)
|
||||
done
|
||||
return 1
|
||||
}
|
||||
@ -121,7 +121,7 @@ _cf_rest() {
|
||||
m=$1
|
||||
ep="$2"
|
||||
data="$3"
|
||||
_debug $ep
|
||||
_debug "$ep"
|
||||
|
||||
_H1="X-Auth-Email: $CF_Email"
|
||||
_H2="X-Auth-Key: $CF_Key"
|
||||
@ -129,7 +129,7 @@ _cf_rest() {
|
||||
|
||||
if [ "$data" ]; then
|
||||
_debug data "$data"
|
||||
response="$(_post "$data" "$CF_Api/$ep" "" $m)"
|
||||
response="$(_post "$data" "$CF_Api/$ep" "" "$m")"
|
||||
else
|
||||
response="$(_get "$CF_Api/$ep")"
|
||||
fi
|
||||
|
@ -22,19 +22,19 @@ dns_cx_add() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
REST_API=$CX_Api
|
||||
REST_API="$CX_Api"
|
||||
|
||||
#save the api key and email to the account conf file.
|
||||
_saveaccountconf CX_Key "$CX_Key"
|
||||
_saveaccountconf CX_Secret "$CX_Secret"
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root $fulldomain; then
|
||||
if ! _get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
|
||||
existing_records $_domain $_sub_domain
|
||||
existing_records "$_domain" "$_sub_domain"
|
||||
_debug count "$count"
|
||||
if [ "$?" != "0" ]; then
|
||||
_err "Error get existing records."
|
||||
@ -42,9 +42,9 @@ dns_cx_add() {
|
||||
fi
|
||||
|
||||
if [ "$count" = "0" ]; then
|
||||
add_record $_domain $_sub_domain $txtvalue
|
||||
add_record "$_domain" "$_sub_domain" "$txtvalue"
|
||||
else
|
||||
update_record $_domain $_sub_domain $txtvalue
|
||||
update_record "$_domain" "$_sub_domain" "$txtvalue"
|
||||
fi
|
||||
|
||||
if [ "$?" = "0" ]; then
|
||||
@ -78,7 +78,7 @@ existing_records() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if printf "$response" | grep '"type":"TXT"' >/dev/null; then
|
||||
if printf "%s" "$response" | grep '"type":"TXT"' >/dev/null; then
|
||||
count=1
|
||||
record_id=$(printf "%s\n" "$seg" | _egrep_o \"record_id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \")
|
||||
_debug record_id "$record_id"
|
||||
@ -93,7 +93,7 @@ add_record() {
|
||||
root=$1
|
||||
sub=$2
|
||||
txtvalue=$3
|
||||
fulldomain=$sub.$root
|
||||
fulldomain="$sub.$root"
|
||||
|
||||
_info "Adding record"
|
||||
|
||||
@ -110,7 +110,7 @@ update_record() {
|
||||
root=$1
|
||||
sub=$2
|
||||
txtvalue=$3
|
||||
fulldomain=$sub.$root
|
||||
fulldomain="$sub.$root"
|
||||
|
||||
_info "Updating record"
|
||||
|
||||
@ -136,30 +136,30 @@ _get_root() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
while [ '1' ]; do
|
||||
h=$(printf $domain | cut -d . -f $i-100)
|
||||
while true; do
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
_debug h "$h"
|
||||
if [ -z "$h" ]; then
|
||||
#not valid
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf "$response" | grep "$h." >/dev/null; then
|
||||
if _contains "$response" "$h."; then
|
||||
seg=$(printf "%s" "$response" | _egrep_o "\{[^\{]*\"$h\.\"[^\}]*\}")
|
||||
_debug seg "$seg"
|
||||
_domain_id=$(printf "%s" "$seg" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \")
|
||||
_debug _domain_id "$_domain_id"
|
||||
if [ "$_domain_id" ]; then
|
||||
_sub_domain=$(printf $domain | cut -d . -f 1-$p)
|
||||
_debug _sub_domain $_sub_domain
|
||||
_domain=$h
|
||||
_debug _domain $_domain
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_debug _sub_domain "$_sub_domain"
|
||||
_domain="$h"
|
||||
_debug _domain "$_domain"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
p=$i
|
||||
i=$(expr $i + 1)
|
||||
p="$i"
|
||||
i=$(_math "$i" + 1)
|
||||
done
|
||||
return 1
|
||||
}
|
||||
@ -168,7 +168,7 @@ _get_root() {
|
||||
_rest() {
|
||||
m=$1
|
||||
ep="$2"
|
||||
_debug $ep
|
||||
_debug "$ep"
|
||||
url="$REST_API/$ep"
|
||||
_debug url "$url"
|
||||
|
||||
@ -180,7 +180,7 @@ _rest() {
|
||||
|
||||
sec="$CX_Key$url$data$cdate$CX_Secret"
|
||||
_debug sec "$sec"
|
||||
hmac=$(printf "$sec" | openssl md5 | cut -d " " -f 2)
|
||||
hmac=$(printf "%s" "$sec" | _digest md5 hex)
|
||||
_debug hmac "$hmac"
|
||||
|
||||
_H1="API-KEY: $CX_Key"
|
||||
@ -199,7 +199,7 @@ _rest() {
|
||||
return 1
|
||||
fi
|
||||
_debug2 response "$response"
|
||||
if ! printf "$response" | grep '"message":"success"' >/dev/null; then
|
||||
if ! _contains "$response" '"message":"success"'; then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
|
@ -22,19 +22,19 @@ dns_dp_add() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
REST_API=$DP_Api
|
||||
REST_API="$DP_Api"
|
||||
|
||||
#save the api key and email to the account conf file.
|
||||
_saveaccountconf DP_Id "$DP_Id"
|
||||
_saveaccountconf DP_Key "$DP_Key"
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root $fulldomain; then
|
||||
if ! _get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
|
||||
existing_records $_domain $_sub_domain
|
||||
existing_records "$_domain" "$_sub_domain"
|
||||
_debug count "$count"
|
||||
if [ "$?" != "0" ]; then
|
||||
_err "Error get existing records."
|
||||
@ -42,9 +42,9 @@ dns_dp_add() {
|
||||
fi
|
||||
|
||||
if [ "$count" = "0" ]; then
|
||||
add_record $_domain $_sub_domain $txtvalue
|
||||
add_record "$_domain" "$_sub_domain" "$txtvalue"
|
||||
else
|
||||
update_record $_domain $_sub_domain $txtvalue
|
||||
update_record "$_domain" "$_sub_domain" "$txtvalue"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -67,14 +67,14 @@ existing_records() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf "$response" | grep 'No records'; then
|
||||
if _contains "$response" 'No records'; then
|
||||
count=0
|
||||
return 0
|
||||
fi
|
||||
|
||||
if printf "$response" | grep "Action completed successful" >/dev/null; then
|
||||
count=$(printf "$response" | grep '<type>TXT</type>' | wc -l)
|
||||
record_id=$(printf "$response" | grep '^<id>' | tail -1 | cut -d '>' -f 2 | cut -d '<' -f 1)
|
||||
if _contains "$response" "Action completed successful"; then
|
||||
count=$(printf "%s" "$response" | grep '<type>TXT</type>' | wc -l)
|
||||
record_id=$(printf "%s" "$response" | grep '^<id>' | tail -1 | cut -d '>' -f 2 | cut -d '<' -f 1)
|
||||
return 0
|
||||
else
|
||||
_err "get existing records error."
|
||||
@ -90,7 +90,7 @@ add_record() {
|
||||
root=$1
|
||||
sub=$2
|
||||
txtvalue=$3
|
||||
fulldomain=$sub.$root
|
||||
fulldomain="$sub.$root"
|
||||
|
||||
_info "Adding record"
|
||||
|
||||
@ -98,7 +98,7 @@ add_record() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf "$response" | grep "Action completed successful"; then
|
||||
if _contains "$response" "Action completed successful"; then
|
||||
|
||||
return 0
|
||||
fi
|
||||
@ -112,7 +112,7 @@ update_record() {
|
||||
root=$1
|
||||
sub=$2
|
||||
txtvalue=$3
|
||||
fulldomain=$sub.$root
|
||||
fulldomain="$sub.$root"
|
||||
|
||||
_info "Updating record"
|
||||
|
||||
@ -120,7 +120,7 @@ update_record() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf "$response" | grep "Action completed successful"; then
|
||||
if _contains "$response" "Action completed successful"; then
|
||||
|
||||
return 0
|
||||
fi
|
||||
@ -138,8 +138,8 @@ _get_root() {
|
||||
domain=$1
|
||||
i=2
|
||||
p=1
|
||||
while [ '1' ]; do
|
||||
h=$(printf $domain | cut -d . -f $i-100)
|
||||
while true; do
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
if [ -z "$h" ]; then
|
||||
#not valid
|
||||
return 1
|
||||
@ -149,20 +149,20 @@ _get_root() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf "$response" | grep "Action completed successful" >/dev/null; then
|
||||
if _contains "$response" "Action completed successful"; then
|
||||
_domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \")
|
||||
_debug _domain_id "$_domain_id"
|
||||
if [ "$_domain_id" ]; then
|
||||
_sub_domain=$(printf $domain | cut -d . -f 1-$p)
|
||||
_debug _sub_domain $_sub_domain
|
||||
_domain=$h
|
||||
_debug _domain $_domain
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_debug _sub_domain "$_sub_domain"
|
||||
_domain="$h"
|
||||
_debug _domain "$_domain"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
p=$i
|
||||
i=$(expr $i + 1)
|
||||
p="$i"
|
||||
i=$(_math "$i" + 1)
|
||||
done
|
||||
return 1
|
||||
}
|
||||
@ -172,14 +172,14 @@ _rest() {
|
||||
m=$1
|
||||
ep="$2"
|
||||
data="$3"
|
||||
_debug $ep
|
||||
_debug "$ep"
|
||||
url="$REST_API/$ep"
|
||||
|
||||
_debug url "$url"
|
||||
|
||||
if [ "$data" ]; then
|
||||
_debug2 data "$data"
|
||||
response="$(_post $data "$url")"
|
||||
response="$(_post "$data" "$url")"
|
||||
else
|
||||
response="$(_get "$url")"
|
||||
fi
|
||||
|
@ -26,7 +26,7 @@ dns_gd_add() {
|
||||
_saveaccountconf GD_Secret "$GD_Secret"
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root $fulldomain; then
|
||||
if ! _get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
@ -67,8 +67,8 @@ _get_root() {
|
||||
domain=$1
|
||||
i=2
|
||||
p=1
|
||||
while [ '1' ]; do
|
||||
h=$(printf $domain | cut -d . -f $i-100)
|
||||
while true; do
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
if [ -z "$h" ]; then
|
||||
#not valid
|
||||
return 1
|
||||
@ -78,11 +78,11 @@ _get_root() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf "$response" | grep '"code":"NOT_FOUND"' >/dev/null; then
|
||||
if _contains "$response" '"code":"NOT_FOUND"'; then
|
||||
_debug "$h not found"
|
||||
else
|
||||
_sub_domain=$(printf $domain | cut -d . -f 1-$p)
|
||||
_domain=$h
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_domain="$h"
|
||||
return 0
|
||||
fi
|
||||
p=$i
|
||||
@ -95,7 +95,7 @@ _gd_rest() {
|
||||
m=$1
|
||||
ep="$2"
|
||||
data="$3"
|
||||
_debug $ep
|
||||
_debug "$ep"
|
||||
|
||||
_H1="Authorization: sso-key $GD_Key:$GD_Secret"
|
||||
_H2="Content-Type: application/json"
|
||||
|
@ -14,9 +14,9 @@ dns_lexicon_add() {
|
||||
fulldomain=$1
|
||||
txtvalue=$2
|
||||
|
||||
domain=$(printf "$fulldomain" | cut -d . -f 2-999)
|
||||
domain=$(printf "%s" "$fulldomain" | cut -d . -f 2-999)
|
||||
|
||||
if ! _exists $lexicon_cmd; then
|
||||
if ! _exists "$lexicon_cmd"; then
|
||||
_err "Please install $lexicon_cmd first: $wiki"
|
||||
return 1
|
||||
fi
|
||||
@ -33,7 +33,7 @@ dns_lexicon_add() {
|
||||
eval Lx_name_v="\$$Lx_name"
|
||||
_debug "$Lx_name" "$Lx_name_v"
|
||||
if [ "$Lx_name_v" ]; then
|
||||
_saveaccountconf $Lx_name "$Lx_name_v"
|
||||
_saveaccountconf "$Lx_name" "$Lx_name_v"
|
||||
export "$Lx_name"
|
||||
fi
|
||||
|
||||
@ -41,7 +41,7 @@ dns_lexicon_add() {
|
||||
eval Lx_token_v="\$$Lx_token"
|
||||
_debug "$Lx_token" "$Lx_token_v"
|
||||
if [ "$Lx_token_v" ]; then
|
||||
_saveaccountconf $Lx_token "$Lx_token_v"
|
||||
_saveaccountconf "$Lx_token" "$Lx_token_v"
|
||||
export "$Lx_token"
|
||||
fi
|
||||
|
||||
@ -49,7 +49,7 @@ dns_lexicon_add() {
|
||||
eval Lx_password_v="\$$Lx_password"
|
||||
_debug "$Lx_password" "$Lx_password_v"
|
||||
if [ "$Lx_password_v" ]; then
|
||||
_saveaccountconf $Lx_password "$Lx_password_v"
|
||||
_saveaccountconf "$Lx_password" "$Lx_password_v"
|
||||
export "$Lx_password"
|
||||
fi
|
||||
|
||||
@ -58,7 +58,7 @@ dns_lexicon_add() {
|
||||
_debug "$Lx_domaintoken" "$Lx_domaintoken_v"
|
||||
if [ "$Lx_domaintoken_v" ]; then
|
||||
export "$Lx_domaintoken"
|
||||
_saveaccountconf $Lx_domaintoken "$Lx_domaintoken_v"
|
||||
_saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v"
|
||||
fi
|
||||
|
||||
$lexicon_cmd "$PROVIDER" create ${domain} TXT --name="_acme-challenge.${domain}." --content="${txtvalue}"
|
||||
|
@ -28,7 +28,7 @@ dns_lua_add() {
|
||||
_saveaccountconf LUA_Email "$LUA_Email"
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root $fulldomain; then
|
||||
if ! _get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
@ -49,7 +49,7 @@ dns_lua_add() {
|
||||
if [ "$count" = "0" ]; then
|
||||
_info "Adding record"
|
||||
if _LUA_rest POST "zones/$_domain_id/records" "{\"type\":\"TXT\",\"name\":\"$fulldomain.\",\"content\":\"$txtvalue\",\"ttl\":120}"; then
|
||||
if printf -- "%s" "$response" | grep $fulldomain >/dev/null; then
|
||||
if printf -- "%s" "$response" | grep "$fulldomain" >/dev/null; then
|
||||
_info "Added"
|
||||
#todo: check if the record takes effect
|
||||
return 0
|
||||
@ -62,7 +62,7 @@ dns_lua_add() {
|
||||
else
|
||||
_info "Updating record"
|
||||
record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]*,\"name\":\"$fulldomain.\",\"type\":\"TXT\" | cut -d: -f2 | cut -d, -f1)
|
||||
_debug "record_id" $record_id
|
||||
_debug "record_id" "$record_id"
|
||||
|
||||
_LUA_rest PUT "zones/$_domain_id/records/$record_id" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$fulldomain.\",\"content\":\"$txtvalue\",\"zone_id\":\"$_domain_id\",\"ttl\":120}"
|
||||
if [ "$?" = "0" ]; then
|
||||
@ -95,24 +95,24 @@ _get_root() {
|
||||
if ! _LUA_rest GET "zones"; then
|
||||
return 1
|
||||
fi
|
||||
while [ '1' ]; do
|
||||
h=$(printf $domain | cut -d . -f $i-100)
|
||||
while true; do
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
if [ -z "$h" ]; then
|
||||
#not valid
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf $response | grep \"name\":\"$h\" >/dev/null; then
|
||||
if _contains "$response" "\"name\":\"$h\""; then
|
||||
_domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]*,\"name\":\"$h\" | cut -d : -f 2 | cut -d , -f 1)
|
||||
if [ "$_domain_id" ]; then
|
||||
_sub_domain=$(printf $domain | cut -d . -f 1-$p)
|
||||
_domain=$h
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_domain="$h"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
p=$i
|
||||
i=$(expr $i + 1)
|
||||
i=$(_math "$i" + 1)
|
||||
done
|
||||
return 1
|
||||
}
|
||||
@ -121,7 +121,7 @@ _LUA_rest() {
|
||||
m=$1
|
||||
ep="$2"
|
||||
data="$3"
|
||||
_debug $ep
|
||||
_debug "$ep"
|
||||
|
||||
_H1="Accept: application/json"
|
||||
_H2="Authorization: Basic $LUA_auth"
|
||||
|
@ -25,7 +25,7 @@ dns_me_add() {
|
||||
_saveaccountconf ME_Secret "$ME_Secret"
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root $fulldomain; then
|
||||
if ! _get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
@ -36,7 +36,7 @@ dns_me_add() {
|
||||
_debug "Getting txt records"
|
||||
_me_rest GET "${_domain_id}/records?recordName=$_sub_domain&type=TXT"
|
||||
|
||||
if ! printf "$response" | grep \"totalRecords\": >/dev/null; then
|
||||
if ! _contains "$response" "\"totalRecords\":"; then
|
||||
_err "Error"
|
||||
return 1
|
||||
fi
|
||||
@ -59,7 +59,7 @@ dns_me_add() {
|
||||
else
|
||||
_info "Updating record"
|
||||
record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]* | cut -d : -f 2 | head -n 1)
|
||||
_debug "record_id" $record_id
|
||||
_debug "record_id" "$record_id"
|
||||
|
||||
_me_rest PUT "$_domain_id/records/$record_id/" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"value\":\"$txtvalue\",\"gtdLocation\":\"DEFAULT\",\"ttl\":120}"
|
||||
if [ "$?" = "0" ]; then
|
||||
@ -89,8 +89,8 @@ _get_root() {
|
||||
domain=$1
|
||||
i=2
|
||||
p=1
|
||||
while [ '1' ]; do
|
||||
h=$(printf $domain | cut -d . -f $i-100)
|
||||
while true; do
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
if [ -z "$h" ]; then
|
||||
#not valid
|
||||
return 1
|
||||
@ -100,17 +100,17 @@ _get_root() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf $response | grep \"name\":\"$h\" >/dev/null; then
|
||||
if _contains "$response" "\"name\":\"$h\""; then
|
||||
_domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]* | head -n 1 | cut -d : -f 2)
|
||||
if [ "$_domain_id" ]; then
|
||||
_sub_domain=$(printf $domain | cut -d . -f 1-$p)
|
||||
_domain=$h
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_domain="$h"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
p=$i
|
||||
i=$(expr $i + 1)
|
||||
i=$(_math "$i" + 1)
|
||||
done
|
||||
return 1
|
||||
}
|
||||
@ -119,10 +119,10 @@ _me_rest() {
|
||||
m=$1
|
||||
ep="$2"
|
||||
data="$3"
|
||||
_debug $ep
|
||||
_debug "$ep"
|
||||
|
||||
cdate=$(date -u +"%a, %d %b %Y %T %Z")
|
||||
hmac=$(printf "$cdate" | _hmac sha1 "$ME_Secret" 1)
|
||||
hmac=$(printf "%s" "$cdate" | _hmac sha1 "$ME_Secret" 1)
|
||||
|
||||
_H1="x-dnsme-apiKey: $ME_Key"
|
||||
_H2="x-dnsme-requestDate: $cdate"
|
||||
|
@ -226,8 +226,8 @@ _get_root() {
|
||||
domain=$1
|
||||
i=2
|
||||
p=1
|
||||
while [ '1' ]; do
|
||||
h=$(printf $domain | cut -d . -f $i-100)
|
||||
while true; do
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
if [ -z "$h" ]; then
|
||||
#not valid
|
||||
return 1
|
||||
@ -238,12 +238,12 @@ _get_root() {
|
||||
fi
|
||||
|
||||
if ! _contains "$response" "This service does not exist" >/dev/null; then
|
||||
_sub_domain=$(printf $domain | cut -d . -f 1-$p)
|
||||
_domain=$h
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
|
||||
_domain="$h"
|
||||
return 0
|
||||
fi
|
||||
p=$i
|
||||
i=$(expr $i + 1)
|
||||
i=$(_math "$i" + 1)
|
||||
done
|
||||
return 1
|
||||
}
|
||||
@ -261,7 +261,7 @@ _ovh_rest() {
|
||||
m=$1
|
||||
ep="$2"
|
||||
data="$3"
|
||||
_debug $ep
|
||||
_debug "$ep"
|
||||
|
||||
_ovh_url="$OVH_API/$ep"
|
||||
_debug2 _ovh_url "$_ovh_url"
|
||||
|
@ -35,7 +35,7 @@ dns_pdns_add() {
|
||||
fi
|
||||
|
||||
if [ -z "$PDNS_Ttl" ]; then
|
||||
PDNS_Ttl=$DEFAULT_PDNS_TTL
|
||||
PDNS_Ttl="$DEFAULT_PDNS_TTL"
|
||||
fi
|
||||
|
||||
#save the api addr and key to the account conf file.
|
||||
@ -48,7 +48,7 @@ dns_pdns_add() {
|
||||
fi
|
||||
|
||||
_debug "First detect the root zone"
|
||||
if ! _get_root $fulldomain; then
|
||||
if ! _get_root "$fulldomain"; then
|
||||
_err "invalid domain"
|
||||
return 1
|
||||
fi
|
||||
@ -94,22 +94,22 @@ _get_root() {
|
||||
p=1
|
||||
|
||||
if _pdns_rest "GET" "/api/v1/servers/$PDNS_ServerId/zones"; then
|
||||
_zones_response=$response
|
||||
_zones_response="$response"
|
||||
fi
|
||||
|
||||
while [ '1' ]; do
|
||||
h=$(printf $domain | cut -d . -f $i-100)
|
||||
while true; do
|
||||
h=$(printf "%s" "$domain" | cut -d . -f $i-100)
|
||||
if [ -z "$h" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if printf "$_zones_response" | grep "\"name\": \"$h.\"" >/dev/null; then
|
||||
_domain=$h
|
||||
if _contains "$_zones_response" "\"name\": \"$h.\""; then
|
||||
_domain="$h"
|
||||
return 0
|
||||
fi
|
||||
|
||||
p=$i
|
||||
i=$(expr $i + 1)
|
||||
i=$(_math $i + 1)
|
||||
done
|
||||
_debug "$domain not found"
|
||||
return 1
|
||||
|
Loading…
Reference in New Issue
Block a user