#!/bin/bash

# s. Ticket 14232842:
# Überprüft alle aktuellen, editierbaren Zonen (also nicht auto-update-Zonen)
# auf Fehler.
path=/var/lib/named/etc/bind/zonen/master
/usr/bin/list_editable_zones |
while read zone; do
#	echo -ne "\r$zone: "
#	if [ -e "$zone" ]; then
#		cat <<_
#Datei "$zone" existiert im aktuellen Verzeichnis bereits.
#=> Programmabbruch aus Sicherheitsgründen.
#_
#		exit 1
#	fi
	result=$( /usr/sbin/named-checkzone -i full -k fail -m fail -M ignore -n fail -S fail -T ignore -W warn "$zone" "$path/$zone" 2>&1 )
	exitcode=$?
	[ $exitcode -eq 0 ] && [ $( echo "$result" | wc -l ) -eq 2 ] && [ $( echo "$result" | tail -1 ) = 'OK' ] && continue
	echo -e "\n=== $zone ===\n$result"
done
