updated domain refresh
This commit is contained in:
parent
2c65f743e7
commit
65ea85da39
|
@ -2,7 +2,7 @@
|
|||
"name": "24unix/bindapi",
|
||||
"description": "manage Bind9 DNS server via REST API",
|
||||
"version": "2023.0.1",
|
||||
"build_number": "342",
|
||||
"build_number": "343",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Micha Espey",
|
||||
|
|
|
@ -911,11 +911,15 @@ class CLIController
|
|||
$self = $this->arguments['self'] ?? '';
|
||||
|
||||
if ($id == 0) {
|
||||
if (!$this->quiet) {
|
||||
echo 'An ID is required' . PHP_EOL;
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
if (!$this->panelRepository->findByID(id: $id)) {
|
||||
if (!$this->quiet) {
|
||||
echo "Panel with ID : $id doesn't exist." . PHP_EOL;
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
if ($apikey) {
|
||||
|
@ -923,13 +927,16 @@ class CLIController
|
|||
} else {
|
||||
$panel = new Panel(name: $name, id: $id, a: $a, aaaa: $aaaa, self: $self);
|
||||
}
|
||||
var_dump($panel);
|
||||
if ($this->panelRepository->update(panel: $panel) !== false) {
|
||||
if (!$this->quiet) {
|
||||
echo 'Panel ' . COLOR_YELLOW . $id . COLOR_DEFAULT . ' has been updated' . PHP_EOL;
|
||||
}
|
||||
} else {
|
||||
if (!$this->quiet) {
|
||||
echo 'Error while updating domain server.' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
|
|
|
@ -70,12 +70,13 @@ class DomainController
|
|||
|
||||
function updateSlaveZones(): void
|
||||
{
|
||||
$this->logger->debug(message: 'Delete all slave zones');
|
||||
$this->logger->debug(message: 'update slave zones');
|
||||
|
||||
$existingZones = glob(pattern: $this->localZonesDir . '*');
|
||||
|
||||
$domains = $this->domainRepository->findAll();
|
||||
$longestEntry = $this->domainRepository->getLongestEntry(field: 'name');
|
||||
$self = $this->panelRepository->getSelf();
|
||||
|
||||
foreach ($domains as $domain) {
|
||||
$zoneFile = $this->localZonesDir . $domain->getName();
|
||||
|
@ -83,6 +84,7 @@ class DomainController
|
|||
echo ' ' . COLOR_YELLOW . str_pad(string: $domain->getName(), length: $longestEntry + 1, pad_string: " ", pad_type: STR_PAD_RIGHT) ;
|
||||
}
|
||||
|
||||
if (strcmp(string1: $self->getName(), string2: $domain->getPanel()) !== 0) {
|
||||
if (!file_exists(filename: $zoneFile)) {
|
||||
if (!$this->quiet) {
|
||||
echo COLOR_GREEN . ' OK' . COLOR_DEFAULT . PHP_EOL;
|
||||
|
@ -100,6 +102,9 @@ class DomainController
|
|||
echo COLOR_DEFAULT . 'Zone already exists.' . PHP_EOL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo COLOR_DEFAULT . 'We are master for ' . COLOR_YELLOW . $domain->getName() . PHP_EOL;
|
||||
}
|
||||
}
|
||||
// remove stale zones
|
||||
foreach ($existingZones as $zone) {
|
||||
|
|
Loading…
Reference in New Issue