DNS script check bind9

#! /bin/bash declare -i RET RET=0 rndc reload systemctl restart named.service systemctl status named.service RET=$((RET + $?)) IP_DNS=$(dig @127.0.0.1 plop.acme.local +short) if [ -z "$IP_DNS" ] then RET=$((RET + 1 )) fi FQDN_DNS=$(dig @127.0.0.1 -x "$IP_DNS" +short) if [ -z "$FQDN_DNS" ] then RET=$((RET + 1 )) fi named-checkconf RET=$((RET + $?)) for ZONE in $(awk '/^zone/ { gsub("\"", "") ; print $2 }' /etc/named.conf) do named-checkzone "$ZONE" "/etc/named/db.${ZONE}" RET=$((RET + $?)) dig -t AXFR @127.0.0.1 "$ZONE" |grep -v "^;;" RET=$((RET + $?)) rndc freeze acme.local rndc reload acme.local RET=$((RET + $?)) rndc thaw acme.local done rndc status RET=$((RET + $?)) echo if [ $RET == 0 ] then echo "*** ALL IS OK ***" else echo "** ERROR ***" fi echo exit $RET