diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-07-12 11:10:09 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-07-12 11:10:09 +0100 |
| commit | 57edb0710ed9d269227550009e1522c883bacd9c (patch) | |
| tree | 943a757c72991da98b5f49978842de4032c183b2 /bin | |
| parent | 5cafd30fce6e27728e651d86a9740c296a63e965 (diff) | |
| download | dns-57edb0710ed9d269227550009e1522c883bacd9c.tar.gz dns-57edb0710ed9d269227550009e1522c883bacd9c.tar.bz2 | |
use a catalog zone to generate the ${ZONES} list
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/get_catalog | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/get_catalog b/bin/get_catalog new file mode 100755 index 0000000..d9e744b --- /dev/null +++ b/bin/get_catalog @@ -0,0 +1,41 @@ +#! /bin/sh +# +# Fetch the catalog zone '$1' from the server '$2' and print a list of zones. + +set -e + +catalog="$1" +server="$2" + +tempfile="$(mktemp -t catalog)" +trap 'rm $tempfile' 0 + +if ! dig "$catalog" axfr @"$server" +noall +answer >"$tempfile"; then + printf >&2 '%s: query failed\n' "$0" + exit 1 +fi + +# Make sure the result has an SOA, otherwise the query failed. +if ! awk <"$tempfile" " +BEGIN { + exitcode=1 +} + +\$1 == \"$catalog.\" && \$4 == \"SOA\" { + exitcode=0 +} + +END { + exit exitcode +} +"; then + printf >&2 '%s: no SOA found in zone; transfer failed?\n' "$0" + exit 1 +fi + +awk <"$tempfile" " +\$1 ~ /zones.$catalog/ && \$4 == \"PTR\" { + zone = \$5 + sub(/\\.$/, \"\", zone) + print zone +}" |
