mirror of
https://github.com/plantroon/acme.sh.git
synced 2024-12-23 05:31:42 +00:00
fix shellcheck warnings
This commit is contained in:
parent
d5ec5f80ff
commit
ca7202eb0a
60
acme.sh
60
acme.sh
@ -2195,7 +2195,7 @@ registeraccount() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__calcAccountKeyHash() {
|
__calcAccountKeyHash() {
|
||||||
[ -f "$ACCOUNT_KEY_PATH" ] && cat "$ACCOUNT_KEY_PATH" | _digest sha256
|
[ -f "$ACCOUNT_KEY_PATH" ] && _digest sha256 <"$ACCOUNT_KEY_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
#keylength
|
#keylength
|
||||||
@ -2244,7 +2244,7 @@ _regAccount() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$code" = "" ] || [ "$code" = '201' ]; then
|
if [ "$code" = "" ] || [ "$code" = '201' ]; then
|
||||||
echo "$response" >$ACCOUNT_JSON_PATH
|
echo "$response" >"$ACCOUNT_JSON_PATH"
|
||||||
_info "Registered"
|
_info "Registered"
|
||||||
elif [ "$code" = '409' ]; then
|
elif [ "$code" = '409' ]; then
|
||||||
_info "Already registered"
|
_info "Already registered"
|
||||||
@ -2384,7 +2384,7 @@ issue() {
|
|||||||
_debug "Using api: $API"
|
_debug "Using api: $API"
|
||||||
|
|
||||||
if [ ! "$IS_RENEW" ]; then
|
if [ ! "$IS_RENEW" ]; then
|
||||||
_initpath $Le_Domain "$Le_Keylength"
|
_initpath "$Le_Domain" "$Le_Keylength"
|
||||||
mkdir -p "$DOMAIN_PATH"
|
mkdir -p "$DOMAIN_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2455,7 +2455,7 @@ issue() {
|
|||||||
_key=$(_readdomainconf Le_Keylength)
|
_key=$(_readdomainconf Le_Keylength)
|
||||||
_debug "Read key length:$_key"
|
_debug "Read key length:$_key"
|
||||||
if [ ! -f "$CERT_KEY_PATH" ] || [ "$Le_Keylength" != "$_key" ]; then
|
if [ ! -f "$CERT_KEY_PATH" ] || [ "$Le_Keylength" != "$_key" ]; then
|
||||||
if ! createDomainKey $Le_Domain $Le_Keylength; then
|
if ! createDomainKey "$Le_Domain" "$Le_Keylength"; then
|
||||||
_err "Create domain key error."
|
_err "Create domain key error."
|
||||||
_clearup
|
_clearup
|
||||||
_on_issue_err
|
_on_issue_err
|
||||||
@ -2482,7 +2482,7 @@ issue() {
|
|||||||
_index=1
|
_index=1
|
||||||
_currentRoot=""
|
_currentRoot=""
|
||||||
for d in $alldomains; do
|
for d in $alldomains; do
|
||||||
_info "Getting webroot for domain" $d
|
_info "Getting webroot for domain" "$d"
|
||||||
_w="$(echo $Le_Webroot | cut -d , -f $_index)"
|
_w="$(echo $Le_Webroot | cut -d , -f $_index)"
|
||||||
_info _w "$_w"
|
_info _w "$_w"
|
||||||
if [ "$_w" ]; then
|
if [ "$_w" ]; then
|
||||||
@ -2520,17 +2520,17 @@ issue() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
token="$(printf "%s\n" "$entry" | _egrep_o '"token":"[^"]*' | cut -d : -f 2 | tr -d '"')"
|
token="$(printf "%s\n" "$entry" | _egrep_o '"token":"[^"]*' | cut -d : -f 2 | tr -d '"')"
|
||||||
_debug token $token
|
_debug token "$token"
|
||||||
|
|
||||||
uri="$(printf "%s\n" "$entry" | _egrep_o '"uri":"[^"]*' | cut -d : -f 2,3 | tr -d '"')"
|
uri="$(printf "%s\n" "$entry" | _egrep_o '"uri":"[^"]*' | cut -d : -f 2,3 | tr -d '"')"
|
||||||
_debug uri $uri
|
_debug uri "$uri"
|
||||||
|
|
||||||
keyauthorization="$token.$thumbprint"
|
keyauthorization="$token.$thumbprint"
|
||||||
_debug keyauthorization "$keyauthorization"
|
_debug keyauthorization "$keyauthorization"
|
||||||
|
|
||||||
if printf "%s" "$response" | grep '"status":"valid"' >/dev/null 2>&1; then
|
if printf "%s" "$response" | grep '"status":"valid"' >/dev/null 2>&1; then
|
||||||
_info "$d is already verified, skip."
|
_info "$d is already verified, skip."
|
||||||
keyauthorization=$STATE_VERIFIED
|
keyauthorization="$STATE_VERIFIED"
|
||||||
_debug keyauthorization "$keyauthorization"
|
_debug keyauthorization "$keyauthorization"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -2545,10 +2545,10 @@ issue() {
|
|||||||
dnsadded=""
|
dnsadded=""
|
||||||
ventries=$(echo "$vlist" | tr ',' ' ')
|
ventries=$(echo "$vlist" | tr ',' ' ')
|
||||||
for ventry in $ventries; do
|
for ventry in $ventries; do
|
||||||
d=$(echo $ventry | cut -d $sep -f 1)
|
d=$(echo "$ventry" | cut -d "$sep" -f 1)
|
||||||
keyauthorization=$(echo $ventry | cut -d $sep -f 2)
|
keyauthorization=$(echo "$ventry" | cut -d "$sep" -f 2)
|
||||||
vtype=$(echo $ventry | cut -d $sep -f 4)
|
vtype=$(echo "$ventry" | cut -d "$sep" -f 4)
|
||||||
_currentRoot=$(echo $ventry | cut -d $sep -f 5)
|
_currentRoot=$(echo "$ventry" | cut -d "$sep" -f 5)
|
||||||
|
|
||||||
if [ "$keyauthorization" = "$STATE_VERIFIED" ]; then
|
if [ "$keyauthorization" = "$STATE_VERIFIED" ]; then
|
||||||
_info "$d is already verified, skip $vtype."
|
_info "$d is already verified, skip $vtype."
|
||||||
@ -2578,18 +2578,18 @@ issue() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
if ! . $d_api; then
|
if ! . "$d_api"; then
|
||||||
_err "Load file $d_api error. Please check your api file and try again."
|
_err "Load file $d_api error. Please check your api file and try again."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
addcommand="${_currentRoot}_add"
|
addcommand="${_currentRoot}_add"
|
||||||
if ! _exists $addcommand; then
|
if ! _exists "$addcommand"; then
|
||||||
_err "It seems that your api file is not correct, it must have a function named: $addcommand"
|
_err "It seems that your api file is not correct, it must have a function named: $addcommand"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $addcommand $txtdomain $txt; then
|
if ! $addcommand "$txtdomain" "$txt"; then
|
||||||
_err "Error add txt for domain:$txtdomain"
|
_err "Error add txt for domain:$txtdomain"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -2617,13 +2617,13 @@ issue() {
|
|||||||
|
|
||||||
if [ "$dnsadded" = '1' ]; then
|
if [ "$dnsadded" = '1' ]; then
|
||||||
if [ -z "$Le_DNSSleep" ]; then
|
if [ -z "$Le_DNSSleep" ]; then
|
||||||
Le_DNSSleep=$DEFAULT_DNS_SLEEP
|
Le_DNSSleep="$DEFAULT_DNS_SLEEP"
|
||||||
else
|
else
|
||||||
_savedomainconf "Le_DNSSleep" "$Le_DNSSleep"
|
_savedomainconf "Le_DNSSleep" "$Le_DNSSleep"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_info "Sleep $(__green $Le_DNSSleep) seconds for the txt records to take effect"
|
_info "Sleep $(__green $Le_DNSSleep) seconds for the txt records to take effect"
|
||||||
_sleep $Le_DNSSleep
|
_sleep "$Le_DNSSleep"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_debug "ok, let's start to verify"
|
_debug "ok, let's start to verify"
|
||||||
@ -2631,11 +2631,11 @@ issue() {
|
|||||||
_ncIndex=1
|
_ncIndex=1
|
||||||
ventries=$(echo "$vlist" | tr ',' ' ')
|
ventries=$(echo "$vlist" | tr ',' ' ')
|
||||||
for ventry in $ventries; do
|
for ventry in $ventries; do
|
||||||
d=$(echo $ventry | cut -d $sep -f 1)
|
d=$(echo "$ventry" | cut -d "$sep" -f 1)
|
||||||
keyauthorization=$(echo $ventry | cut -d $sep -f 2)
|
keyauthorization=$(echo "$ventry" | cut -d "$sep" -f 2)
|
||||||
uri=$(echo $ventry | cut -d $sep -f 3)
|
uri=$(echo "$ventry" | cut -d "$sep" -f 3)
|
||||||
vtype=$(echo $ventry | cut -d $sep -f 4)
|
vtype=$(echo "$ventry" | cut -d "$sep" -f 4)
|
||||||
_currentRoot=$(echo $ventry | cut -d $sep -f 5)
|
_currentRoot=$(echo "$ventry" | cut -d "$sep" -f 5)
|
||||||
|
|
||||||
if [ "$keyauthorization" = "$STATE_VERIFIED" ]; then
|
if [ "$keyauthorization" = "$STATE_VERIFIED" ]; then
|
||||||
_info "$d is already verified, skip $vtype."
|
_info "$d is already verified, skip $vtype."
|
||||||
@ -2664,7 +2664,7 @@ issue() {
|
|||||||
fi
|
fi
|
||||||
serverproc="$!"
|
serverproc="$!"
|
||||||
sleep 1
|
sleep 1
|
||||||
_debug serverproc $serverproc
|
_debug serverproc "$serverproc"
|
||||||
|
|
||||||
else
|
else
|
||||||
if [ "$_currentRoot" = "apache" ]; then
|
if [ "$_currentRoot" = "apache" ]; then
|
||||||
@ -2697,7 +2697,7 @@ issue() {
|
|||||||
if [ ! "$usingApache" ]; then
|
if [ ! "$usingApache" ]; then
|
||||||
if webroot_owner=$(_stat $_currentRoot); then
|
if webroot_owner=$(_stat $_currentRoot); then
|
||||||
_debug "Changing owner/group of .well-known to $webroot_owner"
|
_debug "Changing owner/group of .well-known to $webroot_owner"
|
||||||
chown -R $webroot_owner "$_currentRoot/.well-known"
|
chown -R "$webroot_owner" "$_currentRoot/.well-known"
|
||||||
else
|
else
|
||||||
_debug "not chaning owner/group of webroot"
|
_debug "not chaning owner/group of webroot"
|
||||||
fi
|
fi
|
||||||
@ -2740,7 +2740,7 @@ issue() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! _send_signed_request $uri "{\"resource\": \"challenge\", \"keyAuthorization\": \"$keyauthorization\"}"; then
|
if ! _send_signed_request "$uri" "{\"resource\": \"challenge\", \"keyAuthorization\": \"$keyauthorization\"}"; then
|
||||||
_err "$d:Can not get challenge: $response"
|
_err "$d:Can not get challenge: $response"
|
||||||
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
||||||
_clearup
|
_clearup
|
||||||
@ -2790,7 +2790,7 @@ issue() {
|
|||||||
status=$(echo "$response" | _egrep_o '"status":"[^"]*' | cut -d : -f 2 | tr -d '"')
|
status=$(echo "$response" | _egrep_o '"status":"[^"]*' | cut -d : -f 2 | tr -d '"')
|
||||||
if [ "$status" = "valid" ]; then
|
if [ "$status" = "valid" ]; then
|
||||||
_info "Success"
|
_info "Success"
|
||||||
_stopserver $serverproc
|
_stopserver "$serverproc"
|
||||||
serverproc=""
|
serverproc=""
|
||||||
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
|
||||||
break
|
break
|
||||||
@ -2909,7 +2909,7 @@ issue() {
|
|||||||
_savedomainconf "Le_CertCreateTimeStr" "$Le_CertCreateTimeStr"
|
_savedomainconf "Le_CertCreateTimeStr" "$Le_CertCreateTimeStr"
|
||||||
|
|
||||||
if [ -z "$Le_RenewalDays" ] || [ "$Le_RenewalDays" -lt "0" ] || [ "$Le_RenewalDays" -gt "$MAX_RENEW" ]; then
|
if [ -z "$Le_RenewalDays" ] || [ "$Le_RenewalDays" -lt "0" ] || [ "$Le_RenewalDays" -gt "$MAX_RENEW" ]; then
|
||||||
Le_RenewalDays=$MAX_RENEW
|
Le_RenewalDays="$MAX_RENEW"
|
||||||
else
|
else
|
||||||
_savedomainconf "Le_RenewalDays" "$Le_RenewalDays"
|
_savedomainconf "Le_RenewalDays" "$Le_RenewalDays"
|
||||||
fi
|
fi
|
||||||
@ -2934,12 +2934,12 @@ issue() {
|
|||||||
_cleardomainconf Le_Listen_V4
|
_cleardomainconf Le_Listen_V4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
Le_NextRenewTime=$(_math $Le_CertCreateTime + $Le_RenewalDays \* 24 \* 60 \* 60)
|
Le_NextRenewTime=$(_math "$Le_CertCreateTime" + "$Le_RenewalDays" \* 24 \* 60 \* 60)
|
||||||
|
|
||||||
Le_NextRenewTimeStr=$(_time2str $Le_NextRenewTime)
|
Le_NextRenewTimeStr=$(_time2str "$Le_NextRenewTime")
|
||||||
_savedomainconf "Le_NextRenewTimeStr" "$Le_NextRenewTimeStr"
|
_savedomainconf "Le_NextRenewTimeStr" "$Le_NextRenewTimeStr"
|
||||||
|
|
||||||
Le_NextRenewTime=$(_math $Le_NextRenewTime - 86400)
|
Le_NextRenewTime=$(_math "$Le_NextRenewTime" - 86400)
|
||||||
_savedomainconf "Le_NextRenewTime" "$Le_NextRenewTime"
|
_savedomainconf "Le_NextRenewTime" "$Le_NextRenewTime"
|
||||||
|
|
||||||
_on_issue_success
|
_on_issue_success
|
||||||
|
Loading…
Reference in New Issue
Block a user