36 lines
901 B
Bash
36 lines
901 B
Bash
#!/bin/bash
|
|
|
|
# Rebuild the bind configuration's file
|
|
# with the IP of the slave dns
|
|
|
|
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"
|