mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-22 13:11:41 +00:00
remove use while, [[ ]], array
This commit is contained in:
parent
8896642e25
commit
4b6e7e6c37
@ -27,8 +27,8 @@ gcore_cdn_deploy() {
|
|||||||
_debug _cca "$_cca"
|
_debug _cca "$_cca"
|
||||||
_debug _cfullchain "$_cfullchain"
|
_debug _cfullchain "$_cfullchain"
|
||||||
|
|
||||||
_fullchain=$(while read -r line; do printf "%s" "$line\n"; done <"$_cfullchain")
|
_fullchain=$(cat "$_cfullchain" | tr '\n\r' '@#' | sed 's/@/\\n/g;s/#/\\r/g')
|
||||||
_key=$(while read -r line; do printf "%s" "$line\n"; done <"$_ckey")
|
_key=$(cat "$_ckey" | tr '\n\r' '@#' | sed 's/@/\\n/g;s/#/\\r/g')
|
||||||
|
|
||||||
_debug _fullchain "$_fullchain"
|
_debug _fullchain "$_fullchain"
|
||||||
_debug _key "$_key"
|
_debug _key "$_key"
|
||||||
@ -64,9 +64,9 @@ gcore_cdn_deploy() {
|
|||||||
export _H1="Content-Type:application/json"
|
export _H1="Content-Type:application/json"
|
||||||
_response=$(_post "$_request" "https://api.gcdn.co/auth/signin")
|
_response=$(_post "$_request" "https://api.gcdn.co/auth/signin")
|
||||||
_debug _response "$_response"
|
_debug _response "$_response"
|
||||||
_regex="\"token\":\"([^\"]+)\""
|
_regex=".*\"token\":\"\([-._0-9A-Za-z]*\)\".*$"
|
||||||
_debug _regex "$_regex"
|
_debug _regex "$_regex"
|
||||||
_token=$(if [[ $_response =~ $_regex ]]; then printf "%s" "${BASH_REMATCH[1]}"; fi)
|
_token=$(echo "$_response" | sed -n "s/$_regex/\1/p")
|
||||||
_debug _token "$_token"
|
_debug _token "$_token"
|
||||||
|
|
||||||
if [ -z "$_token" ]; then
|
if [ -z "$_token" ]; then
|
||||||
@ -79,20 +79,21 @@ gcore_cdn_deploy() {
|
|||||||
_response=$(_get "https://api.gcdn.co/resources")
|
_response=$(_get "https://api.gcdn.co/resources")
|
||||||
_debug _response "$_response"
|
_debug _response "$_response"
|
||||||
_regex=".*(\"id\".*?\"cname\":\"$_cdomain\".*?})"
|
_regex=".*(\"id\".*?\"cname\":\"$_cdomain\".*?})"
|
||||||
|
_regex="\"cname\":\"$_cdomain\""
|
||||||
_debug _regex "$_regex"
|
_debug _regex "$_regex"
|
||||||
_resource=$(if [[ $_response =~ $_regex ]]; then printf "%s" "${BASH_REMATCH[1]}"; fi)
|
_resource=$(echo "$_response" | sed 's/},{/},\n{/g' | grep -E "$_regex")
|
||||||
_debug _resource "$_resource"
|
_debug _resource "$_resource"
|
||||||
_regex="\"id\":([0-9]+)"
|
_regex=".*\"id\":\([0-9]*\),.*$"
|
||||||
_debug _regex "$_regex"
|
_debug _regex "$_regex"
|
||||||
_resourceId=$(if [[ $_resource =~ $_regex ]]; then printf "%s" "${BASH_REMATCH[1]}"; fi)
|
_resourceId=$(echo "$_resource" | sed -n "s/$_regex/\1/p")
|
||||||
_debug _resourceId "$_resourceId"
|
_debug _resourceId "$_resourceId"
|
||||||
_regex="\"sslData\":([0-9]+|null)"
|
_regex=".*\"sslData\":\([0-9]*\)}.*$"
|
||||||
_debug _regex "$_regex"
|
_debug _regex "$_regex"
|
||||||
_sslDataOld=$(if [[ $_resource =~ $_regex ]]; then printf "%s" "${BASH_REMATCH[1]}"; fi)
|
_sslDataOld=$(echo "$_resource" | sed -n "s/$_regex/\1/p")
|
||||||
_debug _sslDataOld "$_sslDataOld"
|
_debug _sslDataOld "$_sslDataOld"
|
||||||
_regex="\"originGroup\":([0-9]+)"
|
_regex=".*\"originGroup\":\([0-9]*\),.*$"
|
||||||
_debug _regex "$_regex"
|
_debug _regex "$_regex"
|
||||||
_originGroup=$(if [[ $_resource =~ $_regex ]]; then printf "%s" "${BASH_REMATCH[1]}"; fi)
|
_originGroup=$(echo "$_resource" | sed -n "s/$_regex/\1/p")
|
||||||
_debug _originGroup "$_originGroup"
|
_debug _originGroup "$_originGroup"
|
||||||
|
|
||||||
if [ -z "$_resourceId" ] || [ -z "$_originGroup" ]; then
|
if [ -z "$_resourceId" ] || [ -z "$_originGroup" ]; then
|
||||||
@ -106,9 +107,9 @@ gcore_cdn_deploy() {
|
|||||||
_debug _request "$_request"
|
_debug _request "$_request"
|
||||||
_response=$(_post "$_request" "https://api.gcdn.co/sslData")
|
_response=$(_post "$_request" "https://api.gcdn.co/sslData")
|
||||||
_debug _response "$_response"
|
_debug _response "$_response"
|
||||||
_regex="\"id\":([0-9]+)"
|
_regex=".*\"id\":\([0-9]*\),.*$"
|
||||||
_debug _regex "$_regex"
|
_debug _regex "$_regex"
|
||||||
_sslDataAdd=$(if [[ $_response =~ $_regex ]]; then printf "%s" "${BASH_REMATCH[1]}"; fi)
|
_sslDataAdd=$(echo "$_response" | sed -n "s/$_regex/\1/p")
|
||||||
_debug _sslDataAdd "$_sslDataAdd"
|
_debug _sslDataAdd "$_sslDataAdd"
|
||||||
|
|
||||||
if [ -z "$_sslDataAdd" ]; then
|
if [ -z "$_sslDataAdd" ]; then
|
||||||
@ -121,9 +122,9 @@ gcore_cdn_deploy() {
|
|||||||
_debug _request "$_request"
|
_debug _request "$_request"
|
||||||
_response=$(_post "$_request" "https://api.gcdn.co/resources/$_resourceId" '' "PUT")
|
_response=$(_post "$_request" "https://api.gcdn.co/resources/$_resourceId" '' "PUT")
|
||||||
_debug _response "$_response"
|
_debug _response "$_response"
|
||||||
_regex="\"sslData\":([0-9]+)"
|
_regex=".*\"sslData\":\([0-9]*\)}.*$"
|
||||||
_debug _regex "$_regex"
|
_debug _regex "$_regex"
|
||||||
_sslDataNew=$(if [[ $_response =~ $_regex ]]; then printf "%s" "${BASH_REMATCH[1]}"; fi)
|
_sslDataNew=$(echo "$_response" | sed -n "s/$_regex/\1/p")
|
||||||
_debug _sslDataNew "$_sslDataNew"
|
_debug _sslDataNew "$_sslDataNew"
|
||||||
|
|
||||||
if [ "$_sslDataNew" != "$_sslDataAdd" ]; then
|
if [ "$_sslDataNew" != "$_sslDataAdd" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user