maketank-scripts from ansible
This commit is contained in:
30
roles/mkt-scripts/files/powerdns/cleanup_slave_zones.sh
Executable file
30
roles/mkt-scripts/files/powerdns/cleanup_slave_zones.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
##### PUPPET ###############
|
||||
# from here: http://hostingondemand.nl/techniek/pdns-clean-up-script/
|
||||
# Dependencies:
|
||||
# bind-utils
|
||||
# sqlite3
|
||||
#### Config ################################
|
||||
|
||||
DB="/var/lib/powerdns/pdns.sqlite3"
|
||||
|
||||
#### End of Config #########################
|
||||
SQL="/usr/bin/sqlite3 ${DB}"
|
||||
|
||||
check() {
|
||||
dig @$1 $2 -t SOA +noall +answer +nocomment | grep -q maketank.net
|
||||
if [ $? != 0 ]; then
|
||||
echo "$1 $2: Server not AUTH or SERVfail - removing zone..."
|
||||
DOMAIN_ID=`$SQL "SELECT id FROM domains WHERE name=\'$2\' AND type=\'SLAVE\' AND master=\'$1\' LIMIT 1;"`
|
||||
$SQL "DELETE FROM records WHERE domain_id=\'$DOMAIN_ID\';"
|
||||
$SQL "DELETE FROM domains WHERE id=\'$DOMAIN_ID\';"
|
||||
fi
|
||||
}
|
||||
|
||||
MASTERS=(`$SQL "SELECT DISTINCT ip FROM supermasters;"`)
|
||||
for m in "${MASTERS[@]}"; do
|
||||
NAMES=(`$SQL "SELECT name FROM domains WHERE type = \'SLAVE\' AND master = \'${m}\';"`)
|
||||
for d in "${NAMES[@]}"; do
|
||||
check ${m} ${d}
|
||||
done
|
||||
done
|
||||
Reference in New Issue
Block a user