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