Skip to content

Commit

Permalink
shellcheck improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddict committed Feb 25, 2024
1 parent 41e2624 commit bfc8228
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
22 changes: 9 additions & 13 deletions deploy/directadmin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ _da_get_api() {
data=$2
domain=$3
_debug "$domain; $data"
response=$(_get "$DA_Api/$cmd?$data")

if [ "$?" != "0" ]; then

if ! response=$(_get "$DA_Api/$cmd?$data"); then
_err "error $cmd"
return 1
fi
Expand Down Expand Up @@ -129,7 +128,6 @@ _DA_setSSL() {
fi
fi


curData="domain=${_cdomain}&view=cacert&json=yes"
_debug "Calling _DA_da_get_api_getSSL: '${curData}' '${DA_Api}/CMD_API_SSL'"
_da_get_api CMD_API_SSL "${curData}" "${_cdomain}"
Expand Down Expand Up @@ -162,8 +160,8 @@ _DA_setSSL() {

if [ "$cacert_flat" != "$cca_flat" ]; then
sameCaCert=0
# cat <<< $cacert > ~/cacert.txt
# cat <<< $cca > ~/_cca.txt
# cat <<< $cacert > ~/cacert.txt
# cat <<< $cca > ~/_cca.txt
_info "Domain '${_cdomain}' is using $(__red 'a different') CA certificate."
else
_info "Domain '${_cdomain}' is using the same CA certificate."
Expand All @@ -176,7 +174,6 @@ _DA_setSSL() {
fi
fi


name="key"
sameKey=1
if _contains "$cert_response" "$name"; then
Expand All @@ -186,8 +183,8 @@ _DA_setSSL() {

if [ "$key_flat" != "$ckey_flat" ]; then
sameKey=0
# cat <<< $key > ~/key.txt
# cat <<< $ckey > ~/_ckey.txt
# cat <<< $key > ~/key.txt
# cat <<< $ckey > ~/_ckey.txt
_info "Domain '${_cdomain}' is using $(__red 'a different') private key."
else
_info "Domain '${_cdomain}' is using the same private key."
Expand All @@ -200,11 +197,11 @@ _DA_setSSL() {
cert="$(echo "$cert_response" | jq -r .$name)"
cert_flat="$(echo "$cert" | tr -d '\r' | tr -d '\n')"
_debug2 "$name" "$cert"

if [ "$cert_flat" != "$ccert_flat" ]; then
sameCert=0
# cat <<< $cert > ~/cert.txt
# cat <<< $ccert > ~/_ccert.txt
# cat <<< $cert > ~/cert.txt
# cat <<< $ccert > ~/_ccert.txt
_info "Domain '${_cdomain}' is using $(__red 'a different') certificate."
else
_info "Domain '${_cdomain}' is using the same certificate."
Expand Down Expand Up @@ -256,4 +253,3 @@ _DA_setSSL() {

return 0
}

7 changes: 7 additions & 0 deletions deploy/eddict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,17 @@ eddict_deploy() {

# https://stackoverflow.com/a/42101141
# needed to call ssh_deploy() in ssh.sh
# shellcheck source-path=SCRIPTDIR
. "$(dirname "$0")/deploy/ssh.sh"
# needed to call directadmin_deploy() in directadmin.sh
# shellcheck source-path=SCRIPTDIR
. "$(dirname "$0")/deploy/directadmin.sh"

# # shellcheck source-path=SCRIPTDIR
# here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# . "$here/config.sh"
# . "$here/utils.sh"

#/usr/local/bin/ssh not working
#/usr/local/bin/ssh: /lib/libc.so.6: version `GLIBC_2.20' not found (required by /usr/local/bin/ssh)
export DEPLOY_SSH_CMD="/usr/bin/ssh -T"
Expand Down
36 changes: 18 additions & 18 deletions dnsapi/dns_da_ef.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ _da_api() {
data=$2
domain=$3
_debug "$domain; $data"
response="$(_post "$data" "$DA_Api/$cmd" "" "POST")"
response="$(_post "$data" "$DA_Api/$cmd" "" "POST")"

if [ "$?" != "0" ]; then
_err "error $cmd"
Expand All @@ -116,23 +116,23 @@ response="$(_post "$data" "$DA_Api/$cmd" "" "POST")"
_debug response "$response"

case "${cmd}" in
CMD_API_DNS_CONTROL)
# Parse the result in general
# error=0&text=Records Deleted&details=
# error=1&text=Cannot View Dns Record&details=No domain provided
err_field="$(_getfield "$response" 1 '&')"
txt_field="$(_getfield "$response" 2 '&')"
details_field="$(_getfield "$response" 3 '&')"
error="$(_getfield "$err_field" 2 '=')"
text="$(_getfield "$txt_field" 2 '=')"
details="$(_getfield "$details_field" 2 '=')"
_debug "error: ${error}, text: ${text}, details: ${details}"
if [ "$error" != "0" ]; then
_err "error $response"
return 1
fi
;;
CMD_API_SHOW_DOMAINS) ;;
CMD_API_DNS_CONTROL)
# Parse the result in general
# error=0&text=Records Deleted&details=
# error=1&text=Cannot View Dns Record&details=No domain provided
err_field="$(_getfield "$response" 1 '&')"
txt_field="$(_getfield "$response" 2 '&')"
details_field="$(_getfield "$response" 3 '&')"
error="$(_getfield "$err_field" 2 '=')"
text="$(_getfield "$txt_field" 2 '=')"
details="$(_getfield "$details_field" 2 '=')"
_debug "error: ${error}, text: ${text}, details: ${details}"
if [ "$error" != "0" ]; then
_err "error $response"
return 1
fi
;;
CMD_API_SHOW_DOMAINS) ;;
esac
return 0
}
Expand Down

0 comments on commit bfc8228

Please sign in to comment.