fix shfmt

This commit is contained in:
flywithu 2020-09-01 20:09:45 +09:00 committed by GitHub
parent 8b06343653
commit 9d1913c39f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,51 +15,51 @@
#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" #Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
dns_dnsever_add() { dns_dnsever_add() {
fulldomain=$1 fulldomain=$1
txtvalue=$2 txtvalue=$2
_info "Using dnsever add" _info "Using dnsever add"
_debug fulldomain "$fulldomain" _debug fulldomain "$fulldomain"
_debug txtvalue "$txtvalue" _debug txtvalue "$txtvalue"
if [ -z "$DNSEVER_ID" ] || [ -z "$DNSEVER_PW" ]; then if [ -z "$DNSEVER_ID" ] || [ -z "$DNSEVER_PW" ]; then
DNSEVER_ID="" DNSEVER_ID=""
DNSEVER_PW="" DNSEVER_PW=""
_err "You don't specify dnsever.com ID or PW yet." _err "You don't specify dnsever.com ID or PW yet."
_err "Please create you key and try again." _err "Please create you key and try again."
_err "export DNSEVER_ID=YOURID && export DNSEVER_PW=YOURPW " _err "export DNSEVER_ID=YOURID && export DNSEVER_PW=YOURPW "
_err " ./acme.sh --issue --force --dns dns_dnsever -d "*.flywithu.com" " _err " ./acme.sh --issue --force --dns dns_dnsever -d "*.flywithu.com" "
return 1 return 1
fi fi
#save the api key and email to the account conf file. #save the api key and email to the account conf file.
_saveaccountconf DNSEVER_ID "$DNSEVER_ID" _saveaccountconf DNSEVER_ID "$DNSEVER_ID"
_saveaccountconf DNSEVER_PW "$DNSEVER_PW" _saveaccountconf DNSEVER_PW "$DNSEVER_PW"
dnsever_domain_txt "add" "$DNSEVER_ID" "$DNSEVER_PW" "$fulldomain" "$txtvalue" dnsever_domain_txt "add" "$DNSEVER_ID" "$DNSEVER_PW" "$fulldomain" "$txtvalue"
return $? return $?
} }
#Usage: fulldomain txtvalue #Usage: fulldomain txtvalue
#Remove the txt record after validation. #Remove the txt record after validation.
dns_dnsever_rm() { dns_dnsever_rm() {
fulldomain=$1 fulldomain=$1
txtvalue=$2 txtvalue=$2
_info "Using dnsever remove" _info "Using dnsever remove"
_debug fulldomain "$fulldomain" _debug fulldomain "$fulldomain"
_debug txtvalue "$txtvalue" _debug txtvalue "$txtvalue"
if [ -z "$DNSEVER_ID" ] || [ -z "$DNSEVER_PW" ]; then if [ -z "$DNSEVER_ID" ] || [ -z "$DNSEVER_PW" ]; then
DNSEVER_ID="" DNSEVER_ID=""
DNSEVER_PW="" DNSEVER_PW=""
_err "You don't specify dnsever.com ID or PW yet." _err "You don't specify dnsever.com ID or PW yet."
_err "Please create you key and try again." _err "Please create you key and try again."
_err "export DNSEVER_ID=YOURID && export DNSEVER_PW=YOURPW " _err "export DNSEVER_ID=YOURID && export DNSEVER_PW=YOURPW "
_err " ./acme.sh --issue --force --dns dns_dnsever -d "*.flywithu.com" " _err " ./acme.sh --issue --force --dns dns_dnsever -d "*.flywithu.com" "
return 1 return 1
fi fi
dnsever_domain_txt "del" "$DNSEVER_ID" "$DNSEVER_PW" "$fulldomain" "$txtvalue" dnsever_domain_txt "del" "$DNSEVER_ID" "$DNSEVER_PW" "$fulldomain" "$txtvalue"
return $? return $?
} }
#################### Private functions below ################################## #################### Private functions below ##################################
@ -70,132 +70,132 @@ dns_dnsever_rm() {
# _domain=domain.com # _domain=domain.com
_get_root() { _get_root() {
domain=$1 domain=$1
i=2 i=2
p=1 p=1
while true; do while true; do
h=$(printf "%s" "$domain" | cut -d . -f $i-100) h=$(printf "%s" "$domain" | cut -d . -f $i-100)
if [ -z "$h" ]; then if [ -z "$h" ]; then
#not valid #not valid
return 1 return 1
fi fi
#<OPTION value="flywithu.com" selected>flywithu.com</OPTION> #<OPTION value="flywithu.com" selected>flywithu.com</OPTION>
domains=$(printf "%s\n" "$response" | _egrep_o "OPTION value=\".+\"" | tr -d '\n') domains=$(printf "%s\n" "$response" | _egrep_o "OPTION value=\".+\"" | tr -d '\n')
_debug2 "h" "$h" _debug2 "h" "$h"
_debug2 "domains" "$domains" _debug2 "domains" "$domains"
if _contains "$domains" "$h"; then if _contains "$domains" "$h"; then
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
_domain="$h" _domain="$h"
return 0 return 0
fi fi
p=$i p=$i
i=$(_math "$i" + 1) i=$(_math "$i" + 1)
done done
return 1 return 1
} }
_get_check_count() { _get_check_count() {
domain=$1 domain=$1
_err "res" "$response" _err "res" "$response"
} }
dnsever_domain_txt() { dnsever_domain_txt() {
action="$1" action="$1"
login_id="$2" login_id="$2"
login_password="$3" login_password="$3"
domain_name="$4" domain_name="$4"
domain_txt="$5" domain_txt="$5"
response=$(_post "login_id=$login_id&login_password=$login_password" "https://kr.dnsever.com/index.html") response=$(_post "login_id=$login_id&login_password=$login_password" "https://kr.dnsever.com/index.html")
result=$? result=$?
if [ $result != 0 ] || [ -z "$response" ]; then if [ $result != 0 ] || [ -z "$response" ]; then
_err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/index.html with login_id=$login_id login_password=$login_password" _err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/index.html with login_id=$login_id login_password=$login_password"
return 1 return 1
fi fi
_H1="$(grep PHPSESSID "$HTTP_HEADER" | sed s/^Set-//)" _H1="$(grep PHPSESSID "$HTTP_HEADER" | sed s/^Set-//)"
export _H1 export _H1
response=$(_post "" "https://kr.dnsever.com/start.html") response=$(_post "" "https://kr.dnsever.com/start.html")
result=$? result=$?
if [ $result != 0 ] || [ -z "$response" ]; then if [ $result != 0 ] || [ -z "$response" ]; then
_err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/start.html after login" _err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/start.html after login"
return 1 return 1
fi fi
# newhref=$(echo "$response" | sed -E "s/.*\'(.*)\'<.*/\1/") # newhref=$(echo "$response" | sed -E "s/.*\'(.*)\'<.*/\1/")
newhref=$(printf "%s\n" "$response" | _egrep_o "'.+'" | cut -d\' -f2) newhref=$(printf "%s\n" "$response" | _egrep_o "'.+'" | cut -d\' -f2)
response=$(_post "" "$newhref") response=$(_post "" "$newhref")
result=$? result=$?
if [ $result != 0 ] || [ -z "$response" ]; then if [ $result != 0 ] || [ -z "$response" ]; then
_err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/start.html after login" _err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/start.html after login"
return 1 return 1
fi fi
# newhref=$(echo "$response" | sed -E "s/.*action=\"(.*)\" .*/\1/") # newhref=$(echo "$response" | sed -E "s/.*action=\"(.*)\" .*/\1/")
newhref=$(printf "%s\n" "$response" | _egrep_o "https.+\" " | cut -d\" -f1) newhref=$(printf "%s\n" "$response" | _egrep_o "https.+\" " | cut -d\" -f1)
response=$(_post "" "$newhref") response=$(_post "" "$newhref")
result=$? result=$?
if [ $result != 0 ] || [ -z "$response" ]; then if [ $result != 0 ] || [ -z "$response" ]; then
_err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/start.html after login" _err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/start.html after login"
return 1 return 1
fi fi
response=$(_post "" "https://kr.dnsever.com/start.html") response=$(_post "" "https://kr.dnsever.com/start.html")
result=$? result=$?
if [ $result != 0 ] || [ -z "$response" ]; then if [ $result != 0 ] || [ -z "$response" ]; then
_err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/start.html after login" _err "dnsever_txt:$action ERROR login failed. Please check https://kr.dnsever.com/start.html after login"
return 1 return 1
fi fi
skey=$(printf "%s\n" "$response" | _egrep_o "name=\"skey\" value=\".+\"" | cut -f3 -d= | tr -d \") skey=$(printf "%s\n" "$response" | _egrep_o "name=\"skey\" value=\".+\"" | cut -f3 -d= | tr -d \")
_debug skey "$skey" _debug skey "$skey"
if [ -z "$skey" ]; then if [ -z "$skey" ]; then
_err "dnsever_txt:$action ERROR login failed with login_id=$login_id login_password=$login_password" _err "dnsever_txt:$action ERROR login failed with login_id=$login_id login_password=$login_password"
response=$(_post "skey=$skey" "https://kr.dnsever.com/logout.php") response=$(_post "skey=$skey" "https://kr.dnsever.com/logout.php")
return 1 return 1
fi fi
_get_root "$domain_name" _get_root "$domain_name"
_debug2 "fulldomain" "$domain_name" _debug2 "fulldomain" "$domain_name"
_debug2 "domain" "$_domain" _debug2 "domain" "$_domain"
_debug2 "subdomain" "$_sub_domain" _debug2 "subdomain" "$_sub_domain"
_debug2 "txt" "$domain_txt" _debug2 "txt" "$domain_txt"
if [ "$action" = "add" ]; then if [ "$action" = "add" ]; then
##https://kr.dnsever.com/start.html?user_domain=flywithu.com&selected_menu=edittxt&skey=flywithu:f80f523d2254f1e2c56462ace327f256 ##https://kr.dnsever.com/start.html?user_domain=flywithu.com&selected_menu=edittxt&skey=flywithu:f80f523d2254f1e2c56462ace327f256
# subname=$(echo "$domain_name" | sed "s/\.$user_domain\$//") # subname=$(echo "$domain_name" | sed "s/\.$user_domain\$//")
response=$(_post "skey=$skey&user_domain=$_domain&selected_menu=edittxt&command=add_txt&subname=$_sub_domain&new_txt=$domain_txt" "https://kr.dnsever.com/start.html") response=$(_post "skey=$skey&user_domain=$_domain&selected_menu=edittxt&command=add_txt&subname=$_sub_domain&new_txt=$domain_txt" "https://kr.dnsever.com/start.html")
result=$? result=$?
if [ $result != 0 ] || [ -z "$response" ]; then if [ $result != 0 ] || [ -z "$response" ]; then
_err "dnsever_txt:$action ERROR failed to add_text $domain_name=$domain_txt" _err "dnsever_txt:$action ERROR failed to add_text $domain_name=$domain_txt"
response=$(_post "skey=$skey" "https://kr.dnsever.com/logout.php") response=$(_post "skey=$skey" "https://kr.dnsever.com/logout.php")
fi fi
elif [ "$action" = "del" ]; then elif [ "$action" = "del" ]; then
#https://kr.dnsever.com/start.html?user_domain=flywithu.com&selected_menu=edittxt&skey=flywithu:41e3390a9b7aee2cce36c0012bb042b6 #https://kr.dnsever.com/start.html?user_domain=flywithu.com&selected_menu=edittxt&skey=flywithu:41e3390a9b7aee2cce36c0012bb042b6
response=$(_post "skey=$skey&user_domain=$_domain&selected_menu=edittxt" "https://kr.dnsever.com/start.html") response=$(_post "skey=$skey&user_domain=$_domain&selected_menu=edittxt" "https://kr.dnsever.com/start.html")
# _debug2 "response" "$response" |cut -d\" -f1 # _debug2 "response" "$response" |cut -d\" -f1
seq_1=$(printf "%s\n" "$response" | _egrep_o "name=\"seq_1\" value=\".+\"" | cut -f3 -d= | tr -d \") seq_1=$(printf "%s\n" "$response" | _egrep_o "name=\"seq_1\" value=\".+\"" | cut -f3 -d= | tr -d \")
response=$(_post "skey=$skey&user_domain=$_domain&selected_menu=edittxt&command=delete_txt&domain_for_txt_1=$domain_name&old_txt_1=$domain_txt&txt_1=$domain_txt&check[]=1&seq_1=$seq_1&subname=&new_txt=" "https://kr.dnsever.com/start.html") response=$(_post "skey=$skey&user_domain=$_domain&selected_menu=edittxt&command=delete_txt&domain_for_txt_1=$domain_name&old_txt_1=$domain_txt&txt_1=$domain_txt&check[]=1&seq_1=$seq_1&subname=&new_txt=" "https://kr.dnsever.com/start.html")
result=$? result=$?
if [ $result != 0 ] || [ -z "$response" ]; then if [ $result != 0 ] || [ -z "$response" ]; then
_err "dnsever_txt:$action ERROR failed to delete $domain_name=$domain_txt from DNSEver" _err "dnsever_txt:$action ERROR failed to delete $domain_name=$domain_txt from DNSEver"
response=$(_post "skey=$skey" "https://kr.dnsever.com/logout.php") response=$(_post "skey=$skey" "https://kr.dnsever.com/logout.php")
return 1 return 1
fi fi
fi fi
return 0 return 0
} }