From e9f9f515bdf707e704e33af001378e0bb256d053 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:06:34 +0800 Subject: [PATCH] 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 304d5d3e..dec80a9b 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 c3628a0f..38b6a13c 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 c03686ab..e6b48724 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 db4f796a..ba792474 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 ace52225..97730f7e 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 7c994eb5..0f6c59d5 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"