Commit aaae83ef authored by peter's avatar peter
Browse files

check for return values

parent 0c9a6da6
...@@ -33,9 +33,15 @@ dns_curanet_add() { ...@@ -33,9 +33,15 @@ dns_curanet_add() {
_saveaccountconf_mutable CURANET_AUTHCLIENTID "$CURANET_AUTHCLIENTID" _saveaccountconf_mutable CURANET_AUTHCLIENTID "$CURANET_AUTHCLIENTID"
_saveaccountconf_mutable CURANET_AUTHSECRET "$CURANET_AUTHSECRET" _saveaccountconf_mutable CURANET_AUTHSECRET "$CURANET_AUTHSECRET"
gettoken if ! _get_token; then
_err "Unable to get token"
return 1
fi
_get_root "$fulldomain" if ! _get_root "$fulldomain"; then
_err "Invalid domain"
return 1
fi
export _H1="Content-Type: application/json-patch+json" export _H1="Content-Type: application/json-patch+json"
export _H2="Accept: application/json" export _H2="Accept: application/json"
...@@ -65,9 +71,15 @@ dns_curanet_rm() { ...@@ -65,9 +71,15 @@ dns_curanet_rm() {
CURANET_AUTHCLIENTID="${CURANET_AUTHCLIENTID:-$(_readaccountconf_mutable CURANET_AUTHCLIENTID)}" CURANET_AUTHCLIENTID="${CURANET_AUTHCLIENTID:-$(_readaccountconf_mutable CURANET_AUTHCLIENTID)}"
CURANET_AUTHSECRET="${CURANET_AUTHSECRET:-$(_readaccountconf_mutable CURANET_AUTHSECRET)}" CURANET_AUTHSECRET="${CURANET_AUTHSECRET:-$(_readaccountconf_mutable CURANET_AUTHSECRET)}"
gettoken if ! _get_token; then
_err "Unable to get token"
return 1
fi
_get_root "$fulldomain" if ! _get_root "$fulldomain"; then
_err "Invalid domain"
return 1
fi
_debug "Getting current record list to identify TXT to delete" _debug "Getting current record list to identify TXT to delete"
...@@ -90,13 +102,19 @@ dns_curanet_rm() { ...@@ -90,13 +102,19 @@ dns_curanet_rm() {
#################### Private functions below ################################## #################### Private functions below ##################################
gettoken() { _get_token() {
response="$(_post "grant_type=client_credentials&client_id=$CURANET_AUTHCLIENTID&client_secret=$CURANET_AUTHSECRET&scope=dns" "$CURANET_AUTH_URL" "" "")" response="$(_post "grant_type=client_credentials&client_id=$CURANET_AUTHCLIENTID&client_secret=$CURANET_AUTHSECRET&scope=dns" "$CURANET_AUTH_URL" "" "")"
if ! _contains "$response" "access_token"; then if ! _contains "$response" "access_token"; then
_err "Unable get access token" _err "Unable get access token"
return 1 return 1
fi fi
CURANET_ACCESS_TOKEN=$(echo "$response" | _egrep_o "\"access_token\":\"[^\"]+" | cut -c 17-) CURANET_ACCESS_TOKEN=$(echo "$response" | _egrep_o "\"access_token\":\"[^\"]+" | cut -c 17-)
if [ -z "$CURANET_ACCESS_TOKEN" ]; then
_err "Unable to get token"
return 1
fi
} }
#_acme-challenge.www.domain.com #_acme-challenge.www.domain.com
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment