Created
December 18, 2008 23:52
-
-
Save adam12/37719 to your computer and use it in GitHub Desktop.
Bash script to use scp to sync nameservers
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 | |
TEMPFILE=`mktemp -p /tmp` | |
HOSTNAME=`hostname` | |
MASTERS="xx.xx.xx.xx" | |
REMOTE_URI="[email protected]" | |
for domain in `/bin/grep ^zone /etc/named.conf | /bin/grep "type master" | /bin/ | |
awk '{print $2}' | /bin/awk -F\" '{print $2}'` | |
do | |
/usr/bin/printf "zone \"${domain}\" {\n type slave;\n file \"/var/named/slaves/${domain}.db\";\n masters { ${MASTERS}; };\n};\n\n" | |
done > ${TEMPFILE} | |
# Transfer File | |
scp ${TEMPFILE} ${REMOTE_URI}:${HOSTNAME}.conf | |
# Reload Remote Nameserver | |
ssh -t ${REMOTE_URI} 'sudo /etc/init.d/named reload' | |
# Cleanup | |
rm -f ${TEMPFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment