add experimental bind-cron for testing purposes
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -85,7 +85,7 @@ class bind2
|
|||||||
|
|
||||||
// check for subfolder in bind-config-directory
|
// check for subfolder in bind-config-directory
|
||||||
if (! file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) {
|
if (! file_exists(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/'))) {
|
||||||
$this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
|
$this->_logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
|
||||||
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
|
safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.bindconf_directory') . '/domains/')));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ class bind2
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (empty($domains)) {
|
if (empty($domains)) {
|
||||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'No domains found for nameserver-config, skipping...');
|
$this->_logger->logAction(CRON_ACTION, LOG_INFO, 'No domains found for nameserver-config, skipping...');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,13 +130,14 @@ class bind2
|
|||||||
$isFroxlorHostname = true;
|
$isFroxlorHostname = true;
|
||||||
}
|
}
|
||||||
// create zone-file
|
// create zone-file
|
||||||
$zonefile = createDomainZone($domain, $isFroxlorHostname);
|
$this->_logger->logAction(CRON_ACTION, LOG_DEBUG, 'Generating dns zone for '.$domain['domain']);
|
||||||
|
$zonefile = createDomainZone($domain['id'], $isFroxlorHostname);
|
||||||
$domain['zonefile'] = 'domains/' . $domain['domain'] . '.zone';
|
$domain['zonefile'] = 'domains/' . $domain['domain'] . '.zone';
|
||||||
$zonefile_name = makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']);
|
$zonefile_name = makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']);
|
||||||
$zonefile_handler = fopen($zonefile_name, 'w');
|
$zonefile_handler = fopen($zonefile_name, 'w');
|
||||||
fwrite($zonefile_handler, $zonefile);
|
fwrite($zonefile_handler, $zonefile);
|
||||||
fclose($zonefile_handler);
|
fclose($zonefile_handler);
|
||||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, '`' . $zonefile_name . '` zone written');
|
$this->_logger->logAction(CRON_ACTION, LOG_INFO, '`' . $zonefile_name . '` zone written');
|
||||||
|
|
||||||
// generate config
|
// generate config
|
||||||
$bindconf_file .= $this->_generateDomainConfig($domain);
|
$bindconf_file .= $this->_generateDomainConfig($domain);
|
||||||
@@ -146,35 +147,37 @@ class bind2
|
|||||||
$bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w');
|
$bindconf_file_handler = fopen(makeCorrectFile(Settings::Get('system.bindconf_directory') . '/froxlor_bind.conf'), 'w');
|
||||||
fwrite($bindconf_file_handler, $bindconf_file);
|
fwrite($bindconf_file_handler, $bindconf_file);
|
||||||
fclose($bindconf_file_handler);
|
fclose($bindconf_file_handler);
|
||||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written');
|
$this->_logger->logAction(CRON_ACTION, LOG_INFO, 'froxlor_bind.conf written');
|
||||||
|
|
||||||
// reload Bind
|
// reload Bind
|
||||||
safe_exec(escapeshellcmd(Settings::Get('system.bindreload_command')));
|
safe_exec(escapeshellcmd(Settings::Get('system.bindreload_command')));
|
||||||
$this->logger->logAction(CRON_ACTION, LOG_INFO, 'Bind9 reloaded');
|
$this->_logger->logAction(CRON_ACTION, LOG_INFO, 'Bind9 reloaded');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _generateDomainConfig($domain = array())
|
private function _generateDomainConfig($domain = array())
|
||||||
{
|
{
|
||||||
|
$this->_logger->logAction(CRON_ACTION, LOG_DEBUG, 'Generating dns config for '.$domain['domain']);
|
||||||
|
|
||||||
$bindconf_file = '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
|
$bindconf_file = '# Domain ID: ' . $domain['id'] . ' - CustomerID: ' . $domain['customerid'] . ' - CustomerLogin: ' . $domain['loginname'] . "\n";
|
||||||
$bindconf_file .= 'zone "' . $domain['domain'] . '" in {' . "\n";
|
$bindconf_file .= 'zone "' . $domain['domain'] . '" in {' . "\n";
|
||||||
$bindconf_file .= ' type master;' . "\n";
|
$bindconf_file .= ' type master;' . "\n";
|
||||||
$bindconf_file .= ' file "' . makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']) . '";' . "\n";
|
$bindconf_file .= ' file "' . makeCorrectFile(Settings::Get('system.bindconf_directory') . '/' . $domain['zonefile']) . '";' . "\n";
|
||||||
$bindconf_file .= ' allow-query { any; };' . "\n";
|
$bindconf_file .= ' allow-query { any; };' . "\n";
|
||||||
|
|
||||||
if (count($this->nameservers) > 0 || count($this->axfrservers) > 0) {
|
if (count($this->_ns) > 0 || count($this->_axfr) > 0) {
|
||||||
// open allow-transfer
|
// open allow-transfer
|
||||||
$bindconf_file .= ' allow-transfer {' . "\n";
|
$bindconf_file .= ' allow-transfer {' . "\n";
|
||||||
// put nameservers in allow-transfer
|
// put nameservers in allow-transfer
|
||||||
if (count($this->nameservers) > 0) {
|
if (count($this->_ns) > 0) {
|
||||||
foreach ($this->nameservers as $ns) {
|
foreach ($this->_ns as $ns) {
|
||||||
foreach ($ns["ips"] as $ip) {
|
foreach ($ns["ips"] as $ip) {
|
||||||
$bindconf_file .= ' ' . $ip . ";\n";
|
$bindconf_file .= ' ' . $ip . ";\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// AXFR server #100
|
// AXFR server #100
|
||||||
if (count($this->axfrservers) > 0) {
|
if (count($this->_axfr) > 0) {
|
||||||
foreach ($this->axfrservers as $axfrserver) {
|
foreach ($this->_axfr as $axfrserver) {
|
||||||
if (validate_ip($axfrserver, true) !== false) {
|
if (validate_ip($axfrserver, true) !== false) {
|
||||||
$bindconf_file .= ' ' . $axfrserver . ';' . "\n";
|
$bindconf_file .= ' ' . $axfrserver . ';' . "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
// necessary includes
|
// necessary includes
|
||||||
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.dns.10.bind.php');
|
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.dns.10.bind.php');
|
||||||
|
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.dns.15.bind.php');
|
||||||
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.10.apache.php');
|
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.10.apache.php');
|
||||||
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.15.apache_fcgid.php');
|
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.15.apache_fcgid.php');
|
||||||
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.20.lighttpd.php');
|
require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.20.lighttpd.php');
|
||||||
@@ -179,11 +180,14 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) {
|
|||||||
* TYPE=4 MEANS THAT SOMETHING IN THE BIND CONFIG HAS CHANGED. REBUILD froxlor_bind.conf IF BIND IS ENABLED
|
* TYPE=4 MEANS THAT SOMETHING IN THE BIND CONFIG HAS CHANGED. REBUILD froxlor_bind.conf IF BIND IS ENABLED
|
||||||
*/
|
*/
|
||||||
elseif ($row['type'] == '4' && (int)Settings::Get('system.bind_enable') != 0) {
|
elseif ($row['type'] == '4' && (int)Settings::Get('system.bind_enable') != 0) {
|
||||||
|
|
||||||
|
$bindclass ="bind2";
|
||||||
|
|
||||||
if (!isset($nameserver)) {
|
if (!isset($nameserver)) {
|
||||||
$nameserver = new bind($cronlog);
|
$nameserver = new $bindclass($cronlog);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::Get('dkim.use_dkim') == '1') {
|
if (Settings::Get('dkim.use_dkim') == '1' && $bindclass == 'bind') {
|
||||||
$nameserver->writeDKIMconfigs();
|
$nameserver->writeDKIMconfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user