Skip to content

Commit

Permalink
restores while loop for get_soa
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-burns committed Jun 24, 2024
1 parent 1085287 commit 64f7376
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions functions/get_soa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ get_soa() {
# returns string of most granular superdomain of fqdn parameter that contains a SOA resource record
#
local soa_fqdn="${1}"
soa_fqdn="$(dig +noall +authority ${1} SOA | cut -f1)"
if [[ "${soa_fqdn}" == "" ]]; then
soa_fqdn="${1}"
fi
while [[ ! -n $(dig +short ${soa_fqdn} SOA) ]]
do
soa_fqdn=${soa_fqdn#*.}
[[ ! "${soa_fqdn}" == *"."* ]] && soa_fqdn="" && break
done

# soa_fqdn="$(dig +noall +authority ${1} SOA | cut -f1)"
# if [[ "${soa_fqdn}" == "" ]]; then
# soa_fqdn="${1}"
# fi
echo ${soa_fqdn}
}

Expand All @@ -32,7 +38,7 @@ get_soa_master() {
if [[ -n ${TEST} ]]; then
printf "** TEST get_soa()\n"
DEBUG="true"
for test in zenr.io _signal.zenr.io request._signal.zenr.io test5.test4.test3.test2.test1.zembla.zenr.io test1.testzone.zenr.io test5.test4.test3.test2.test1.zembla.zenr.io.rubbish
for test in zenr.io _signal.zenr.io request._signal.zenr.io test.zembla.zenr.io test5.test4.test3.test2.test1.zembla.zenr.io test1.testzone.zenr.io test5.test4.test3.test2.test1.zembla.zenr.io.rubbish
do
test_ret=$(get_soa ${test})
echo "'${test_ret}' is most granular domain with an SOA resource record for ${test}"
Expand Down

0 comments on commit 64f7376

Please sign in to comment.