added logger

Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
tracer 2022-03-21 14:03:55 +01:00
parent 5a71d5efde
commit 6b1329eb3c
1 changed files with 18 additions and 8 deletions

View File

@ -49,10 +49,22 @@ class DomainController
$oFile = fopen(filename: $this->localZoneFile, mode: 'w');
foreach ($domains as $domain) {
fputs(stream: $oFile, data: 'include "' . $this->localZonesDir . $domain->getName() . '";' . PHP_EOL);
if (!$this->isMasterZone(domain: $domain)) {
fputs(stream: $oFile, data: 'include "' . $this->localZonesDir . $domain->getName() . '";' . PHP_EOL);
}
}
fclose(stream: $oFile);
exec(command: '/usr/sbin/named-checkconf', output: $output, result_code: $resultCode);
if ($resultCode != 0) {
echo 'There was an error:' . PHP_EOL;
foreach ($output as $line) {
echo $line . PHP_EOL;
}
echo 'You need to fix the error before the configuration can be activated.' . PHP_EOL;
exit(1);
}
exec(command: '/usr/sbin/rndc reload');
}
@ -118,12 +130,11 @@ class DomainController
if (in_array(needle: $name, haystack: $members)) {
echo "\t$name" . COLOR_DEFAULT . ' is in group ' . COLOR_YELLOW . 'bind' . PHP_EOL;
} else {
echo "\t$name needs to be in group $bindGroup!" . PHP_EOL;
echo "\t$name needs to be in group " . COLOR_YELLOW . 'bind' . COLOR_DEFAULT . '!' . PHP_EOL;
}
echo COLOR_DEFAULT . 'Checking ' . COLOR_YELLOW . $this->localZoneFile . PHP_EOL;
$localZoneFilePermissions = fileperms(filename: $this->localZoneFile);
$localZoneFilePermissions = @fileperms(filename: $this->localZoneFile);
if ($localZoneFilePermissions & 0x0010) {
echo COLOR_DEFAULT . "\t✅ Group has write access." . PHP_EOL;
} else {
@ -142,7 +153,7 @@ class DomainController
}
echo COLOR_DEFAULT . 'Checking directory: ' . COLOR_YELLOW . $this->localZonesDir . PHP_EOL;
$localZoneDirPermissions = fileperms(filename: $this->localZonesDir);
$localZoneDirPermissions = @fileperms(filename: $this->localZonesDir);
if ($localZoneDirPermissions & 0x0010) {
echo "\t✅ Group has write access." . PHP_EOL;
} else {
@ -199,9 +210,8 @@ class DomainController
}
// check if we're a master zone
$keyhelpConf = file_get_contents(filename: $this->keyhelpNamedCond);
if (str_contains(haystack: $keyhelpConf, needle: $domain->getName())) {
echo 'We a zone master for ' . $domain->getName() . PHP_EOL;
if ($this->isMasterZone($domain->getName())) {
echo 'We are zone master for ' . $domain->getName() . PHP_EOL;
exit(1);
}