Fixed incorrect zone reload and sign #176

This commit is contained in:
Pinga 2024-11-01 18:52:42 +02:00
parent f62b19ef03
commit ff871dd4ae

View file

@ -40,6 +40,8 @@ Coroutine::create(function () use ($pool, $log, $c) {
$sth->execute();
$timestamp = time();
$tlds = [];
while (list($id, $tld) = $sth->fetch(PDO::FETCH_NUM)) {
$tldRE = preg_quote($tld, '/');
$cleanedTld = ltrim(strtolower($tld), '.');
@ -157,13 +159,10 @@ Coroutine::create(function () use ($pool, $log, $c) {
file_put_contents("{$basePath}/{$cleanedTld}.zone", $completed_zone);
if ($c['dns_server'] == 'opendnssec') {
chown("{$basePath}/{$cleanedTld}.zone", 'opendnssec');
chgrp("{$basePath}/{$cleanedTld}.zone", 'opendnssec');
}
$tlds[] = $cleanedTld;
}
foreach ($tlds as $cleanedTld) {
if ($c['dns_server'] == 'bind') {
exec("rndc reload {$cleanedTld}.", $output, $return_var);
if ($return_var != 0) {
@ -190,6 +189,9 @@ Coroutine::create(function () use ($pool, $log, $c) {
$log->error('Failed to notify secondary servers. ' . $return_var);
}
} elseif ($c['dns_server'] == 'opendnssec') {
chown("{$basePath}/{$cleanedTld}.zone", 'opendnssec');
chgrp("{$basePath}/{$cleanedTld}.zone", 'opendnssec');
exec("ods-signer sign {$cleanedTld}");
sleep(1);
copy("/var/lib/opendnssec/signed/{$cleanedTld}", "/var/lib/bind/{$cleanedTld}.zone.signed");
@ -215,6 +217,7 @@ Coroutine::create(function () use ($pool, $log, $c) {
$log->error('Failed to notify secondary servers. ' . $return_var);
}
}
}
$log->info('job finished successfully.');
} catch (PDOException $e) {