From cde42308ca5ccc34c5e8dc41d3905c0ddb239091 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 21 Apr 2020 14:53:22 +0200 Subject: [PATCH] Finished bin/get-dns-zonefiles --- bin/get-dns-zonefiles | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/get-dns-zonefiles b/bin/get-dns-zonefiles index 1b5010f..1bfe2c7 100755 --- a/bin/get-dns-zonefiles +++ b/bin/get-dns-zonefiles @@ -115,16 +115,23 @@ get_zone() { info "Get zone '${GREEN}${zone}${NORMAL}' ..." local tmpfile=$( mktemp "${zone}.XXXXXXXXXX.zone" ) + local i=0 + local zone_file="${zone}.$( cur_ts ).${i}.zone" + while [[ -e "${zone_file}" ]] ; do + i=$(( $i + 1 )) + zone_file="${zone}.$( cur_ts ).${i}.zone" + done dig axfr "${zone}" >"${tmpfile}" if grep -i 'Transfer failed' "${tmpfile}" >/dev/null ; then error "Could not transfer zone '${RED}${zone}${NORMAL}'." else if type -p named-compilezone >/dev/null ; then - named-compilezone -o - -s relative "${zone}" "${tmpfile}" + named-compilezone -o "${zone_file}" -s relative "${zone}" "${tmpfile}" else - cat "${tmpfile}" | grep -P -v '^\s*(;|$)' + cat "${tmpfile}" | grep -P -v '^\s*(;|$)' >"${zone_file}" fi + info "Created zone file '${GREEN}${zone_file}${NORMAL}'." fi RM "${tmpfile}" -- 2.39.5