Mini Shell
Direktori : /opt/maint/bin/ |
|
Current File : //opt/maint/bin/dns_clean.sh |
#!/bin/bash
# Simple maintenance script to clean orphaned DNS zones on the local server
# Written by Erik S. (e@inmotion.net / ext 834)
# cron config appends stdout/err to /var/log/maint/dnsclean.log
shopt -s nullglob
cd /var/named || exit
for zone_file in *.db
do domain=$(sed 's/.db$//' <<< "$zone_file")
check_dom_owner=$(/scripts/whoowns "$domain")
if [ "$check_dom_owner" == "" ]; then
echo "$(date "+%D %T"): $domain has no owner, auto-cleaning zone file: $zone_file"
rm -f "/var/named/$domain.db"
sed -e "/^zone \"$domain\"/,+4 d" -i /etc/named.conf
fi
done
Zerion Mini Shell 1.0