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) {
|
||||
echo 'An ID is required' . PHP_EOL;
|
||||
if (!$this->quiet) {
|
||||
echo 'An ID is required' . PHP_EOL;
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if ($apikey) {
|
||||
@ -923,11 +927,14 @@ 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) {
|
||||
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 {
|
||||
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
|
||||
{
|
||||
$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();
|
||||
if (!$this->quiet) {
|
||||
echo ' ' . COLOR_YELLOW . str_pad(string: $domain->getName(), length: $longestEntry + 1, pad_string: " ", pad_type: STR_PAD_RIGHT) ;
|
||||
}
|
||||
|
||||
if (!file_exists(filename: $zoneFile)) {
|
||||
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]);
|
||||
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;
|
||||
}
|
||||
$this->createSlaveZoneFile(domain: $domain);
|
||||
} else {
|
||||
echo 'missing value: ' . $zoneFile;
|
||||
}
|
||||
if (!$this->quiet) {
|
||||
echo COLOR_DEFAULT . 'Zone already exists.' . PHP_EOL;
|
||||
if (($key = array_search(needle: $zoneFile, haystack: $existingZones)) !== false) {
|
||||
if (isset($existingZones[$key])) {
|
||||
unset($existingZones[$key]);
|
||||
}
|
||||
} 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
|
||||
|
Loading…
Reference in New Issue
Block a user