Browse Source

fix shellcheck warnings.

pull/379/head
neilpang 8 years ago
parent
commit
e9f9f515bd
  1. 4
      dnsapi/dns_gd.sh
  2. 10
      dnsapi/dns_lexicon.sh
  3. 8
      dnsapi/dns_lua.sh
  4. 2
      dnsapi/dns_me.sh
  5. 6
      dnsapi/dns_ovh.sh
  6. 2
      dnsapi/dns_pdns.sh

4
dnsapi/dns_gd.sh

@ -85,8 +85,8 @@ _get_root() {
_domain="$h" _domain="$h"
return 0 return 0
fi fi
p=$i
i=$(expr $i + 1)
p="$i"
i=$(_math "$i" + 1)
done done
return 1 return 1
} }

10
dnsapi/dns_lexicon.sh

@ -29,7 +29,7 @@ dns_lexicon_add() {
_savedomainconf PROVIDER "$PROVIDER" _savedomainconf PROVIDER "$PROVIDER"
export 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" eval Lx_name_v="\$$Lx_name"
_debug "$Lx_name" "$Lx_name_v" _debug "$Lx_name" "$Lx_name_v"
if [ "$Lx_name_v" ]; then if [ "$Lx_name_v" ]; then
@ -37,7 +37,7 @@ dns_lexicon_add() {
export "$Lx_name" export "$Lx_name"
fi 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" eval Lx_token_v="\$$Lx_token"
_debug "$Lx_token" "$Lx_token_v" _debug "$Lx_token" "$Lx_token_v"
if [ "$Lx_token_v" ]; then if [ "$Lx_token_v" ]; then
@ -45,7 +45,7 @@ dns_lexicon_add() {
export "$Lx_token" export "$Lx_token"
fi 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" eval Lx_password_v="\$$Lx_password"
_debug "$Lx_password" "$Lx_password_v" _debug "$Lx_password" "$Lx_password_v"
if [ "$Lx_password_v" ]; then if [ "$Lx_password_v" ]; then
@ -53,7 +53,7 @@ dns_lexicon_add() {
export "$Lx_password" export "$Lx_password"
fi 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" eval Lx_domaintoken_v="\$$Lx_domaintoken"
_debug "$Lx_domaintoken" "$Lx_domaintoken_v" _debug "$Lx_domaintoken" "$Lx_domaintoken_v"
if [ "$Lx_domaintoken_v" ]; then if [ "$Lx_domaintoken_v" ]; then
@ -61,7 +61,7 @@ dns_lexicon_add() {
_saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v" _saveaccountconf "$Lx_domaintoken" "$Lx_domaintoken_v"
fi 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}"
} }

8
dnsapi/dns_lua.sh

@ -44,7 +44,7 @@ dns_lua_add() {
return 1 return 1
fi 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" _debug count "$count"
if [ "$count" = "0" ]; then if [ "$count" = "0" ]; then
_info "Adding record" _info "Adding record"
@ -61,7 +61,7 @@ dns_lua_add() {
_err "Add txt record error." _err "Add txt record error."
else else
_info "Updating record" _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" _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}" _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 fi
if _contains "$response" "\"name\":\"$h\""; 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)
_domain_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":[^,]*,\"name\":\"$h\"" | cut -d : -f 2 | cut -d , -f 1)
if [ "$_domain_id" ]; then if [ "$_domain_id" ]; 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"
@ -127,7 +127,7 @@ _LUA_rest() {
_H2="Authorization: Basic $LUA_auth" _H2="Authorization: Basic $LUA_auth"
if [ "$data" ]; then if [ "$data" ]; then
_debug data "$data" _debug data "$data"
response="$(_post "$data" "$LUA_Api/$ep" "" $m)"
response="$(_post "$data" "$LUA_Api/$ep" "" "$m")"
else else
response="$(_get "$LUA_Api/$ep")" response="$(_get "$LUA_Api/$ep")"
fi fi

2
dnsapi/dns_me.sh

@ -130,7 +130,7 @@ _me_rest() {
if [ "$data" ]; then if [ "$data" ]; then
_debug data "$data" _debug data "$data"
response="$(_post "$data" "$ME_Api/$ep" "" $m)"
response="$(_post "$data" "$ME_Api/$ep" "" "$m")"
else else
response="$(_get "$ME_Api/$ep")" response="$(_get "$ME_Api/$ep")"
fi fi

6
dnsapi/dns_ovh.sh

@ -127,7 +127,7 @@ dns_ovh_add() {
_info "Consumer key is ok." _info "Consumer key is ok."
_debug "First detect the root zone" _debug "First detect the root zone"
if ! _get_root $fulldomain; then
if ! _get_root "$fulldomain"; then
_err "invalid domain" _err "invalid domain"
return 1 return 1
fi fi
@ -157,7 +157,7 @@ dns_ovh_add() {
_err "Can not get record id." _err "Can not get record id."
return 1 return 1
fi 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 _ovh_rest PUT "domain/zone/$_domain/record/$record_id" "{\"target\":\"$txtvalue\",\"subDomain\":\"$_sub_domain\",\"ttl\":60}"; then
if _contains "$response" "null"; then if _contains "$response" "null"; then
@ -280,7 +280,7 @@ _ovh_rest() {
_H5="Content-Type: application/json;charset=utf-8" _H5="Content-Type: application/json;charset=utf-8"
if [ "$data" ] || [ "$m" = "POST" ] || [ "$m" = "PUT" ]; then if [ "$data" ] || [ "$m" = "POST" ] || [ "$m" = "PUT" ]; then
_debug data "$data" _debug data "$data"
response="$(_post "$data" "$_ovh_url" "" $m)"
response="$(_post "$data" "$_ovh_url" "" "$m")"
else else
response="$(_get "$_ovh_url")" response="$(_get "$_ovh_url")"
fi fi

2
dnsapi/dns_pdns.sh

@ -91,7 +91,6 @@ set_record() {
_get_root() { _get_root() {
domain=$1 domain=$1
i=1 i=1
p=1
if _pdns_rest "GET" "/api/v1/servers/$PDNS_ServerId/zones"; then if _pdns_rest "GET" "/api/v1/servers/$PDNS_ServerId/zones"; then
_zones_response="$response" _zones_response="$response"
@ -108,7 +107,6 @@ _get_root() {
return 0 return 0
fi fi
p=$i
i=$(_math $i + 1) i=$(_math $i + 1)
done done
_debug "$domain not found" _debug "$domain not found"

Loading…
Cancel
Save