[fix] slave_dns now broken since PR #295
This commit is contained in:
parent
36fb528818
commit
c8d814ff68
|
@ -1,35 +1,33 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
|
||||||
# Rebuild the bind configuration's file
|
// Rebuild the bind configuration's file
|
||||||
# with the IP of the slave dns
|
// with the IP of the slave dns
|
||||||
|
|
||||||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
$FLAGFILE="/run/alternc/refresh_slave";
|
||||||
FLAGFILE="/run/alternc/refresh_slave";
|
$TPL="/etc/alternc/templates/bind/slaveip.conf";
|
||||||
TPL="/etc/alternc/templates/bind/slaveip.conf"
|
$TARGET="/var/lib/alternc/bind/slaveip.conf";
|
||||||
TARGET="/var/lib/alternc/bind/slaveip.conf"
|
|
||||||
|
|
||||||
if [ ! -e "$FLAGFILE" ] ; then
|
if (!file_exists($FLAGFILE)) exit(0);
|
||||||
# Nothing to do
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Source some functions
|
// Bootstrap
|
||||||
. /usr/lib/alternc/functions.sh
|
require_once("/usr/share/alternc/panel/class/config_nochk.php");
|
||||||
|
|
||||||
TMP=$(mktemp /tmp/slaveip.conf.XXXX)
|
$db->query("SELECT ip,class FROM slaveip;");
|
||||||
|
$str="";
|
||||||
|
while ($db->next_record()) {
|
||||||
|
$str.=" ".$db->Record["ip"]."/".$db->Record["class"].";\n";
|
||||||
|
}
|
||||||
|
|
||||||
# Get the slave IP. Remove the "newline" caracters
|
file_put_contents($TARGET, str_replace("//AUTO-SLAVES//",$str, file_get_contents($TPL) ) );
|
||||||
val=$(mysql_query "SELECT concat(ip,'::',class,'; ') FROM slaveip;"|tr '\n' ' ')
|
|
||||||
|
|
||||||
# Add the slaves to the templates, re-add the missing "/" separator of subnet
|
chown($TARGET,"root");
|
||||||
cat "$TPL" | sed -e "s/\/\/AUTO-SLAVES\/\//$val/g" -e "s/::/\//g" > "$TMP"
|
chgrp($TARGET,"bind");
|
||||||
|
chmod($TARGET,0640);
|
||||||
|
|
||||||
# Activate the new configuration
|
putenv("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin");
|
||||||
mv "$TMP" "$TARGET"
|
passthru("rndc reconfig");
|
||||||
chown root:bind "$TARGET"
|
|
||||||
chmod 640 "$TARGET"
|
unlink($FLAGFILE);
|
||||||
|
|
||||||
invoke-rc.d bind9 reload
|
|
||||||
|
|
||||||
# Remove FLAGSLAVE file
|
|
||||||
rm -f "$FLAGFILE"
|
|
||||||
|
|
Loading…
Reference in New Issue