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}"