From: Frank Brehm Date: Tue, 21 Apr 2020 12:53:22 +0000 (+0200) Subject: Finished bin/get-dns-zonefiles X-Git-Tag: 0.4.1~6^2~5 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=cde42308ca5ccc34c5e8dc41d3905c0ddb239091;p=pixelpark%2Fpp-admin-tools.git Finished bin/get-dns-zonefiles --- 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}"