From 6b1329eb3c6365a592b59259399a910267ebf99c Mon Sep 17 00:00:00 2001 From: tracer Date: Mon, 21 Mar 2022 14:03:55 +0100 Subject: [PATCH] added logger Signed-off-by: tracer --- src/Controller/DomainController.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Controller/DomainController.php b/src/Controller/DomainController.php index b53c7a8..e68ff56 100644 --- a/src/Controller/DomainController.php +++ b/src/Controller/DomainController.php @@ -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); }