AlternC/src/slave_dns

36 lines
901 B
Plaintext
Raw Normal View History

#!/bin/bash
# Rebuild the bind configuration's file
# with the IP of the slave dns
2015-11-05 16:36:25 +00:00
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
FLAGFILE="/var/run/alternc/refresh_slave";
TPL="/etc/alternc/templates/bind/slaveip.conf"
TARGET="/var/lib/alternc/bind/slaveip.conf"
if [ ! -e "$FLAGFILE" ] ; then
# Nothing to do
exit 0
fi
# Source some functions
. /usr/lib/alternc/functions.sh
TMP=$(mktemp /tmp/slaveip.conf.XXXX)
# Get the slave IP. Remove the "newline" caracters
val=$(mysql_query "SELECT concat(ip,'::',class,'; ') FROM slaveip;"|tr '\n' ' ')
# Add the slaves to the templates, re-add the missing "/" separator of subnet
cat "$TPL" | sed -e "s/\/\/AUTO-SLAVES\/\//$val/g" -e "s/::/\//g" > "$TMP"
# Activate the new configuration
mv "$TMP" "$TARGET"
chown root:bind "$TARGET"
chmod 640 "$TARGET"
invoke-rc.d bind9 reload
# Remove FLAGSLAVE file
rm -f "$FLAGFILE"