From b435a3d6e34b81570c353fb61f00259c3d8563bb Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 12 Sep 2018 04:17:48 -0600 Subject: [PATCH] Fixed array processing for record lookup. Updated testing echo section. --- cfddns.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cfddns.sh b/cfddns.sh index a126a1e..b5f9970 100755 --- a/cfddns.sh +++ b/cfddns.sh @@ -72,6 +72,7 @@ unset accountFile unset ipAddress dnsRecords=() cfDetails=() +record=() ip4=1 ip6=0 @@ -149,14 +150,11 @@ fi ## Check if desired record(s) exist at CloudFlare -for counter in "${dnsRecords[@]}"; do - record=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/ \ - ${cfDetails[2]}/dns_records?name=${dnsRecords[counter]}&type=A" \ - -H "X-Auth-Email: ${cfDetails[0]}" \ - -H "X-Auth-Key: ${cfDetails[1]}" \ - -H "Content-Type: application/json") +for cfLookup in "${dnsRecords[@]}"; do +record+=("$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones/${cfDetails[2]}/dns_records?name=$cfLookup&type=A" -H "X-Auth-Email: ${cfDetails[0]}" -H "X-Auth-Key: ${cfDetails[1]}" -H "Content-Type: application/json")") done + ### Echo results (testing) echo -e "\nBased on parameters provided:" echo -e "\e[0;35mLogin details at: ${accountFile}" @@ -169,5 +167,14 @@ if [ $ip4 -eq 1 ]; then elif [ $ip6 -eq 1 ]; then echo -e "\e[0;92mUpdating AAAA records" fi -echo -e "\e[0;92mPointing records to IP: $ipAddress\e[0m\n" +echo -e "\e[0;92mPointing records to IP: $ipAddress" +echo -e "\e[0m\n" + +echo -e "\e[0;39mRecord check:" +echo "Array length: ${#record[@]}" +echo "Results:" +for cfResult in "${record[@]}"; do + echo -e "\n$cfResult" +done + exit 0