Created
October 29, 2016 12:40
-
-
Save genofire/90c7158f77c6fedef365df891de8b96c to your computer and use it in GitHub Desktop.
zone update recursiv and with checkzone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DNS_ZONES_FOLDER='/srv/dns' | |
# Check if DNS zones folder exists | |
if [ ! -d "$DNS_ZONES_FOLDER" ]; then | |
echo "${DNS_ZONES_FOLDER} does not exists!" >&2 | |
exit 1 | |
fi | |
echo "git pull:" | |
for GITDNS in ${DNS_ZONES_FOLDER}/*; do | |
git -C "$GITDNS" pull | |
done | |
echo -e "\nfetch zones:" | |
for DNS_ZONE in $(find $DNS_ZONES_FOLDER -name "*.zone"); do | |
if ! nsd-checkzone "$(basename ${DNS_ZONE} '.zone')" "${DNS_ZONE}"; then | |
continue | |
fi | |
cp "$DNS_ZONE" "/etc/nsd/zone/" | |
done | |
echo -e "\nreload zones:" | |
echo -n "" > /etc/nsd/zones.conf | |
for DNS_ZONE in $(find /etc/nsd/zone/ -name "*.zone"); do | |
echo -e "zone:\n" \ | |
" name: \"$(basename ${DNS_ZONE} '.zone')\"\n" \ | |
" include-pattern: default\n" \ | |
" zonefile: \"$(basename ${DNS_ZONE})\"\n" >> /etc/nsd/zones.conf | |
# Reload zone | |
echo -n "zone $(basename ${DNS_ZONE} '.zone') " | |
nsd-control reload "$(basename ${DNS_ZONE} '.zone')" | |
# Notify slaves about changed zones | |
# should reload do | |
nsd-control notify "$(basename ${DNS_ZONE} '.zone')" | |
done | |
# Reload DNS server configuration | |
nsd-control reconfig >/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment