From e591d5cfe4a9a990adbce3a194771a9b9ee113f5 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 21:13:33 +0800 Subject: [PATCH 01/31] fix shellcheck warnings --- acme.sh | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/acme.sh b/acme.sh index e4c377d..255c609 100755 --- a/acme.sh +++ b/acme.sh @@ -27,7 +27,7 @@ STAGE_CA="https://acme-staging.api.letsencrypt.org" VTYPE_HTTP="http-01" VTYPE_DNS="dns-01" VTYPE_TLS="tls-sni-01" -VTYPE_TLS2="tls-sni-02" +#VTYPE_TLS2="tls-sni-02" LOCAL_ANY_ADDRESS="0.0.0.0" @@ -247,10 +247,10 @@ _exists() { _usage "Usage: _exists cmd" return 1 fi - if type command >/dev/null 2>&1; then + if command >/dev/null 2>&1; then command -v "$cmd" >/dev/null 2>&1 - else - type "$cmd" >/dev/null 2>&1 + else which >/dev/null 2>&1; + which "$cmd" >/dev/null 2>&1 fi ret="$?" _debug3 "$cmd exists=$ret" @@ -259,7 +259,7 @@ _exists() { #a + b _math() { - expr "$@" + $(( "$@" )) } _h_char_2_dec() { @@ -299,10 +299,7 @@ _h2b() { hex=$(cat) i=1 j=2 - if _exists let; then - uselet="1" - fi - _debug3 uselet "$uselet" + _debug3 _URGLY_PRINTF "$_URGLY_PRINTF" while true; do if [ -z "$_URGLY_PRINTF" ]; then @@ -310,7 +307,7 @@ _h2b() { if [ -z "$h" ]; then break fi - printf "\x$h" + printf "\x$h%s" else ic="$(printf "%s" "$hex" | cut -c $i)" jc="$(printf "%s" "$hex" | cut -c $j)" @@ -321,13 +318,10 @@ _h2b() { jc="$(_h_char_2_dec "$jc")" printf '\'"$(printf "%o" "$(_math "$ic" \* 16 + $jc)")" fi - if [ "$uselet" ]; then - let "i+=2" >/dev/null - let "j+=2" >/dev/null - else - i="$(_math "$i" + 2)" - j="$(_math "$j" + 2)" - fi + + i="$(_math "$i" + 2)" + j="$(_math "$j" + 2)" + done } @@ -3006,9 +3000,9 @@ renewAll() { _debug "_stopRenewOnError" "$_stopRenewOnError" _ret="0" - for d in "${CERT_HOME}"/*.*/; do - _debug d "$d" - d=$(basename "$d") + for di in "${CERT_HOME}"/*.*/; do + _debug di "$di" + d=$(basename "$di") _debug d "$d" ( if _endswith "$d" "$ECC_SUFFIX"; then @@ -3129,15 +3123,15 @@ list() { _sep="|" if [ "$_raw" ]; then printf "%s\n" "Main_Domain${_sep}KeyLength${_sep}SAN_Domains${_sep}Created${_sep}Renew" - for d in "${CERT_HOME}"/*.*/; do - d=$(basename "$d") + for di in "${CERT_HOME}"/*.*/; do + d=$(basename "$di") _debug d "$d" ( if _endswith "$d" "$ECC_SUFFIX"; then _isEcc=$(echo "$d" | cut -d "$ECC_SEP" -f 2) d=$(echo "$d" | cut -d "$ECC_SEP" -f 1) fi - _initpath $d "$_isEcc" + _initpath "$d" "$_isEcc" if [ -f "$DOMAIN_CONF" ]; then . "$DOMAIN_CONF" printf "%s\n" "$Le_Domain${_sep}\"$Le_Keylength\"${_sep}$Le_Alt${_sep}$Le_CertCreateTimeStr${_sep}$Le_NextRenewTimeStr" @@ -3163,13 +3157,13 @@ deploy() { return 1 fi - _initpath $Le_Domain "$_isEcc" + _initpath "$Le_Domain" "$_isEcc" if [ ! -d "$DOMAIN_PATH" ]; then _err "Domain is not valid:'$Le_Domain'" return 1 fi - _deployApi="$(_findHook $Le_Domain deploy $Le_DeployHook)" + _deployApi="$(_findHook "$Le_Domain" deploy "$Le_DeployHook")" if [ -z "$_deployApi" ]; then _err "The deploy hook $Le_DeployHook is not found." return 1 @@ -3179,18 +3173,18 @@ deploy() { _savedomainconf Le_DeployHook "$Le_DeployHook" if ! ( - if ! . $_deployApi; then + if ! . "$_deployApi"; then _err "Load file $_deployApi error. Please check your api file and try again." return 1 fi d_command="${Le_DeployHook}_deploy" - if ! _exists $d_command; then + if ! _exists "$d_command"; then _err "It seems that your api file is not correct, it must have a function named: $d_command" return 1 fi - if ! $d_command $Le_Domain "$CERT_KEY_PATH" "$CERT_PATH" "$CA_CERT_PATH" "$CERT_FULLCHAIN_PATH"; then + if ! $d_command "$Le_Domain" "$CERT_KEY_PATH" "$CERT_PATH" "$CA_CERT_PATH" "$CERT_FULLCHAIN_PATH"; then _err "Error deploy for domain:$Le_Domain" _on_issue_err return 1 From e3698edd1952b7777d7b2c438cd6ac6f3ee25fb5 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 21:15:48 +0800 Subject: [PATCH 02/31] fix shellcheck warnings --- acme.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acme.sh b/acme.sh index 255c609..ed2bf90 100755 --- a/acme.sh +++ b/acme.sh @@ -4046,7 +4046,7 @@ _process() { _dnssleep="" _listraw="" _stopRenewOnError="" - _insecure="" + #_insecure="" _ca_bundle="" _nocron="" _ecc="" @@ -4321,7 +4321,7 @@ _process() { _stopRenewOnError="1" ;; --insecure) - _insecure="1" + #_insecure="1" HTTPS_INSECURE="1" ;; --ca-bundle) From c4a375b3a5288b5abbb0ff73ad9b06d32f492565 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 21:22:48 +0800 Subject: [PATCH 03/31] fix shellcheck warnings. --- acme.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/acme.sh b/acme.sh index ed2bf90..79afb23 100755 --- a/acme.sh +++ b/acme.sh @@ -3364,7 +3364,7 @@ revoke() { _isEcc="$2" - _initpath $Le_Domain "$_isEcc" + _initpath "$Le_Domain" "$_isEcc" if [ ! -f "$DOMAIN_CONF" ]; then _err "$Le_Domain is not a issued domain, skip." return 1 @@ -3387,10 +3387,10 @@ revoke() { if [ -f "$CERT_KEY_PATH" ]; then _info "Try domain key first." - if _send_signed_request $uri "$data" "" "$CERT_KEY_PATH"; then + if _send_signed_request "$uri" "$data" "" "$CERT_KEY_PATH"; then if [ -z "$response" ]; then _info "Revoke success." - rm -f $CERT_PATH + rm -f "$CERT_PATH" return 0 else _err "Revoke error by domain key." @@ -3403,10 +3403,10 @@ revoke() { _info "Try account key." - if _send_signed_request $uri "$data" "" "$ACCOUNT_KEY_PATH"; then + if _send_signed_request "$uri" "$data" "" "$ACCOUNT_KEY_PATH"; then if [ -z "$response" ]; then _info "Revoke success." - rm -f $CERT_PATH + rm -f "$CERT_PATH" return 0 else _err "Revoke error." @@ -3450,11 +3450,11 @@ _deactivate() { fi _vtype="$(printf "%s\n" "$entry" | _egrep_o '"type": *"[^"]*"' | cut -d : -f 2 | tr -d '"')" - _debug _vtype $_vtype + _debug _vtype "$_vtype" _info "Found $_vtype" uri="$(printf "%s\n" "$entry" | _egrep_o '"uri":"[^"]*' | cut -d : -f 2,3 | tr -d '"')" - _debug uri $uri + _debug uri "$uri" if [ "$_d_type" ] && [ "$_d_type" != "$_vtype" ]; then _info "Skip $_vtype" @@ -3493,7 +3493,7 @@ deactivate() { if [ -z "$_d_dm" ] || [ "$_d_dm" = "$NO_VALUE" ]; then continue fi - if ! _deactivate "$_d_dm" $_d_type; then + if ! _deactivate "$_d_dm" "$_d_type"; then return 1 fi done @@ -3562,7 +3562,7 @@ _initconf() { #USER_AGENT=\"$USER_AGENT\" -#USER_PATH="" +#USER_PATH= #dns api ####################### From 7ff7a7c527ca9aa6c02d7722717ede9dd8e50b37 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 21:31:16 +0800 Subject: [PATCH 04/31] fix shellcheck warnning --- acme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index 79afb23..705f5a9 100755 --- a/acme.sh +++ b/acme.sh @@ -259,7 +259,7 @@ _exists() { #a + b _math() { - $(( "$@" )) + printf "%s" "$(( $@ ))" } _h_char_2_dec() { From 4bd31f4967fcd637087cbc423b650f9d8eb3a557 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 21:47:24 +0800 Subject: [PATCH 05/31] fix shellcheck warnings --- acme.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/acme.sh b/acme.sh index 705f5a9..d050738 100755 --- a/acme.sh +++ b/acme.sh @@ -3212,7 +3212,7 @@ installcert() { Le_RealFullChainPath="$6" _isEcc="$7" - _initpath $Le_Domain "$_isEcc" + _initpath "$Le_Domain" "$_isEcc" if [ ! -d "$DOMAIN_PATH" ]; then _err "Domain is not valid:'$Le_Domain'" return 1 @@ -3245,9 +3245,9 @@ _installcert() { Le_RealFullChainPath="" fi - _installed="0" + if [ "$Le_RealCertPath" ]; then - _installed=1 + _info "Installing cert to:$Le_RealCertPath" if [ -f "$Le_RealCertPath" ] && [ ! "$IS_RENEW" ]; then cp "$Le_RealCertPath" "$Le_RealCertPath".bak @@ -3256,7 +3256,7 @@ _installcert() { fi if [ "$Le_RealCACertPath" ]; then - _installed=1 + _info "Installing CA to:$Le_RealCACertPath" if [ "$Le_RealCACertPath" = "$Le_RealCertPath" ]; then echo "" >>"$Le_RealCACertPath" @@ -3270,7 +3270,7 @@ _installcert() { fi if [ "$Le_RealKeyPath" ]; then - _installed=1 + _info "Installing key to:$Le_RealKeyPath" if [ -f "$Le_RealKeyPath" ] && [ ! "$IS_RENEW" ]; then cp "$Le_RealKeyPath" "$Le_RealKeyPath".bak @@ -3279,7 +3279,7 @@ _installcert() { fi if [ "$Le_RealFullChainPath" ]; then - _installed=1 + _info "Installing full chain to:$Le_RealFullChainPath" if [ -f "$Le_RealFullChainPath" ] && [ ! "$IS_RENEW" ]; then cp "$Le_RealFullChainPath" "$Le_RealFullChainPath".bak @@ -3288,7 +3288,7 @@ _installcert() { fi if [ "$Le_ReloadCmd" ]; then - _installed=1 + _info "Run Le_ReloadCmd: $Le_ReloadCmd" if (cd "$DOMAIN_PATH" && eval "$Le_ReloadCmd"); then _info "$(__green "Reload success")" From e51bef6d12c4d80babbd6d24fcaef8dca7b3bbf4 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 22:00:15 +0800 Subject: [PATCH 06/31] fix shellcheck warnings. --- acme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index d050738..5a42595 100755 --- a/acme.sh +++ b/acme.sh @@ -316,7 +316,7 @@ _h2b() { fi ic="$(_h_char_2_dec "$ic")" jc="$(_h_char_2_dec "$jc")" - printf '\'"$(printf "%o" "$(_math "$ic" \* 16 + $jc)")" + printf '\'"$(printf "%o" "$(_math "$ic" \* 16 + $jc)")""%s" fi i="$(_math "$i" + 2)" From b97e1403891ac9f38911bea9baf8c77f6d12c502 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 22:07:49 +0800 Subject: [PATCH 07/31] fix shfmt warnings --- acme.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acme.sh b/acme.sh index 5a42595..bd61d11 100755 --- a/acme.sh +++ b/acme.sh @@ -249,7 +249,7 @@ _exists() { fi if command >/dev/null 2>&1; then command -v "$cmd" >/dev/null 2>&1 - else which >/dev/null 2>&1; + elif which >/dev/null 2>&1; which "$cmd" >/dev/null 2>&1 fi ret="$?" @@ -259,7 +259,7 @@ _exists() { #a + b _math() { - printf "%s" "$(( $@ ))" + printf "%s" "$(($@))" } _h_char_2_dec() { From a8b564fa648a0cafae32c7948ae7167a583e86a1 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 22:10:14 +0800 Subject: [PATCH 08/31] typo --- acme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index bd61d11..f861ace 100755 --- a/acme.sh +++ b/acme.sh @@ -249,7 +249,7 @@ _exists() { fi if command >/dev/null 2>&1; then command -v "$cmd" >/dev/null 2>&1 - elif which >/dev/null 2>&1; + elif which >/dev/null 2>&1; then which "$cmd" >/dev/null 2>&1 fi ret="$?" From a988a91e2eb7e3d9ef81924bc14f7bd6ab36b186 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 22:14:21 +0800 Subject: [PATCH 09/31] fix shfmt warnings --- acme.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/acme.sh b/acme.sh index f861ace..4a5b111 100755 --- a/acme.sh +++ b/acme.sh @@ -3222,7 +3222,6 @@ installcert() { } _installcert() { - _savedomainconf "Le_RealCertPath" "$Le_RealCertPath" _savedomainconf "Le_RealCACertPath" "$Le_RealCACertPath" _savedomainconf "Le_RealKeyPath" "$Le_RealKeyPath" @@ -3245,7 +3244,6 @@ _installcert() { Le_RealFullChainPath="" fi - if [ "$Le_RealCertPath" ]; then _info "Installing cert to:$Le_RealCertPath" From 7af784adce32592a2758b3e72d1eebb89e1dd7ae Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 22:30:55 +0800 Subject: [PATCH 10/31] fix shellcheck warnings --- acme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index 4a5b111..c5e0926 100755 --- a/acme.sh +++ b/acme.sh @@ -548,7 +548,7 @@ _createkey() { _is_idn() { _is_idn_d="$1" _debug2 _is_idn_d "$_is_idn_d" - _idn_temp=$(printf "%s" "$_is_idn_d" | tr -d '[0-9]' | tr -d '[a-z]' | tr -d 'A-Z' | tr -d '.,-') + _idn_temp=$(printf "%s" "$_is_idn_d" | tr -d '0-9' | tr -d 'a-z' | tr -d 'A-Z' | tr -d '.,-') _debug2 _idn_temp "$_idn_temp" [ "$_idn_temp" ] } From 796e2cc1562a856ba9909be018d5da8b8711a202 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 22:32:11 +0800 Subject: [PATCH 11/31] fix shellcheck warnings --- acme.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acme.sh b/acme.sh index c5e0926..29f0881 100755 --- a/acme.sh +++ b/acme.sh @@ -532,10 +532,10 @@ _createkey() { if _isEccKey "$length"; then _debug "Using ec name: $eccname" - openssl ecparam -name $eccname -genkey 2>/dev/null >"$f" + openssl ecparam -name "$eccname" -genkey 2>/dev/null >"$f" else _debug "Using RSA: $length" - openssl genrsa $length 2>/dev/null >"$f" + openssl genrsa "$length" 2>/dev/null >"$f" fi if [ "$?" != "0" ]; then From 031e885e4de0b684e6d0df5ef686540c5181c0d6 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 22:36:16 +0800 Subject: [PATCH 12/31] fix shellcheck warnings --- acme.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index 29f0881..f8c7e17 100755 --- a/acme.sh +++ b/acme.sh @@ -859,7 +859,8 @@ _time2str() { #Soaris if _exists adb; then - echo $(echo "0t${1}=Y" | adb) + _t_s_a=$(echo "0t${1}=Y" | adb) + echo "$_t_s_a" fi } From c7b16249b88f682fed44f84ef772625bb69b0eba Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 23:30:14 +0800 Subject: [PATCH 13/31] fix shellcheck warnings --- acme.sh | 10 ++++----- dnsapi/dns_cf.sh | 22 ++++++++++---------- dnsapi/dns_cx.sh | 40 ++++++++++++++++++------------------ dnsapi/dns_dp.sh | 48 +++++++++++++++++++++---------------------- dnsapi/dns_gd.sh | 14 ++++++------- dnsapi/dns_lexicon.sh | 12 +++++------ dnsapi/dns_lua.sh | 20 +++++++++--------- dnsapi/dns_me.sh | 22 ++++++++++---------- dnsapi/dns_ovh.sh | 12 +++++------ dnsapi/dns_pdns.sh | 16 +++++++-------- 10 files changed, 108 insertions(+), 108 deletions(-) diff --git a/acme.sh b/acme.sh index f8c7e17..195adee 100755 --- a/acme.sh +++ b/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 diff --git a/dnsapi/dns_cf.sh b/dnsapi/dns_cf.sh index 63acb28..edd4830 100755 --- a/dnsapi/dns_cf.sh +++ b/dnsapi/dns_cf.sh @@ -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 diff --git a/dnsapi/dns_cx.sh b/dnsapi/dns_cx.sh index 81eb896..c4d941d 100755 --- a/dnsapi/dns_cx.sh +++ b/dnsapi/dns_cx.sh @@ -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 diff --git a/dnsapi/dns_dp.sh b/dnsapi/dns_dp.sh index 8861bfc..605c541 100755 --- a/dnsapi/dns_dp.sh +++ b/dnsapi/dns_dp.sh @@ -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 'TXT' | wc -l) - record_id=$(printf "$response" | grep '^' | tail -1 | cut -d '>' -f 2 | cut -d '<' -f 1) + if _contains "$response" "Action completed successful"; then + count=$(printf "%s" "$response" | grep 'TXT' | wc -l) + record_id=$(printf "%s" "$response" | grep '^' | 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 diff --git a/dnsapi/dns_gd.sh b/dnsapi/dns_gd.sh index 51ca8db..304d5d3 100755 --- a/dnsapi/dns_gd.sh +++ b/dnsapi/dns_gd.sh @@ -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" diff --git a/dnsapi/dns_lexicon.sh b/dnsapi/dns_lexicon.sh index 847b999..bceab8d 100755 --- a/dnsapi/dns_lexicon.sh +++ b/dnsapi/dns_lexicon.sh @@ -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}" diff --git a/dnsapi/dns_lua.sh b/dnsapi/dns_lua.sh index efd197c..a6375e5 100755 --- a/dnsapi/dns_lua.sh +++ b/dnsapi/dns_lua.sh @@ -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" diff --git a/dnsapi/dns_me.sh b/dnsapi/dns_me.sh index abc1747..db4f796 100755 --- a/dnsapi/dns_me.sh +++ b/dnsapi/dns_me.sh @@ -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" diff --git a/dnsapi/dns_ovh.sh b/dnsapi/dns_ovh.sh index 782c083..ace5222 100755 --- a/dnsapi/dns_ovh.sh +++ b/dnsapi/dns_ovh.sh @@ -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" diff --git a/dnsapi/dns_pdns.sh b/dnsapi/dns_pdns.sh index ec82bfe..7c994eb 100755 --- a/dnsapi/dns_pdns.sh +++ b/dnsapi/dns_pdns.sh @@ -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 From a0636d5a87e216ecfb033eff320bd5a79a0489de Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 23:34:21 +0800 Subject: [PATCH 14/31] fix shellcheck warnings. --- dnsapi/dns_lexicon.sh | 8 ++++---- dnsapi/dns_lua.sh | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dnsapi/dns_lexicon.sh b/dnsapi/dns_lexicon.sh index bceab8d..4cec7cb 100755 --- a/dnsapi/dns_lexicon.sh +++ b/dnsapi/dns_lexicon.sh @@ -29,7 +29,7 @@ dns_lexicon_add() { _savedomainconf PROVIDER "$PROVIDER" export PROVIDER - Lx_name=$(echo LEXICON_${PROVIDER}_USERNAME | tr [a-z] [A-Z]) + Lx_name=$(echo LEXICON_${PROVIDER}_USERNAME | tr 'a-z' 'A-Z') eval Lx_name_v="\$$Lx_name" _debug "$Lx_name" "$Lx_name_v" if [ "$Lx_name_v" ]; then @@ -37,7 +37,7 @@ dns_lexicon_add() { export "$Lx_name" fi - Lx_token=$(echo LEXICON_${PROVIDER}_TOKEN | tr [a-z] [A-Z]) + Lx_token=$(echo LEXICON_${PROVIDER}_TOKEN | tr 'a-z' 'A-Z') eval Lx_token_v="\$$Lx_token" _debug "$Lx_token" "$Lx_token_v" if [ "$Lx_token_v" ]; then @@ -45,7 +45,7 @@ dns_lexicon_add() { export "$Lx_token" fi - Lx_password=$(echo LEXICON_${PROVIDER}_PASSWORD | tr [a-z] [A-Z]) + Lx_password=$(echo LEXICON_${PROVIDER}_PASSWORD | tr 'a-z' 'A-Z') eval Lx_password_v="\$$Lx_password" _debug "$Lx_password" "$Lx_password_v" if [ "$Lx_password_v" ]; then @@ -53,7 +53,7 @@ dns_lexicon_add() { export "$Lx_password" fi - Lx_domaintoken=$(echo LEXICON_${PROVIDER}_DOMAINTOKEN | tr [a-z] [A-Z]) + Lx_domaintoken=$(echo LEXICON_${PROVIDER}_DOMAINTOKEN | tr 'a-z' 'A-Z') eval Lx_domaintoken_v="\$$Lx_domaintoken" _debug "$Lx_domaintoken" "$Lx_domaintoken_v" if [ "$Lx_domaintoken_v" ]; then diff --git a/dnsapi/dns_lua.sh b/dnsapi/dns_lua.sh index a6375e5..c03686a 100755 --- a/dnsapi/dns_lua.sh +++ b/dnsapi/dns_lua.sh @@ -8,7 +8,7 @@ #LUA_Email="user@luadns.net" LUA_Api="https://api.luadns.com/v1" -LUA_auth=$(printf $LUA_Email:$LUA_Key | _base64) +LUA_auth=$(printf "%s" "$LUA_Email:$LUA_Key" | _base64) ######## Public functions ##################### @@ -39,7 +39,7 @@ dns_lua_add() { _debug "Getting txt records" _LUA_rest GET "zones/${_domain_id}/records" - if ! printf "$response" | grep \"id\": >/dev/null; then + if ! _contains "$response" "\"id\":"; then _err "Error" return 1 fi From c7b8f223ee3cd17c6c95e45bdde47c9129547648 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 23:48:27 +0800 Subject: [PATCH 15/31] fix for solaris tr --- acme.sh | 2 +- dnsapi/dns_lexicon.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/acme.sh b/acme.sh index 195adee..78a6ec6 100755 --- a/acme.sh +++ b/acme.sh @@ -548,7 +548,7 @@ _createkey() { _is_idn() { _is_idn_d="$1" _debug2 _is_idn_d "$_is_idn_d" - _idn_temp=$(printf "%s" "$_is_idn_d" | tr -d '0-9' | tr -d 'a-z' | tr -d 'A-Z' | tr -d '.,-') + _idn_temp=$(printf "%s" "$_is_idn_d" | tr -d '[0-9]' | tr -d '[a-z]' | tr -d '[A-Z]' | tr -d '.,-') _debug2 _idn_temp "$_idn_temp" [ "$_idn_temp" ] } diff --git a/dnsapi/dns_lexicon.sh b/dnsapi/dns_lexicon.sh index 4cec7cb..c3628a0 100755 --- a/dnsapi/dns_lexicon.sh +++ b/dnsapi/dns_lexicon.sh @@ -29,7 +29,7 @@ dns_lexicon_add() { _savedomainconf PROVIDER "$PROVIDER" export PROVIDER - Lx_name=$(echo LEXICON_${PROVIDER}_USERNAME | tr 'a-z' 'A-Z') + Lx_name=$(echo LEXICON_${PROVIDER}_USERNAME | tr '[a-z]' '[A-Z]') eval Lx_name_v="\$$Lx_name" _debug "$Lx_name" "$Lx_name_v" if [ "$Lx_name_v" ]; then @@ -37,7 +37,7 @@ dns_lexicon_add() { export "$Lx_name" fi - Lx_token=$(echo LEXICON_${PROVIDER}_TOKEN | tr 'a-z' 'A-Z') + Lx_token=$(echo LEXICON_${PROVIDER}_TOKEN | tr '[a-z]' '[A-Z]') eval Lx_token_v="\$$Lx_token" _debug "$Lx_token" "$Lx_token_v" if [ "$Lx_token_v" ]; then @@ -45,7 +45,7 @@ dns_lexicon_add() { export "$Lx_token" fi - Lx_password=$(echo LEXICON_${PROVIDER}_PASSWORD | tr 'a-z' 'A-Z') + Lx_password=$(echo LEXICON_${PROVIDER}_PASSWORD | tr '[a-z]' '[A-Z]') eval Lx_password_v="\$$Lx_password" _debug "$Lx_password" "$Lx_password_v" if [ "$Lx_password_v" ]; then @@ -53,7 +53,7 @@ dns_lexicon_add() { export "$Lx_password" fi - Lx_domaintoken=$(echo LEXICON_${PROVIDER}_DOMAINTOKEN | tr 'a-z' 'A-Z') + Lx_domaintoken=$(echo LEXICON_${PROVIDER}_DOMAINTOKEN | tr '[a-z]' '[A-Z]') eval Lx_domaintoken_v="\$$Lx_domaintoken" _debug "$Lx_domaintoken" "$Lx_domaintoken_v" if [ "$Lx_domaintoken_v" ]; then From efd96153d840672d6893c448412eb24f2b763a09 Mon Sep 17 00:00:00 2001 From: neilpang Date: Fri, 11 Nov 2016 23:52:02 +0800 Subject: [PATCH 16/31] minor fix log message. --- acme.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acme.sh b/acme.sh index 78a6ec6..e49a253 100755 --- a/acme.sh +++ b/acme.sh @@ -2319,7 +2319,7 @@ __get_domain_new_authz() { _Max_new_authz_retry_times=5 _authz_i=0 while [ "$_authz_i" -lt "$_Max_new_authz_retry_times" ]; do - _info "Try new-authz for the $_authz_i time." + _debug "Try new-authz for the $_authz_i time." if ! _send_signed_request "$API/acme/new-authz" "{\"resource\": \"new-authz\", \"identifier\": {\"type\": \"dns\", \"value\": \"$(_idn "$_gdnd")\"}}"; then _err "Can not get domain new authz." return 1 @@ -2334,7 +2334,7 @@ __get_domain_new_authz() { done if [ "$_authz_i" = "$_Max_new_authz_retry_times" ]; then - _debug "new-authz retry reach the max $_Max_new_authz_retry_times times." + _err "new-authz retry reach the max $_Max_new_authz_retry_times times." fi if [ ! -z "$code" ] && [ ! "$code" = '201' ]; then From e9f9f515bdf707e704e33af001378e0bb256d053 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:06:34 +0800 Subject: [PATCH 17/31] fix shellcheck warnings. --- dnsapi/dns_gd.sh | 4 ++-- dnsapi/dns_lexicon.sh | 10 +++++----- dnsapi/dns_lua.sh | 8 ++++---- dnsapi/dns_me.sh | 2 +- dnsapi/dns_ovh.sh | 6 +++--- dnsapi/dns_pdns.sh | 2 -- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/dnsapi/dns_gd.sh b/dnsapi/dns_gd.sh index 304d5d3..dec80a9 100755 --- a/dnsapi/dns_gd.sh +++ b/dnsapi/dns_gd.sh @@ -85,8 +85,8 @@ _get_root() { _domain="$h" return 0 fi - p=$i - i=$(expr $i + 1) + p="$i" + i=$(_math "$i" + 1) done return 1 } diff --git a/dnsapi/dns_lexicon.sh b/dnsapi/dns_lexicon.sh index c3628a0..38b6a13 100755 --- a/dnsapi/dns_lexicon.sh +++ b/dnsapi/dns_lexicon.sh @@ -29,7 +29,7 @@ dns_lexicon_add() { _savedomainconf PROVIDER "$PROVIDER" export PROVIDER - Lx_name=$(echo LEXICON_${PROVIDER}_USERNAME | tr '[a-z]' '[A-Z]') + Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr '[a-z]' '[A-Z]') eval Lx_name_v="\$$Lx_name" _debug "$Lx_name" "$Lx_name_v" if [ "$Lx_name_v" ]; then @@ -37,7 +37,7 @@ dns_lexicon_add() { export "$Lx_name" fi - Lx_token=$(echo LEXICON_${PROVIDER}_TOKEN | tr '[a-z]' '[A-Z]') + Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr '[a-z]' '[A-Z]') eval Lx_token_v="\$$Lx_token" _debug "$Lx_token" "$Lx_token_v" if [ "$Lx_token_v" ]; then @@ -45,7 +45,7 @@ dns_lexicon_add() { export "$Lx_token" fi - Lx_password=$(echo LEXICON_${PROVIDER}_PASSWORD | tr '[a-z]' '[A-Z]') + Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr '[a-z]' '[A-Z]') eval Lx_password_v="\$$Lx_password" _debug "$Lx_password" "$Lx_password_v" if [ "$Lx_password_v" ]; then @@ -53,7 +53,7 @@ dns_lexicon_add() { export "$Lx_password" fi - Lx_domaintoken=$(echo LEXICON_${PROVIDER}_DOMAINTOKEN | tr '[a-z]' '[A-Z]') + Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr '[a-z]' '[A-Z]') eval Lx_domaintoken_v="\$$Lx_domaintoken" _debug "$Lx_domaintoken" "$Lx_domaintoken_v" if [ "$Lx_domaintoken_v" ]; then @@ -61,7 +61,7 @@ dns_lexicon_add() { _saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v" fi - $lexicon_cmd "$PROVIDER" create ${domain} TXT --name="_acme-challenge.${domain}." --content="${txtvalue}" + $lexicon_cmd "$PROVIDER" create "${domain}" TXT --name="_acme-challenge.${domain}." --content="${txtvalue}" } diff --git a/dnsapi/dns_lua.sh b/dnsapi/dns_lua.sh index c03686a..e6b4872 100755 --- a/dnsapi/dns_lua.sh +++ b/dnsapi/dns_lua.sh @@ -44,7 +44,7 @@ dns_lua_add() { return 1 fi - count=$(printf "%s\n" "$response" | _egrep_o \"name\":\"$fulldomain\" | wc -l) + count=$(printf "%s\n" "$response" | _egrep_o "\"name\":\"$fulldomain\"" | wc -l) _debug count "$count" if [ "$count" = "0" ]; then _info "Adding record" @@ -61,7 +61,7 @@ dns_lua_add() { _err "Add txt record error." else _info "Updating record" - record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]*,\"name\":\"$fulldomain.\",\"type\":\"TXT\" | cut -d: -f2 | cut -d, -f1) + record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":[^,]*,\"name\":\"$fulldomain.\",\"type\":\"TXT\"" | cut -d: -f2 | cut -d, -f1) _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}" @@ -103,7 +103,7 @@ _get_root() { fi 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) + _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 "%s" "$domain" | cut -d . -f 1-$p) _domain="$h" @@ -127,7 +127,7 @@ _LUA_rest() { _H2="Authorization: Basic $LUA_auth" if [ "$data" ]; then _debug data "$data" - response="$(_post "$data" "$LUA_Api/$ep" "" $m)" + response="$(_post "$data" "$LUA_Api/$ep" "" "$m")" else response="$(_get "$LUA_Api/$ep")" fi diff --git a/dnsapi/dns_me.sh b/dnsapi/dns_me.sh index db4f796..ba79247 100755 --- a/dnsapi/dns_me.sh +++ b/dnsapi/dns_me.sh @@ -130,7 +130,7 @@ _me_rest() { if [ "$data" ]; then _debug data "$data" - response="$(_post "$data" "$ME_Api/$ep" "" $m)" + response="$(_post "$data" "$ME_Api/$ep" "" "$m")" else response="$(_get "$ME_Api/$ep")" fi diff --git a/dnsapi/dns_ovh.sh b/dnsapi/dns_ovh.sh index ace5222..97730f7 100755 --- a/dnsapi/dns_ovh.sh +++ b/dnsapi/dns_ovh.sh @@ -127,7 +127,7 @@ dns_ovh_add() { _info "Consumer key is ok." _debug "First detect the root zone" - if ! _get_root $fulldomain; then + if ! _get_root "$fulldomain"; then _err "invalid domain" return 1 fi @@ -157,7 +157,7 @@ dns_ovh_add() { _err "Can not get record id." return 1 fi - _debug "record_id" $record_id + _debug "record_id" "$record_id" if _ovh_rest PUT "domain/zone/$_domain/record/$record_id" "{\"target\":\"$txtvalue\",\"subDomain\":\"$_sub_domain\",\"ttl\":60}"; then if _contains "$response" "null"; then @@ -280,7 +280,7 @@ _ovh_rest() { _H5="Content-Type: application/json;charset=utf-8" if [ "$data" ] || [ "$m" = "POST" ] || [ "$m" = "PUT" ]; then _debug data "$data" - response="$(_post "$data" "$_ovh_url" "" $m)" + response="$(_post "$data" "$_ovh_url" "" "$m")" else response="$(_get "$_ovh_url")" fi diff --git a/dnsapi/dns_pdns.sh b/dnsapi/dns_pdns.sh index 7c994eb..0f6c59d 100755 --- a/dnsapi/dns_pdns.sh +++ b/dnsapi/dns_pdns.sh @@ -91,7 +91,6 @@ set_record() { _get_root() { domain=$1 i=1 - p=1 if _pdns_rest "GET" "/api/v1/servers/$PDNS_ServerId/zones"; then _zones_response="$response" @@ -108,7 +107,6 @@ _get_root() { return 0 fi - p=$i i=$(_math $i + 1) done _debug "$domain not found" From 69925ce8230d98d7ea32a543d785a83391985ee9 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:09:45 +0800 Subject: [PATCH 18/31] fix shellcheck warnings. --- dnsapi/dns_cx.sh | 2 +- dnsapi/dns_gd.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dnsapi/dns_cx.sh b/dnsapi/dns_cx.sh index c4d941d..4500374 100755 --- a/dnsapi/dns_cx.sh +++ b/dnsapi/dns_cx.sh @@ -189,7 +189,7 @@ _rest() { _H4="Content-Type: application/json" if [ "$data" ]; then - response="$(_post "$data" "$url" "" $m)" + response="$(_post "$data" "$url" "" "$m")" else response="$(_get "$url")" fi diff --git a/dnsapi/dns_gd.sh b/dnsapi/dns_gd.sh index dec80a9..fed25d8 100755 --- a/dnsapi/dns_gd.sh +++ b/dnsapi/dns_gd.sh @@ -102,7 +102,7 @@ _gd_rest() { if [ "$data" ]; then _debug data "$data" - response="$(_post "$data" "$GD_Api/$ep" "" $m)" + response="$(_post "$data" "$GD_Api/$ep" "" "$m")" else response="$(_get "$GD_Api/$ep")" fi From 432771dfe3c46786a5eaf01f8fa37d811e923c1d Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:19:59 +0800 Subject: [PATCH 19/31] add shellcheck to CI --- .travis.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f363dbe..3c4485b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,19 @@ -language: bash +language: shell env: global: - SHFMT_URL=https://github.com/mvdan/sh/releases/download/v0.4.0/shfmt_v0.4.0_linux_amd64 +addons: + apt: + sources: + - debian-sid # Grab shellcheck from the Debian repo (o_O) + packages: + - shellcheck + script: - curl -sSL $SHFMT_URL -o ~/shfmt - chmod +x ~/shfmt - - ~/shfmt -l -w -i 2 . - - git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && false) + - ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && false) + - [ "$?" = "0" ] && shellcheck -e SC2021,SC2126,SC2034 **/*.sh && echo "shellcheck OK" || false + From 9d6abcd9be975a0286125b1da4da02ccc85d5356 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:23:07 +0800 Subject: [PATCH 20/31] fix CI --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3c4485b..1509979 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,6 @@ addons: script: - curl -sSL $SHFMT_URL -o ~/shfmt - chmod +x ~/shfmt - - ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && false) - - [ "$?" = "0" ] && shellcheck -e SC2021,SC2126,SC2034 **/*.sh && echo "shellcheck OK" || false + - ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && exit 1) + - shellcheck -e SC2021,SC2126,SC2034 **/*.sh && echo "shellcheck OK" || exit 1 From 870274ad9db5f789f20f766326891bb4f51eb190 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:25:15 +0800 Subject: [PATCH 21/31] fix CI --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1509979..cad5a20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ addons: script: - curl -sSL $SHFMT_URL -o ~/shfmt - chmod +x ~/shfmt - - ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && exit 1) - shellcheck -e SC2021,SC2126,SC2034 **/*.sh && echo "shellcheck OK" || exit 1 + - ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && exit 1) + From 5766250288ffdf6c28a8b49069f5720d9b20cdd2 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:31:24 +0800 Subject: [PATCH 22/31] fix CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cad5a20..4c06c2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ addons: script: - curl -sSL $SHFMT_URL -o ~/shfmt - chmod +x ~/shfmt + - shellcheck -V - shellcheck -e SC2021,SC2126,SC2034 **/*.sh && echo "shellcheck OK" || exit 1 - ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && exit 1) From e440223b40998411c80be06286ff88336fbefc03 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:50:44 +0800 Subject: [PATCH 23/31] fix shellcheck warnings --- dnsapi/dns_cf.sh | 6 +++--- dnsapi/dns_cx.sh | 4 ++-- dnsapi/dns_dp.sh | 2 +- dnsapi/dns_gd.sh | 3 +-- dnsapi/dns_me.sh | 6 +++--- dnsapi/dns_ovh.sh | 3 +-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/dnsapi/dns_cf.sh b/dnsapi/dns_cf.sh index edd4830..20cb169 100755 --- a/dnsapi/dns_cf.sh +++ b/dnsapi/dns_cf.sh @@ -41,7 +41,7 @@ dns_cf_add() { return 1 fi - count=$(printf "%s\n" "$response" | _egrep_o \"count\":[^,]* | cut -d : -f 2) + count=$(printf "%s\n" "$response" | _egrep_o "\"count\":[^,]*" | cut -d : -f 2) _debug count "$count" if [ "$count" = "0" ]; then _info "Adding record" @@ -59,7 +59,7 @@ dns_cf_add() { _err "Add txt record error." else _info "Updating record" - record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \" | head -n 1) + record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | head -n 1) _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\"}" @@ -103,7 +103,7 @@ _get_root() { fi 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 \") + _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 "%s" "$domain" | cut -d . -f 1-$p) _domain=$h diff --git a/dnsapi/dns_cx.sh b/dnsapi/dns_cx.sh index 4500374..38649f3 100755 --- a/dnsapi/dns_cx.sh +++ b/dnsapi/dns_cx.sh @@ -80,7 +80,7 @@ existing_records() { 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 \") + record_id=$(printf "%s\n" "$seg" | _egrep_o "\"record_id\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \") _debug record_id "$record_id" return 0 fi @@ -147,7 +147,7 @@ _get_root() { 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 \") + _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 "%s" "$domain" | cut -d . -f 1-$p) diff --git a/dnsapi/dns_dp.sh b/dnsapi/dns_dp.sh index 605c541..a06f157 100755 --- a/dnsapi/dns_dp.sh +++ b/dnsapi/dns_dp.sh @@ -150,7 +150,7 @@ _get_root() { fi if _contains "$response" "Action completed successful"; then - _domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \") + _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 "%s" "$domain" | cut -d . -f 1-$p) diff --git a/dnsapi/dns_gd.sh b/dnsapi/dns_gd.sh index fed25d8..f96af93 100755 --- a/dnsapi/dns_gd.sh +++ b/dnsapi/dns_gd.sh @@ -30,7 +30,7 @@ dns_gd_add() { _err "invalid domain" return 1 fi - _debug _domain_id "$_domain_id" + _debug _sub_domain "$_sub_domain" _debug _domain "$_domain" @@ -62,7 +62,6 @@ dns_gd_rm() { #returns # _sub_domain=_acme-challenge.www # _domain=domain.com -# _domain_id=sdjkglgdfewsdfg _get_root() { domain=$1 i=2 diff --git a/dnsapi/dns_me.sh b/dnsapi/dns_me.sh index ba79247..f231f7e 100755 --- a/dnsapi/dns_me.sh +++ b/dnsapi/dns_me.sh @@ -41,7 +41,7 @@ dns_me_add() { return 1 fi - count=$(printf "%s\n" "$response" | _egrep_o \"totalRecords\":[^,]* | cut -d : -f 2) + count=$(printf "%s\n" "$response" | _egrep_o "\"totalRecords\":[^,]*" | cut -d : -f 2) _debug count "$count" if [ "$count" = "0" ]; then _info "Adding record" @@ -58,7 +58,7 @@ dns_me_add() { _err "Add txt record error." else _info "Updating record" - record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]* | cut -d : -f 2 | head -n 1) + record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":[^,]*" | cut -d : -f 2 | head -n 1) _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}" @@ -101,7 +101,7 @@ _get_root() { fi if _contains "$response" "\"name\":\"$h\""; then - _domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]* | head -n 1 | cut -d : -f 2) + _domain_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":[^,]*" | head -n 1 | cut -d : -f 2) if [ "$_domain_id" ]; then _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) _domain="$h" diff --git a/dnsapi/dns_ovh.sh b/dnsapi/dns_ovh.sh index 97730f7..ed8c42b 100755 --- a/dnsapi/dns_ovh.sh +++ b/dnsapi/dns_ovh.sh @@ -131,7 +131,7 @@ dns_ovh_add() { _err "invalid domain" return 1 fi - _debug _domain_id "$_domain_id" + _debug _sub_domain "$_sub_domain" _debug _domain "$_domain" @@ -221,7 +221,6 @@ _ovh_authentication() { #returns # _sub_domain=_acme-challenge.www # _domain=domain.com -# _domain_id=sdjkglgdfewsdfg _get_root() { domain=$1 i=2 From be68fbd4f5b65716a37a4a669e7a8ae960ebf07d Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 10:58:20 +0800 Subject: [PATCH 24/31] fix for alpine --- acme.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index e49a253..b4f0138 100755 --- a/acme.sh +++ b/acme.sh @@ -259,7 +259,8 @@ _exists() { #a + b _math() { - printf "%s" "$(($@))" + _m_opts="$@" + printf "%s" "$(($_m_opts))" } _h_char_2_dec() { From 797cbb9b2064784a4a13d8d509863a3292c35739 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 11:05:05 +0800 Subject: [PATCH 25/31] fix shellcheck warnings --- dnsapi/dns_cf.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dnsapi/dns_cf.sh b/dnsapi/dns_cf.sh index 20cb169..cacb5b3 100755 --- a/dnsapi/dns_cf.sh +++ b/dnsapi/dns_cf.sh @@ -15,6 +15,8 @@ dns_cf_add() { txtvalue=$2 if [ -z "$CF_Key" ] || [ -z "$CF_Email" ]; then + CF_Key="" + CF_Email="" _err "You don't specify cloudflare api key and email yet." _err "Please create you key and try again." return 1 From 422e5026d60847c1df316539d3e7b91ef2fee2a6 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 11:13:40 +0800 Subject: [PATCH 26/31] fix shellcheck warnings --- dnsapi/dns_cx.sh | 2 ++ dnsapi/dns_dp.sh | 2 ++ dnsapi/dns_gd.sh | 2 ++ dnsapi/dns_lexicon.sh | 1 + dnsapi/dns_me.sh | 2 ++ dnsapi/dns_ovh.sh | 2 ++ dnsapi/dns_pdns.sh | 3 +++ 7 files changed, 14 insertions(+) diff --git a/dnsapi/dns_cx.sh b/dnsapi/dns_cx.sh index 38649f3..0caf0c0 100755 --- a/dnsapi/dns_cx.sh +++ b/dnsapi/dns_cx.sh @@ -17,6 +17,8 @@ dns_cx_add() { txtvalue=$2 if [ -z "$CX_Key" ] || [ -z "$CX_Secret" ]; then + CX_Key="" + CX_Secret="" _err "You don't specify cloudxns.com api key or secret yet." _err "Please create you key and try again." return 1 diff --git a/dnsapi/dns_dp.sh b/dnsapi/dns_dp.sh index a06f157..aa06d5f 100755 --- a/dnsapi/dns_dp.sh +++ b/dnsapi/dns_dp.sh @@ -17,6 +17,8 @@ dns_dp_add() { txtvalue=$2 if [ -z "$DP_Id" ] || [ -z "$DP_Key" ]; then + DP_Id="" + DP_Key="" _err "You don't specify dnspod api key and key id yet." _err "Please create you key and try again." return 1 diff --git a/dnsapi/dns_gd.sh b/dnsapi/dns_gd.sh index f96af93..9470ed2 100755 --- a/dnsapi/dns_gd.sh +++ b/dnsapi/dns_gd.sh @@ -16,6 +16,8 @@ dns_gd_add() { txtvalue=$2 if [ -z "$GD_Key" ] || [ -z "$GD_Secret" ]; then + GD_Key="" + GD_Secret="" _err "You don't specify godaddy api key and secret yet." _err "Please create you key and try again." return 1 diff --git a/dnsapi/dns_lexicon.sh b/dnsapi/dns_lexicon.sh index 38b6a13..a0f707a 100755 --- a/dnsapi/dns_lexicon.sh +++ b/dnsapi/dns_lexicon.sh @@ -22,6 +22,7 @@ dns_lexicon_add() { fi if [ -z "$PROVIDER" ]; then + PROVIDER="" _err "Please define env PROVIDER first: $wiki" return 1 fi diff --git a/dnsapi/dns_me.sh b/dnsapi/dns_me.sh index f231f7e..edd88d9 100755 --- a/dnsapi/dns_me.sh +++ b/dnsapi/dns_me.sh @@ -15,6 +15,8 @@ dns_me_add() { txtvalue=$2 if [ -z "$ME_Key" ] || [ -z "$ME_Secret" ]; then + ME_Key="" + ME_Secret="" _err "You didn't specify DNSMadeEasy api key and secret yet." _err "Please create you key and try again." return 1 diff --git a/dnsapi/dns_ovh.sh b/dnsapi/dns_ovh.sh index ed8c42b..377b3de 100755 --- a/dnsapi/dns_ovh.sh +++ b/dnsapi/dns_ovh.sh @@ -86,6 +86,8 @@ dns_ovh_add() { txtvalue=$2 if [ -z "$OVH_AK" ] || [ -z "$OVH_AS" ]; then + OVH_AK="" + OVH_AS="" _err "You don't specify OVH application key and application secret yet." _err "Please create you key and try again." return 1 diff --git a/dnsapi/dns_pdns.sh b/dnsapi/dns_pdns.sh index 0f6c59d..5d6d99f 100755 --- a/dnsapi/dns_pdns.sh +++ b/dnsapi/dns_pdns.sh @@ -17,18 +17,21 @@ dns_pdns_add() { txtvalue=$2 if [ -z "$PDNS_Url" ]; then + PDNS_Url="" _err "You don't specify PowerDNS address." _err "Please set PDNS_Url and try again." return 1 fi if [ -z "$PDNS_ServerId" ]; then + PDNS_ServerId="" _err "You don't specify PowerDNS server id." _err "Please set you PDNS_ServerId and try again." return 1 fi if [ -z "$PDNS_Token" ]; then + PDNS_Token="" _err "You don't specify PowerDNS token." _err "Please create you PDNS_Token and try again." return 1 From 158a628c0e53173686f127a25c41ca7d30c9490e Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 11:16:40 +0800 Subject: [PATCH 27/31] fix CI --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4c06c2d..7b68dfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ script: - curl -sSL $SHFMT_URL -o ~/shfmt - chmod +x ~/shfmt - shellcheck -V - - shellcheck -e SC2021,SC2126,SC2034 **/*.sh && echo "shellcheck OK" || exit 1 - - ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && exit 1) + - shellcheck -e SC2021,SC2126,SC2034 **/*.sh && echo "shellcheck OK" + - ~/shfmt -l -w -i 2 . && echo "shfmt OK" || git diff --exit-code || (echo "Run shfmt to fix the formatting issues" && false) From a0311b0134571d380715e63cd633db1e939bfa56 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 11:35:19 +0800 Subject: [PATCH 28/31] fix for shellcheck warnings --- dnsapi/dns_lexicon.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dnsapi/dns_lexicon.sh b/dnsapi/dns_lexicon.sh index a0f707a..7495442 100755 --- a/dnsapi/dns_lexicon.sh +++ b/dnsapi/dns_lexicon.sh @@ -31,7 +31,7 @@ dns_lexicon_add() { export PROVIDER Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr '[a-z]' '[A-Z]') - eval Lx_name_v="\$$Lx_name" + Lx_name_v=$(eval "echo "\$$Lx_name"") _debug "$Lx_name" "$Lx_name_v" if [ "$Lx_name_v" ]; then _saveaccountconf "$Lx_name" "$Lx_name_v" @@ -39,7 +39,7 @@ dns_lexicon_add() { fi Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr '[a-z]' '[A-Z]') - eval Lx_token_v="\$$Lx_token" + Lx_token_v=$(eval "echo "\$$Lx_token"") _debug "$Lx_token" "$Lx_token_v" if [ "$Lx_token_v" ]; then _saveaccountconf "$Lx_token" "$Lx_token_v" @@ -47,7 +47,7 @@ dns_lexicon_add() { fi Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr '[a-z]' '[A-Z]') - eval Lx_password_v="\$$Lx_password" + Lx_password_v=$(eval "echo "\$$Lx_password"") _debug "$Lx_password" "$Lx_password_v" if [ "$Lx_password_v" ]; then _saveaccountconf "$Lx_password" "$Lx_password_v" @@ -55,7 +55,7 @@ dns_lexicon_add() { fi Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr '[a-z]' '[A-Z]') - eval Lx_domaintoken_v="\$$Lx_domaintoken" + Lx_domaintoken_v=$(eval "echo "\$$Lx_domaintoken"") _debug "$Lx_domaintoken" "$Lx_domaintoken_v" if [ "$Lx_domaintoken_v" ]; then export "$Lx_domaintoken" From 3de85700226a2f5fe0c9145259ca7864ae1093a5 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 11:40:30 +0800 Subject: [PATCH 29/31] fix shellcheck warnings. --- dnsapi/dns_lexicon.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dnsapi/dns_lexicon.sh b/dnsapi/dns_lexicon.sh index 7495442..d3bfc94 100755 --- a/dnsapi/dns_lexicon.sh +++ b/dnsapi/dns_lexicon.sh @@ -31,34 +31,34 @@ dns_lexicon_add() { export PROVIDER Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr '[a-z]' '[A-Z]') - Lx_name_v=$(eval "echo "\$$Lx_name"") + Lx_name_v=$(eval "echo "\$"$Lx_name""") _debug "$Lx_name" "$Lx_name_v" if [ "$Lx_name_v" ]; then _saveaccountconf "$Lx_name" "$Lx_name_v" - export "$Lx_name" + eval export "$Lx_name" fi Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr '[a-z]' '[A-Z]') - Lx_token_v=$(eval "echo "\$$Lx_token"") + Lx_token_v=$(eval "echo "\$"$Lx_token""") _debug "$Lx_token" "$Lx_token_v" if [ "$Lx_token_v" ]; then _saveaccountconf "$Lx_token" "$Lx_token_v" - export "$Lx_token" + eval export "$Lx_token" fi Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr '[a-z]' '[A-Z]') - Lx_password_v=$(eval "echo "\$$Lx_password"") + Lx_password_v=$(eval "echo "\$"$Lx_password""") _debug "$Lx_password" "$Lx_password_v" if [ "$Lx_password_v" ]; then _saveaccountconf "$Lx_password" "$Lx_password_v" - export "$Lx_password" + eval export "$Lx_password" fi Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr '[a-z]' '[A-Z]') - Lx_domaintoken_v=$(eval "echo "\$$Lx_domaintoken"") + Lx_domaintoken_v=$(eval "echo "\$"$Lx_domaintoken""") _debug "$Lx_domaintoken" "$Lx_domaintoken_v" if [ "$Lx_domaintoken_v" ]; then - export "$Lx_domaintoken" + eval export "$Lx_domaintoken" _saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v" fi From a8c61111978013d594d63cca7e6eadab1e865bad Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 11:45:30 +0800 Subject: [PATCH 30/31] fix shellcheck warnings --- dnsapi/dns_lexicon.sh | 8 ++++---- dnsapi/dns_lua.sh | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dnsapi/dns_lexicon.sh b/dnsapi/dns_lexicon.sh index d3bfc94..4ab6564 100755 --- a/dnsapi/dns_lexicon.sh +++ b/dnsapi/dns_lexicon.sh @@ -31,7 +31,7 @@ dns_lexicon_add() { export PROVIDER Lx_name=$(echo LEXICON_"${PROVIDER}"_USERNAME | tr '[a-z]' '[A-Z]') - Lx_name_v=$(eval "echo "\$"$Lx_name""") + Lx_name_v=$(eval echo \$"$Lx_name") _debug "$Lx_name" "$Lx_name_v" if [ "$Lx_name_v" ]; then _saveaccountconf "$Lx_name" "$Lx_name_v" @@ -39,7 +39,7 @@ dns_lexicon_add() { fi Lx_token=$(echo LEXICON_"${PROVIDER}"_TOKEN | tr '[a-z]' '[A-Z]') - Lx_token_v=$(eval "echo "\$"$Lx_token""") + Lx_token_v=$(eval echo \$"$Lx_token") _debug "$Lx_token" "$Lx_token_v" if [ "$Lx_token_v" ]; then _saveaccountconf "$Lx_token" "$Lx_token_v" @@ -47,7 +47,7 @@ dns_lexicon_add() { fi Lx_password=$(echo LEXICON_"${PROVIDER}"_PASSWORD | tr '[a-z]' '[A-Z]') - Lx_password_v=$(eval "echo "\$"$Lx_password""") + Lx_password_v=$(eval echo \$"$Lx_password") _debug "$Lx_password" "$Lx_password_v" if [ "$Lx_password_v" ]; then _saveaccountconf "$Lx_password" "$Lx_password_v" @@ -55,7 +55,7 @@ dns_lexicon_add() { fi Lx_domaintoken=$(echo LEXICON_"${PROVIDER}"_DOMAINTOKEN | tr '[a-z]' '[A-Z]') - Lx_domaintoken_v=$(eval "echo "\$"$Lx_domaintoken""") + Lx_domaintoken_v=$(eval echo \$"$Lx_domaintoken") _debug "$Lx_domaintoken" "$Lx_domaintoken_v" if [ "$Lx_domaintoken_v" ]; then eval export "$Lx_domaintoken" diff --git a/dnsapi/dns_lua.sh b/dnsapi/dns_lua.sh index e6b4872..2c7ec4b 100755 --- a/dnsapi/dns_lua.sh +++ b/dnsapi/dns_lua.sh @@ -18,6 +18,8 @@ dns_lua_add() { txtvalue=$2 if [ -z "$LUA_Key" ] || [ -z "$LUA_Email" ]; then + LUA_Key="" + LUA_Email="" _err "You don't specify luadns api key and email yet." _err "Please create you key and try again." return 1 From 8f9a1881a4d78c567e53eb84300933b2b18da278 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 18:28:17 +0800 Subject: [PATCH 31/31] v2.6.5, support shellcheck and shfmt --- acme.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acme.sh b/acme.sh index b4f0138..c2f7663 100755 --- a/acme.sh +++ b/acme.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh -VER=2.6.4 +VER=2.6.5 PROJECT_NAME="acme.sh"