Alternc  latest
Alternc logiel libre pour l'hébergement
slave_dns
Go to the documentation of this file.
1 #!/usr/bin/php
2 <?php
3 
4 // Rebuild the bind configuration's file
5 // with the IP of the slave dns
6 
7 $FLAGFILE="/run/alternc/refresh_slave";
8 $TPL="/etc/alternc/templates/bind/slaveip.conf";
9 $TARGET="/var/lib/alternc/bind/slaveip.conf";
10 
11 if (!file_exists($FLAGFILE)) exit(0);
12 
13 // Bootstrap
14 require_once("/usr/share/alternc/panel/class/config_nochk.php");
15 
16 $db->query("SELECT ip,class FROM slaveip;");
17 $str="";
18 while ($db->next_record()) {
19  $str.=" ".$db->Record["ip"]."/".$db->Record["class"].";\n";
20 }
21 
22 file_put_contents($TARGET, str_replace("//AUTO-SLAVES//",$str, file_get_contents($TPL) ) );
23 
24 chown($TARGET,"root");
25 chgrp($TARGET,"bind");
26 chmod($TARGET,0640);
27 
28 putenv("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin");
29 passthru("rndc reconfig");
30 
31 unlink($FLAGFILE);
32 
33