From bc36b9e89d09e68d3a94e3644abcac89388f7cb7 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 18 Mar 2020 14:43:30 +0100 Subject: [PATCH 01/20] Firts release --- dnsapi/dns_aruba.sh | 248 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 dnsapi/dns_aruba.sh diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh new file mode 100644 index 00000000..1ff3e2a6 --- /dev/null +++ b/dnsapi/dns_aruba.sh @@ -0,0 +1,248 @@ +#!/bin/bash + +#Original Author: Gerardo Trotta + +#Application username +#ARUBA_AK="username" +# +#Application password +#ARUBA_AS="password" +# +#API key +#ARUBA_TK="token" +# +#Consumer Key +#ARUBA_CK="sdfsdfsdfsdfsdfdsf" + +#ARUBA_END_POINT=aruba-it + +#'aruba-it' +ARUBA_IT='https://api.arubabusiness.it' + +_aruba_get_api() { + _ogaep="$1" + + case "${_ogaep}" in + + aruba-it | arubait) + printf "%s" $ARUBA_IT + return + ;; + + *) + _err "Unknown parameter : $1" + return 1 + ;; + esac +} + +_initAuth() { + ARUBA_AK="${ARUBA_AK:-$(_readaccountconf_mutable ARUBA_AK)}" + ARUBA_AS="${ARUBA_AS:-$(_readaccountconf_mutable ARUBA_AS)}" + ARUBA_TK="${ARUBA_TK:-$(_readaccountconf_mutable ARUBA_TK)}" + + if [ -z "$ARUBA_AK" ] || [ -z "$ARUBA_AS" ] || [ -z "$ARUBA_TK" ]; then + ARUBA_AK="" + ARUBA_AS="" + ARUBA_TK="" + _err "You don't specify ARUBA application key or application secret yet." + _err "Please create you key and try again." + return 1 + fi + + if [ "$ARUBA_TK" != "$(_readaccountconf ARUBA_TK)" ]; then + _info "It seems that your aruba key is changed, let's clear consumer key first." + _clearaccountconf ARUBA_TK + _clearaccountconf ARUBA_CK + fi + _saveaccountconf_mutable ARUBA_AK "$ARUBA_AK" + _saveaccountconf_mutable ARUBA_AS "$ARUBA_AS" + _saveaccountconf_mutable ARUBA_TK "$ARUBA_TK" + + ARUBA_END_POINT="${ARUBA_END_POINT:-$(_readaccountconf_mutable ARUBA_END_POINT)}" + if [ -z "$ARUBA_END_POINT" ]; then + ARUBA_END_POINT="aruba-it" + fi + _info "Using ARUBA endpoint: $ARUBA_END_POINT" + if [ "$ARUBA_END_POINT" != "aruba-it" ]; then + _saveaccountconf_mutable ARUBA_END_POINT "$ARUBA_END_POINT" + fi + + ARUBA_API="$(_aruba_get_api $ARUBA_END_POINT)" + _debug ARUBA_API "$ARUBA_API" + + ARUBA_CK="${ARUBA_CK:-$(_readaccountconf_mutable ARUBA_CK)}" + if [ -z "$ARUBA_CK" ]; then + _info "ARUBA consumer key is empty, Let's get one:" + if ! _aruba_authentication; then + _err "Can not get consumer key." + fi + #return and wait for retry. + return 1 + fi + + _info "Checking authentication and get domain details" + + if ! _aruba_rest GET "api/domains/dns/$_domain/details" || _contains "$response" "error" || _contains "$response" "denied"; then + _err "The consumer key is invalid: $ARUBA_CK" + _err "Please retry to create a new one." + _clearaccountconf ARUBA_CK + return 1 + fi + + domainData=$(echo "$response" | tr -d '\r' ) + + # get all Ids and peek only values + temp="$(echo "$domainData" | grep -oP "Id\": \d{1,}" | cut -d : -f 2)" + read -ra ADDR <<< "$temp" #put Ids into array + domain_id="${ADDR[0]}" # first element is zone Id + + _info "DomainId is: $domain_id" + _info "Consumer key is ok." + return 0 +} + +######## Public functions ##################### + +#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" +dns_aruba_add() { + fulldomain=$1 + txtvalue=$2 + + if ! _initAuth; then + return 1 + fi + + _debug "Check if _acme-challenge record exists" + if ! _get_zone_id "$_domain"; then + _err "invalid domain" + return 1 + fi + + _debug _domain "$_domain" + _sub_domain="_acme-challenge" + + _payload="{ \"IdDomain\": $domain_id, \"Type\": \"TXT\", \"Name\": \"$_sub_domain\", \"Content\": \"\\\"$txtvalue\\\"\" }" + + _info "Adding record" + if _aruba_rest POST "api/domains/dns/record" "$_payload"; then + if _contains "$response" "$txtvalue"; then + _aruba_rest GET "api/domains/dns/$_domain/details" + _debug "Refresh:$response" + _info "Added, sleep 10 seconds." + _sleep 10 + return 0 + fi + fi + _err "Add txt record error." + return 1 +} + +#fulldomain +dns_aruba_rm() { + fulldomain=$1 + txtvalue=$2 + + if ! _initAuth; then + return 1 + fi + + _sub_domain="_acme-challenge.${_domain}" + _debug _sub_domain "$_sub_domain" + _debug "Getting TXT record to delete" + + if ! _extract_record_id $_sub_domain; then + return 1 + fi + + if ! _ovh_rest DELETE "api/domains/dns/record/$_recordId"; then + return 1 + fi + + return 0 +} + +#################### Private functions below ################################## + +# returns TXT record and put it in_record_id, if esists +_extract_record_id() { + subdomain=$1 + _arrayid=0 + _ids="$(echo $domainData | grep -oP '(?<="Id": )[^,]+')" + _names="$(echo $domainData | grep -oP '(?<="Name": ")[^"]+')" + ARRAY_IDS=($(echo $_ids | tr ", " "\n")) + ARRAY_NAMES=($_names) + + for i in "${!ARRAY_NAMES[@]}" + do + if [[ ${ARRAY_NAMES[$i]} = $subdomain ]]; then + _debug printf "%s\t%s\n" "$i" "${ARRAY_NAMES[$i]}" + _arrayid=$i + _debug"Found txt record id: ${ARRAY_IDS[$_arrayid]}" + _recordId=${ARRAY_IDS[$_arrayid} + #printf "%s" ${ARRAY_IDS[$_arrayid} + return 0 + fi + done + + return 1 +} + + +_aruba_authentication() { + export _H1="Content-Type: application/x-www-form-urlencoded" + export _H2="Authorization-Key: $ARUBA_TK" + _H3="" + _H4="" + + _arubadata="grant_type=password&username=$ARUBA_AK&password=$ARUBA_AS" + + response="$(_post "$_arubadata" "$ARUBA_API/auth/token")" + + _debug3 response "$response" + + access_token="$(echo "$response" | _egrep_o "access_token\":\"[^\"]*\"" | cut -d : -f 2 | tr -d '"')" + if [ -z "$access_token" ]; then + _err "Unable to get access_token" + return 1 + fi + _secure_debug access_token "$access_token" + + ARUBA_CK="$access_token" + _saveaccountconf ARUBA_CK "$ARUBA_CK" + + return 0 +} + + +_aruba_rest() { + m=$1 + ep="$2" + data="$3" + _debug "$ep" + + _aruba_url="$ARUBA_API/$ep" + _debug2 _aruba_url "$_aruba_url" + + export _H1="Content-type: application/json" + export _H2="Accept: application/json" + export _H3="Authorization: Bearer $ARUBA_CK" + export _H4="Authorization-Key: $ARUBA_TK" + export _H5="Accept: application/json" + + _debug3 _H3 "$_H3" + _debug3 _H4 "$_H4" + if [ "$data" ] || [ "$m" = "POST" ] || [ "$m" = "PUT" ] || [ "$m" = "DELETE" ]; then + _debug data "$data" + response="$(_post "$data" "$_aruba_url" "" "$m")" + else + response="$(_get "$_aruba_url")" + fi + + if [ "$?" != "0" ] || _contains "$response" "wrong credentials" || _contains "$response" "Unprocessable"; then + _err "Response error $response" + return 1 + fi + _debug2 response "$response" + return 0 +} From 936d6cf83782331cd6b809dc91655263255b051c Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sat, 18 Apr 2020 22:01:16 +0200 Subject: [PATCH 02/20] Refactoring from bash to dash Some errors --- dnsapi/dns_aruba.sh | 79 +++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 32 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 1ff3e2a6..2a9d8da7 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -1,15 +1,15 @@ -#!/bin/bash +#!/usr/bin/env sh #Original Author: Gerardo Trotta #Application username -#ARUBA_AK="username" +#ARUBA_AK="xxxxx" # #Application password -#ARUBA_AS="password" +#ARUBA_AS="xxxxxx" # #API key -#ARUBA_TK="token" +#ARUBA_TK="xxxxxxxx" # #Consumer Key #ARUBA_CK="sdfsdfsdfsdfsdfdsf" @@ -30,6 +30,7 @@ _aruba_get_api() { ;; *) + _err "Unknown parameter : $1" return 1 ;; @@ -44,15 +45,15 @@ _initAuth() { if [ -z "$ARUBA_AK" ] || [ -z "$ARUBA_AS" ] || [ -z "$ARUBA_TK" ]; then ARUBA_AK="" ARUBA_AS="" - ARUBA_TK="" - _err "You don't specify ARUBA application key or application secret yet." + ARUBA_TK="" + _err "You don't specify ARUBA application key and application secret yet." _err "Please create you key and try again." return 1 fi if [ "$ARUBA_TK" != "$(_readaccountconf ARUBA_TK)" ]; then _info "It seems that your aruba key is changed, let's clear consumer key first." - _clearaccountconf ARUBA_TK + _clearaccountconf ARUBA_TK _clearaccountconf ARUBA_CK fi _saveaccountconf_mutable ARUBA_AK "$ARUBA_AK" @@ -76,9 +77,9 @@ _initAuth() { _info "ARUBA consumer key is empty, Let's get one:" if ! _aruba_authentication; then _err "Can not get consumer key." + #return and wait for retry. + return 1 fi - #return and wait for retry. - return 1 fi _info "Checking authentication and get domain details" @@ -93,9 +94,9 @@ _initAuth() { domainData=$(echo "$response" | tr -d '\r' ) # get all Ids and peek only values - temp="$(echo "$domainData" | grep -oP "Id\": \d{1,}" | cut -d : -f 2)" - read -ra ADDR <<< "$temp" #put Ids into array - domain_id="${ADDR[0]}" # first element is zone Id + temp="$(echo "$domainData" | grep -oP "Id\": \d{1,}" | cut -d : -f 2 | head -1)" + #read -ra ADDR <<< "$temp" #put Ids into array + domain_id=$temp # first element is zone Id _info "DomainId is: $domain_id" _info "Consumer key is ok." @@ -113,14 +114,16 @@ dns_aruba_add() { return 1 fi - _debug "Check if _acme-challenge record exists" - if ! _get_zone_id "$_domain"; then + _debug _domain "$_domain" + _sub_domain="_acme-challenge" + + _debug "Check if _acme-challenge record exists in " "$_domain" + if ! _extract_record_id "$_sub_domain$_domain"; then _err "invalid domain" return 1 fi - _debug _domain "$_domain" - _sub_domain="_acme-challenge" + _payload="{ \"IdDomain\": $domain_id, \"Type\": \"TXT\", \"Name\": \"$_sub_domain\", \"Content\": \"\\\"$txtvalue\\\"\" }" @@ -155,7 +158,7 @@ dns_aruba_rm() { return 1 fi - if ! _ovh_rest DELETE "api/domains/dns/record/$_recordId"; then + if ! _aruba_rest DELETE "api/domains/dns/record/$_recordId"; then return 1 fi @@ -169,21 +172,33 @@ _extract_record_id() { subdomain=$1 _arrayid=0 _ids="$(echo $domainData | grep -oP '(?<="Id": )[^,]+')" + _temp="$(echo $domainData | grep -oP "\"DomainId\":\s\d{1,}," | tr -d ' ')" + _domainids="$(echo $_temp | tr -d ' ')" _names="$(echo $domainData | grep -oP '(?<="Name": ")[^"]+')" - ARRAY_IDS=($(echo $_ids | tr ", " "\n")) - ARRAY_NAMES=($_names) + ARRAY_IDS=$(echo $_ids | tr ", " "\n") + ARRAY_NAMES=$_names - for i in "${!ARRAY_NAMES[@]}" + j=0 + for i in $ARRAY_NAMES; do - if [[ ${ARRAY_NAMES[$i]} = $subdomain ]]; then - _debug printf "%s\t%s\n" "$i" "${ARRAY_NAMES[$i]}" - _arrayid=$i - _debug"Found txt record id: ${ARRAY_IDS[$_arrayid]}" - _recordId=${ARRAY_IDS[$_arrayid} - #printf "%s" ${ARRAY_IDS[$_arrayid} - return 0 - fi + if [ "$i" = "$subdomain" ]; then + _debug printf "%s\t%s\n" "$i" + _arrayname=$i + _arrayId=$j + _debug "Found txt record id: $_arrayId" + fi + j=$(_math "$j" + 1) done + + n=0 + for i in $ARRAY_IDS; + do + if [ "$n" = "$_arrayId" ]; then + _recordId=$i + return 0 + fi + n=$(_math "$n" + 1) + done return 1 } @@ -198,7 +213,7 @@ _aruba_authentication() { _arubadata="grant_type=password&username=$ARUBA_AK&password=$ARUBA_AS" response="$(_post "$_arubadata" "$ARUBA_API/auth/token")" - + _debug "$(_post "$_arubadata" "$ARUBA_API/auth/token")" _debug3 response "$response" access_token="$(echo "$response" | _egrep_o "access_token\":\"[^\"]*\"" | cut -d : -f 2 | tr -d '"')" @@ -230,8 +245,8 @@ _aruba_rest() { export _H4="Authorization-Key: $ARUBA_TK" export _H5="Accept: application/json" - _debug3 _H3 "$_H3" - _debug3 _H4 "$_H4" + _debug2 _H3 "$_H3" + _debug2 _H4 "$_H4" if [ "$data" ] || [ "$m" = "POST" ] || [ "$m" = "PUT" ] || [ "$m" = "DELETE" ]; then _debug data "$data" response="$(_post "$data" "$_aruba_url" "" "$m")" @@ -239,7 +254,7 @@ _aruba_rest() { response="$(_get "$_aruba_url")" fi - if [ "$?" != "0" ] || _contains "$response" "wrong credentials" || _contains "$response" "Unprocessable"; then + if [ "$?" != "0" ] || _contains "$response" "wrong credentials" || _contains "$response" "Unprocessable" || _contains "$response" "denied"; then _err "Response error $response" return 1 fi From afee487a80ced4f69b3b828216a3954d8e343a4d Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 11:16:11 +0200 Subject: [PATCH 03/20] Uncommented global variables --- dnsapi/dns_aruba.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 2a9d8da7..b974cd22 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -3,13 +3,13 @@ #Original Author: Gerardo Trotta #Application username -#ARUBA_AK="xxxxx" +ARUBA_AK="xxxxx" # #Application password -#ARUBA_AS="xxxxxx" +ARUBA_AS="xxxxxx" # #API key -#ARUBA_TK="xxxxxxxx" +ARUBA_TK="xxxxxxxx" # #Consumer Key #ARUBA_CK="sdfsdfsdfsdfsdfdsf" From 6e589de5eb4de90357b98e6d8d4947be3bb165be Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 14:25:48 +0200 Subject: [PATCH 04/20] Modified grep and TXT search --- dnsapi/dns_aruba.sh | 50 ++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index b974cd22..0f9a00e5 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -3,29 +3,29 @@ #Original Author: Gerardo Trotta #Application username -ARUBA_AK="xxxxx" +#ARUBA_AK="xxxxx" # #Application password -ARUBA_AS="xxxxxx" +#ARUBA_AS="xxxxxx" # #API key -ARUBA_TK="xxxxxxxx" +#ARUBA_TK="xxxxxxxx" # #Consumer Key #ARUBA_CK="sdfsdfsdfsdfsdfdsf" #ARUBA_END_POINT=aruba-it -#'aruba-it' -ARUBA_IT='https://api.arubabusiness.it' +#'aruba-business-it' +ARUBA_BUSINESS_IT='https://api.arubabusiness.it' _aruba_get_api() { _ogaep="$1" case "${_ogaep}" in - aruba-it | arubait) - printf "%s" $ARUBA_IT + aruba-b-it | arubabit) + printf "%s" $ARUBA_BUSINESS_IT return ;; @@ -94,7 +94,7 @@ _initAuth() { domainData=$(echo "$response" | tr -d '\r' ) # get all Ids and peek only values - temp="$(echo "$domainData" | grep -oP "Id\": \d{1,}" | cut -d : -f 2 | head -1)" + temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" #read -ra ADDR <<< "$temp" #put Ids into array domain_id=$temp # first element is zone Id @@ -118,17 +118,17 @@ dns_aruba_add() { _sub_domain="_acme-challenge" _debug "Check if _acme-challenge record exists in " "$_domain" - if ! _extract_record_id "$_sub_domain$_domain"; then - _err "invalid domain" - return 1 + if ! _extract_record_id "$_sub_domain.$_domain."; then + _method="POST" + else + _method="PUT" fi - _payload="{ \"IdDomain\": $domain_id, \"Type\": \"TXT\", \"Name\": \"$_sub_domain\", \"Content\": \"\\\"$txtvalue\\\"\" }" _info "Adding record" - if _aruba_rest POST "api/domains/dns/record" "$_payload"; then + if _aruba_rest "$_method" "api/domains/dns/record" "$_payload"; then if _contains "$response" "$txtvalue"; then _aruba_rest GET "api/domains/dns/$_domain/details" _debug "Refresh:$response" @@ -149,15 +149,16 @@ dns_aruba_rm() { if ! _initAuth; then return 1 fi + + _sub_domain="_acme-challenge" - _sub_domain="_acme-challenge.${_domain}" - _debug _sub_domain "$_sub_domain" - _debug "Getting TXT record to delete" + _debug "Getting TXT record to delete: $_sub_domain.$_domain." - if ! _extract_record_id $_sub_domain; then + if ! _extract_record_id "$_sub_domain.$_domain"; then return 1 fi + _debug "Deleting TXT record: $_sub_domain.$_domain" if ! _aruba_rest DELETE "api/domains/dns/record/$_recordId"; then return 1 fi @@ -169,12 +170,14 @@ dns_aruba_rm() { # returns TXT record and put it in_record_id, if esists _extract_record_id() { - subdomain=$1 + subdomain="$1" _arrayid=0 - _ids="$(echo $domainData | grep -oP '(?<="Id": )[^,]+')" - _temp="$(echo $domainData | grep -oP "\"DomainId\":\s\d{1,}," | tr -d ' ')" - _domainids="$(echo $_temp | tr -d ' ')" - _names="$(echo $domainData | grep -oP '(?<="Name": ")[^"]+')" + _ids="$(echo $domainData | _egrep_o '"Id": [^,]+' | cut -d : -f 2)" + _debug $ids + #_temp="$(echo $domainData | grep -oP "\"DomainId\":\s\d{1,}," | tr -d ' ')" + #_domainids="$(echo $_temp | tr -d ' ')" + _names="$(echo $domainData | _egrep_o '"Name": [^,]*' | cut -d : -f 2)" + _debug $names ARRAY_IDS=$(echo $_ids | tr ", " "\n") ARRAY_NAMES=$_names @@ -185,7 +188,7 @@ _extract_record_id() { _debug printf "%s\t%s\n" "$i" _arrayname=$i _arrayId=$j - _debug "Found txt record id: $_arrayId" + _info "Found txt record id: $_arrayId" fi j=$(_math "$j" + 1) done @@ -195,6 +198,7 @@ _extract_record_id() { do if [ "$n" = "$_arrayId" ]; then _recordId=$i + _info "recordid found: $_recordId" return 0 fi n=$(_math "$n" + 1) From 3945a59ea4862a88ffd7336f8425313e1fa6dbe5 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 15:03:42 +0200 Subject: [PATCH 05/20] Travis refactoring --- dnsapi/dns_aruba.sh | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 0f9a00e5..596745da 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -45,7 +45,7 @@ _initAuth() { if [ -z "$ARUBA_AK" ] || [ -z "$ARUBA_AS" ] || [ -z "$ARUBA_TK" ]; then ARUBA_AK="" ARUBA_AS="" - ARUBA_TK="" + ARUBA_TK="" _err "You don't specify ARUBA application key and application secret yet." _err "Please create you key and try again." return 1 @@ -53,7 +53,7 @@ _initAuth() { if [ "$ARUBA_TK" != "$(_readaccountconf ARUBA_TK)" ]; then _info "It seems that your aruba key is changed, let's clear consumer key first." - _clearaccountconf ARUBA_TK + _clearaccountconf ARUBA_TK _clearaccountconf ARUBA_CK fi _saveaccountconf_mutable ARUBA_AK "$ARUBA_AK" @@ -91,12 +91,10 @@ _initAuth() { return 1 fi - domainData=$(echo "$response" | tr -d '\r' ) - + domainData=$(echo "$response" | tr -d '\r') # get all Ids and peek only values - temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" - #read -ra ADDR <<< "$temp" #put Ids into array - domain_id=$temp # first element is zone Id + temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id + domain_id=$temp _info "DomainId is: $domain_id" _info "Consumer key is ok." @@ -114,7 +112,7 @@ dns_aruba_add() { return 1 fi - _debug _domain "$_domain" + _debug _domain "$_domain" _sub_domain="_acme-challenge" _debug "Check if _acme-challenge record exists in " "$_domain" @@ -155,12 +153,12 @@ dns_aruba_rm() { _debug "Getting TXT record to delete: $_sub_domain.$_domain." if ! _extract_record_id "$_sub_domain.$_domain"; then - return 1 + return 1 fi _debug "Deleting TXT record: $_sub_domain.$_domain" if ! _aruba_rest DELETE "api/domains/dns/record/$_recordId"; then - return 1 + return 1 fi return 0 @@ -171,31 +169,29 @@ dns_aruba_rm() { # returns TXT record and put it in_record_id, if esists _extract_record_id() { subdomain="$1" - _arrayid=0 - _ids="$(echo $domainData | _egrep_o '"Id": [^,]+' | cut -d : -f 2)" + _arrayid=0 + _ids="$(echo "$domainData" | _egrep_o '"Id": [^,]+' | cut -d : -f 2)" _debug $ids #_temp="$(echo $domainData | grep -oP "\"DomainId\":\s\d{1,}," | tr -d ' ')" #_domainids="$(echo $_temp | tr -d ' ')" - _names="$(echo $domainData | _egrep_o '"Name": [^,]*' | cut -d : -f 2)" + _names="$(echo "$domainData" | _egrep_o '"Name": [^,]*' | cut -d : -f 2)" _debug $names - ARRAY_IDS=$(echo $_ids | tr ", " "\n") + ARRAY_IDS=$(echo "$_ids" | tr ", " "\n") ARRAY_NAMES=$_names - + j=0 - for i in $ARRAY_NAMES; - do + for i in $ARRAY_NAMES; do if [ "$i" = "$subdomain" ]; then _debug printf "%s\t%s\n" "$i" - _arrayname=$i + #_arrayname=$i _arrayId=$j - _info "Found txt record id: $_arrayId" + _info "Found txt record id: $_arrayId" fi j=$(_math "$j" + 1) done n=0 - for i in $ARRAY_IDS; - do + for i in $ARRAY_IDS; do if [ "$n" = "$_arrayId" ]; then _recordId=$i _info "recordid found: $_recordId" @@ -216,8 +212,8 @@ _aruba_authentication() { _arubadata="grant_type=password&username=$ARUBA_AK&password=$ARUBA_AS" - response="$(_post "$_arubadata" "$ARUBA_API/auth/token")" - _debug "$(_post "$_arubadata" "$ARUBA_API/auth/token")" + response="$(_post "$_arubadata" "$ARUBA_API/auth/token")" + _debug "$(_post "$_arubadata" "$ARUBA_API/auth/token")" _debug3 response "$response" access_token="$(echo "$response" | _egrep_o "access_token\":\"[^\"]*\"" | cut -d : -f 2 | tr -d '"')" From 1ab4565e5711115e1cfd18750588be479fc30f4d Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 15:54:41 +0200 Subject: [PATCH 06/20] Travis refactoring 2 --- dnsapi/dns_aruba.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 596745da..8f2625fc 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -45,7 +45,7 @@ _initAuth() { if [ -z "$ARUBA_AK" ] || [ -z "$ARUBA_AS" ] || [ -z "$ARUBA_TK" ]; then ARUBA_AK="" ARUBA_AS="" - ARUBA_TK="" + ARUBA_TK="" _err "You don't specify ARUBA application key and application secret yet." _err "Please create you key and try again." return 1 @@ -53,7 +53,7 @@ _initAuth() { if [ "$ARUBA_TK" != "$(_readaccountconf ARUBA_TK)" ]; then _info "It seems that your aruba key is changed, let's clear consumer key first." - _clearaccountconf ARUBA_TK + _clearaccountconf ARUBA_TK _clearaccountconf ARUBA_CK fi _saveaccountconf_mutable ARUBA_AK "$ARUBA_AK" @@ -153,7 +153,7 @@ dns_aruba_rm() { _debug "Getting TXT record to delete: $_sub_domain.$_domain." if ! _extract_record_id "$_sub_domain.$_domain"; then - return 1 + return 1 fi _debug "Deleting TXT record: $_sub_domain.$_domain" @@ -180,24 +180,24 @@ _extract_record_id() { ARRAY_NAMES=$_names j=0 - for i in $ARRAY_NAMES; do - if [ "$i" = "$subdomain" ]; then - _debug printf "%s\t%s\n" "$i" + for i in $ARRAY_NAMES; do + if [ "$i" = "$subdomain" ]; then + _debug printf "%s\t%s\n" "$i" #_arrayname=$i _arrayId=$j - _info "Found txt record id: $_arrayId" + _info "Found txt record id: $_arrayId" fi - j=$(_math "$j" + 1) + j=$(_math "$j" + 1) done n=0 - for i in $ARRAY_IDS; do - if [ "$n" = "$_arrayId" ]; then + for i in $ARRAY_IDS; do + if [ "$n" = "$_arrayId" ]; then _recordId=$i _info "recordid found: $_recordId" return 0 fi - n=$(_math "$n" + 1) + n=$(_math "$n" + 1) done return 1 From 680106582bf14846bf57f1fdc7202e2a570f7404 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 16:21:54 +0200 Subject: [PATCH 07/20] Travis 3 --- dnsapi/dns_aruba.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 8f2625fc..04260293 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -91,7 +91,7 @@ _initAuth() { return 1 fi - domainData=$(echo "$response" | tr -d '\r') + domainData=$(echo "$response" | tr -d '\r') # get all Ids and peek only values temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id domain_id=$temp @@ -185,7 +185,7 @@ _extract_record_id() { _debug printf "%s\t%s\n" "$i" #_arrayname=$i _arrayId=$j - _info "Found txt record id: $_arrayId" + _info "Found txt record id: $_arrayId" fi j=$(_math "$j" + 1) done @@ -198,7 +198,7 @@ _extract_record_id() { return 0 fi n=$(_math "$n" + 1) - done + done return 1 } From 51668042e97497a1e942bbb1c97a848f6bd51e00 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 16:50:06 +0200 Subject: [PATCH 08/20] Travis 4 --- dnsapi/dns_aruba.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 04260293..ec935e02 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -111,7 +111,7 @@ dns_aruba_add() { if ! _initAuth; then return 1 fi - + _debug _domain "$_domain" _sub_domain="_acme-challenge" @@ -122,7 +122,6 @@ dns_aruba_add() { _method="PUT" fi - _payload="{ \"IdDomain\": $domain_id, \"Type\": \"TXT\", \"Name\": \"$_sub_domain\", \"Content\": \"\\\"$txtvalue\\\"\" }" _info "Adding record" @@ -149,7 +148,6 @@ dns_aruba_rm() { fi _sub_domain="_acme-challenge" - _debug "Getting TXT record to delete: $_sub_domain.$_domain." if ! _extract_record_id "$_sub_domain.$_domain"; then @@ -178,7 +176,7 @@ _extract_record_id() { _debug $names ARRAY_IDS=$(echo "$_ids" | tr ", " "\n") ARRAY_NAMES=$_names - + j=0 for i in $ARRAY_NAMES; do if [ "$i" = "$subdomain" ]; then @@ -189,7 +187,7 @@ _extract_record_id() { fi j=$(_math "$j" + 1) done - + n=0 for i in $ARRAY_IDS; do if [ "$n" = "$_arrayId" ]; then @@ -199,11 +197,9 @@ _extract_record_id() { fi n=$(_math "$n" + 1) done - return 1 } - _aruba_authentication() { export _H1="Content-Type: application/x-www-form-urlencoded" export _H2="Authorization-Key: $ARUBA_TK" @@ -225,11 +221,9 @@ _aruba_authentication() { ARUBA_CK="$access_token" _saveaccountconf ARUBA_CK "$ARUBA_CK" - return 0 } - _aruba_rest() { m=$1 ep="$2" @@ -244,7 +238,6 @@ _aruba_rest() { export _H3="Authorization: Bearer $ARUBA_CK" export _H4="Authorization-Key: $ARUBA_TK" export _H5="Accept: application/json" - _debug2 _H3 "$_H3" _debug2 _H4 "$_H4" if [ "$data" ] || [ "$m" = "POST" ] || [ "$m" = "PUT" ] || [ "$m" = "DELETE" ]; then From e16e44872c241b2d784c448e705517190bcaa71c Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 17:02:05 +0200 Subject: [PATCH 09/20] Travis 5 --- dnsapi/dns_aruba.sh | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index ec935e02..ec8e7448 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -89,13 +89,11 @@ _initAuth() { _err "Please retry to create a new one." _clearaccountconf ARUBA_CK return 1 - fi - + fi domainData=$(echo "$response" | tr -d '\r') # get all Ids and peek only values temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id - domain_id=$temp - + domain_id=$temp _info "DomainId is: $domain_id" _info "Consumer key is ok." return 0 @@ -111,7 +109,6 @@ dns_aruba_add() { if ! _initAuth; then return 1 fi - _debug _domain "$_domain" _sub_domain="_acme-challenge" @@ -146,19 +143,15 @@ dns_aruba_rm() { if ! _initAuth; then return 1 fi - _sub_domain="_acme-challenge" _debug "Getting TXT record to delete: $_sub_domain.$_domain." - if ! _extract_record_id "$_sub_domain.$_domain"; then return 1 fi - _debug "Deleting TXT record: $_sub_domain.$_domain" if ! _aruba_rest DELETE "api/domains/dns/record/$_recordId"; then return 1 fi - return 0 } @@ -176,7 +169,6 @@ _extract_record_id() { _debug $names ARRAY_IDS=$(echo "$_ids" | tr ", " "\n") ARRAY_NAMES=$_names - j=0 for i in $ARRAY_NAMES; do if [ "$i" = "$subdomain" ]; then From 69306075464dc8cafa3a802c91b807432f2fc8f7 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 17:13:52 +0200 Subject: [PATCH 10/20] Travis 6 --- dnsapi/dns_aruba.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index ec8e7448..ce7621b8 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -89,11 +89,11 @@ _initAuth() { _err "Please retry to create a new one." _clearaccountconf ARUBA_CK return 1 - fi + fi domainData=$(echo "$response" | tr -d '\r') # get all Ids and peek only values temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id - domain_id=$temp + domain_id=$temp _info "DomainId is: $domain_id" _info "Consumer key is ok." return 0 @@ -110,8 +110,7 @@ dns_aruba_add() { return 1 fi _debug _domain "$_domain" - _sub_domain="_acme-challenge" - + _sub_domain="_acme-challenge" _debug "Check if _acme-challenge record exists in " "$_domain" if ! _extract_record_id "$_sub_domain.$_domain."; then _method="POST" @@ -160,13 +159,12 @@ dns_aruba_rm() { # returns TXT record and put it in_record_id, if esists _extract_record_id() { subdomain="$1" - _arrayid=0 _ids="$(echo "$domainData" | _egrep_o '"Id": [^,]+' | cut -d : -f 2)" - _debug $ids + _debug "$_ids" #_temp="$(echo $domainData | grep -oP "\"DomainId\":\s\d{1,}," | tr -d ' ')" #_domainids="$(echo $_temp | tr -d ' ')" _names="$(echo "$domainData" | _egrep_o '"Name": [^,]*' | cut -d : -f 2)" - _debug $names + _debug "$_names" ARRAY_IDS=$(echo "$_ids" | tr ", " "\n") ARRAY_NAMES=$_names j=0 From b0ada7dccd7f7d9359e804841147281dab49a219 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 17:22:52 +0200 Subject: [PATCH 11/20] Travis 7 --- dnsapi/dns_aruba.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index ce7621b8..6063fc83 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -110,7 +110,7 @@ dns_aruba_add() { return 1 fi _debug _domain "$_domain" - _sub_domain="_acme-challenge" + _sub_domain="_acme-challenge" _debug "Check if _acme-challenge record exists in " "$_domain" if ! _extract_record_id "$_sub_domain.$_domain."; then _method="POST" @@ -176,8 +176,7 @@ _extract_record_id() { _info "Found txt record id: $_arrayId" fi j=$(_math "$j" + 1) - done - + done n=0 for i in $ARRAY_IDS; do if [ "$n" = "$_arrayId" ]; then From 31f57cd3be9f22142461ae958a058d9e898f0007 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 17:30:11 +0200 Subject: [PATCH 12/20] Travis 8 --- dnsapi/dns_aruba.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 6063fc83..8ba378c6 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -176,7 +176,7 @@ _extract_record_id() { _info "Found txt record id: $_arrayId" fi j=$(_math "$j" + 1) - done + done n=0 for i in $ARRAY_IDS; do if [ "$n" = "$_arrayId" ]; then From d14875fec89a403a86fbc2efc7502158b5476ba2 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 19 Apr 2020 19:01:36 +0200 Subject: [PATCH 13/20] Travis 9 --- dnsapi/dns_aruba.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 8ba378c6..05bee483 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -105,12 +105,14 @@ _initAuth() { dns_aruba_add() { fulldomain=$1 txtvalue=$2 - + + _debug _domain "$_domain" + _sub_domain="_acme-challenge" + if ! _initAuth; then return 1 fi - _debug _domain "$_domain" - _sub_domain="_acme-challenge" + _debug "Check if _acme-challenge record exists in " "$_domain" if ! _extract_record_id "$_sub_domain.$_domain."; then _method="POST" @@ -136,7 +138,7 @@ dns_aruba_add() { #fulldomain dns_aruba_rm() { - fulldomain=$1 + #fulldomain=$1 txtvalue=$2 if ! _initAuth; then From 23c097ac3b587c35757ae6c62775f6b7c9c5ca37 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Mon, 20 Apr 2020 16:27:53 +0200 Subject: [PATCH 14/20] Trvavis 10 --- dnsapi/dns_aruba.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 05bee483..67ccf035 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -103,12 +103,10 @@ _initAuth() { #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" dns_aruba_add() { - fulldomain=$1 + #fulldomain=$1 txtvalue=$2 - _debug _domain "$_domain" _sub_domain="_acme-challenge" - if ! _initAuth; then return 1 fi From ee844a01ed2cbbd2f5bc8e0cc0a53940eb77b3b8 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Tue, 21 Apr 2020 18:28:33 +0200 Subject: [PATCH 15/20] Added Get --- dnsapi/dns_aruba.sh | 105 +++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 26 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 67ccf035..41609d87 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -9,12 +9,12 @@ #ARUBA_AS="xxxxxx" # #API key -#ARUBA_TK="xxxxxxxx" +#ARUBA_TK="xxxxxxxxxxxxxxxx" # #Consumer Key #ARUBA_CK="sdfsdfsdfsdfsdfdsf" -#ARUBA_END_POINT=aruba-it +#ARUBA_END_POINT=aruba-b-it #'aruba-business-it' ARUBA_BUSINESS_IT='https://api.arubabusiness.it' @@ -62,10 +62,10 @@ _initAuth() { ARUBA_END_POINT="${ARUBA_END_POINT:-$(_readaccountconf_mutable ARUBA_END_POINT)}" if [ -z "$ARUBA_END_POINT" ]; then - ARUBA_END_POINT="aruba-it" + ARUBA_END_POINT="aruba-b-it" fi _info "Using ARUBA endpoint: $ARUBA_END_POINT" - if [ "$ARUBA_END_POINT" != "aruba-it" ]; then + if [ "$ARUBA_END_POINT" != "aruba-b-it" ]; then _saveaccountconf_mutable ARUBA_END_POINT "$ARUBA_END_POINT" fi @@ -82,19 +82,20 @@ _initAuth() { fi fi - _info "Checking authentication and get domain details" - - if ! _aruba_rest GET "api/domains/dns/$_domain/details" || _contains "$response" "error" || _contains "$response" "denied"; then - _err "The consumer key is invalid: $ARUBA_CK" - _err "Please retry to create a new one." - _clearaccountconf ARUBA_CK - return 1 - fi - domainData=$(echo "$response" | tr -d '\r') - # get all Ids and peek only values - temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id - domain_id=$temp - _info "DomainId is: $domain_id" + #_info "Checking authentication and get domain details" + + #if ! _aruba_rest GET "api/domains/dns/$_domain/details" || _contains "$response" "error" || _contains "$response" "denied"; then + # _err "The consumer key is invalid: $ARUBA_CK" + # _err "Please retry to create a new one." + # _clearaccountconf ARUBA_CK + # return 1 + #fi + + #domainData=$(echo "$response" | tr -d '\r') + ## get all Ids and peek only values + #temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id + #domain_id=$temp + #_info "DomainId is: $domain_id" _info "Consumer key is ok." return 0 } @@ -103,16 +104,36 @@ _initAuth() { #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" dns_aruba_add() { - #fulldomain=$1 + fulldomain=$1 txtvalue=$2 - _debug _domain "$_domain" - _sub_domain="_acme-challenge" + + #_debug _domain "$_domain" + #_sub_domain="_acme-challenge" + if ! _initAuth; then return 1 fi + _debug "First detect the root zone" + if ! _get_root "$fulldomain"; then + _err "invalid domain" + return 1 + fi + + _info "Get domain details" + + if ! _aruba_rest GET "api/domains/dns/$_domain/details" || _contains "$response" "error" || _contains "$response" "denied"; then + _err "Error reading domn details for : $_domain" + return 1 + fi + domainData=$(echo "$response" | tr -d '\r') + # get all Ids and peek only values + temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id + domain_id=$temp + _info "DomainId is: $domain_id" + _debug "Check if _acme-challenge record exists in " "$_domain" - if ! _extract_record_id "$_sub_domain.$_domain."; then + if ! _extract_record_id "$fulldomain."; then # notice dot at the end, aruba TXT is like this: _acme-challenge.www.domain.com. _method="POST" else _method="PUT" @@ -136,18 +157,20 @@ dns_aruba_add() { #fulldomain dns_aruba_rm() { - #fulldomain=$1 + fulldomain=$1 txtvalue=$2 if ! _initAuth; then return 1 fi + _sub_domain="_acme-challenge" - _debug "Getting TXT record to delete: $_sub_domain.$_domain." - if ! _extract_record_id "$_sub_domain.$_domain"; then + _debug "Getting TXT record to delete: $fulldomain." + if ! _extract_record_id "$fulldomain."; then return 1 fi - _debug "Deleting TXT record: $_sub_domain.$_domain" + + _debug "Deleting TXT record: $fulldomain. Id: $_recordId" if ! _aruba_rest DELETE "api/domains/dns/record/$_recordId"; then return 1 fi @@ -156,11 +179,41 @@ dns_aruba_rm() { #################### Private functions below ################################## +#_acme-challenge.www.domain.com +#returns +# _sub_domain=_acme-challenge.www +# _domain=domain.com +_get_root() { + domain=$1 + i=2 + p=1 + while true; do + h=$(printf "%s" "$domain" | cut -d . -f $i-100) + if [ -z "$h" ]; then + #not valid + return 1 + fi + _debug "doamin to check: $h" + if ! _aruba_rest GET "api/domains/dns/$h/details"; then + return 1 + fi + + if ! _contains "$response" "error" >/dev/null && ! _contains "$response" "denied" >/dev/null; then + _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) + _domain="$h" + return 0 + fi + p=$i + i=$(_math "$i" + 1) + done + return 1 +} + # returns TXT record and put it in_record_id, if esists _extract_record_id() { subdomain="$1" _ids="$(echo "$domainData" | _egrep_o '"Id": [^,]+' | cut -d : -f 2)" - _debug "$_ids" + #_debug "$_ids" #_temp="$(echo $domainData | grep -oP "\"DomainId\":\s\d{1,}," | tr -d ' ')" #_domainids="$(echo $_temp | tr -d ' ')" _names="$(echo "$domainData" | _egrep_o '"Name": [^,]*' | cut -d : -f 2)" From f9131b703d451574f82373ebbc6292b0e8d99265 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 22 Apr 2020 08:55:52 +0200 Subject: [PATCH 17/20] Travis 11 --- dnsapi/dns_aruba.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 41609d87..3effc335 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -106,10 +106,8 @@ _initAuth() { dns_aruba_add() { fulldomain=$1 txtvalue=$2 - #_debug _domain "$_domain" #_sub_domain="_acme-challenge" - if ! _initAuth; then return 1 fi @@ -118,12 +116,11 @@ dns_aruba_add() { if ! _get_root "$fulldomain"; then _err "invalid domain" return 1 - fi - + fi _info "Get domain details" if ! _aruba_rest GET "api/domains/dns/$_domain/details" || _contains "$response" "error" || _contains "$response" "denied"; then - _err "Error reading domn details for : $_domain" + _err "Error reading domn details for : $_domain" return 1 fi domainData=$(echo "$response" | tr -d '\r') @@ -163,13 +160,13 @@ dns_aruba_rm() { if ! _initAuth; then return 1 fi - + _sub_domain="_acme-challenge" _debug "Getting TXT record to delete: $fulldomain." if ! _extract_record_id "$fulldomain."; then return 1 fi - + _debug "Deleting TXT record: $fulldomain. Id: $_recordId" if ! _aruba_rest DELETE "api/domains/dns/record/$_recordId"; then return 1 @@ -194,7 +191,7 @@ _get_root() { return 1 fi _debug "doamin to check: $h" - if ! _aruba_rest GET "api/domains/dns/$h/details"; then + if ! _aruba_rest GET "api/domains/dns/$h/details"; then return 1 fi From 76d196a21a0ca15013a14c2149efc61ce2375e69 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 22 Apr 2020 09:06:56 +0200 Subject: [PATCH 18/20] Travis 12 --- dnsapi/dns_aruba.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 3effc335..89f803ab 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -116,7 +116,7 @@ dns_aruba_add() { if ! _get_root "$fulldomain"; then _err "invalid domain" return 1 - fi + fi _info "Get domain details" if ! _aruba_rest GET "api/domains/dns/$_domain/details" || _contains "$response" "error" || _contains "$response" "denied"; then @@ -127,7 +127,7 @@ dns_aruba_add() { # get all Ids and peek only values temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id domain_id=$temp - _info "DomainId is: $domain_id" + _info "DomainId is: $domain_id" _debug "Check if _acme-challenge record exists in " "$_domain" if ! _extract_record_id "$fulldomain."; then # notice dot at the end, aruba TXT is like this: _acme-challenge.www.domain.com. From 37b001ff50cd6a059ccde5bc854255b304c33f68 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 22 Apr 2020 09:18:26 +0200 Subject: [PATCH 19/20] Travis 13 --- dnsapi/dns_aruba.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index 89f803ab..fb534310 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -90,7 +90,6 @@ _initAuth() { # _clearaccountconf ARUBA_CK # return 1 #fi - #domainData=$(echo "$response" | tr -d '\r') ## get all Ids and peek only values #temp="$(echo "$domainData" | _egrep_o "Id\": [^,]*" | cut -d : -f 2 | head -1)" # first element is zone Id From 0896c6d854e67bec1944b2a8adee600d273c66e7 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Sun, 6 Dec 2020 13:00:03 +0100 Subject: [PATCH 20/20] Update dns_aruba.sh --- dnsapi/dns_aruba.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/dnsapi/dns_aruba.sh b/dnsapi/dns_aruba.sh index fb534310..7e743f28 100644 --- a/dnsapi/dns_aruba.sh +++ b/dnsapi/dns_aruba.sh @@ -28,9 +28,7 @@ _aruba_get_api() { printf "%s" $ARUBA_BUSINESS_IT return ;; - *) - _err "Unknown parameter : $1" return 1 ;;