From c8d814ff68cb8ae1ee581006d7c94e64907b33fa Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Tue, 23 Oct 2018 17:59:50 +0200 Subject: [PATCH] [fix] slave_dns now broken since PR #295 --- src/slave_dns | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/slave_dns b/src/slave_dns index 0b20420e..b63d476c 100644 --- a/src/slave_dns +++ b/src/slave_dns @@ -1,35 +1,33 @@ -#!/bin/bash +#!/usr/bin/php +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 -val=$(mysql_query "SELECT concat(ip,'::',class,'; ') FROM slaveip;"|tr '\n' ' ') +file_put_contents($TARGET, str_replace("//AUTO-SLAVES//",$str, file_get_contents($TPL) ) ); -# 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" +chown($TARGET,"root"); +chgrp($TARGET,"bind"); +chmod($TARGET,0640); -# Activate the new configuration -mv "$TMP" "$TARGET" -chown root:bind "$TARGET" -chmod 640 "$TARGET" +putenv("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"); +passthru("rndc reconfig"); + +unlink($FLAGFILE); -invoke-rc.d bind9 reload -# Remove FLAGSLAVE file -rm -f "$FLAGFILE"