renamed doains:refresh to domains:update as former update has been dropped

This commit is contained in:
tracer 2024-04-18 18:04:25 +02:00
parent 65ea85da39
commit 176bd9dc83
2 changed files with 45 additions and 45 deletions

View File

@ -2,7 +2,7 @@
"name": "24unix/bindapi",
"description": "manage Bind9 DNS server via REST API",
"version": "2023.0.1",
"build_number": "343",
"build_number": "344",
"authors": [
{
"name": "Micha Espey",

View File

@ -193,13 +193,13 @@ class CLIController
$this->domainsList();
}))
->addCommand(command: new Command(
name: 'refresh',
name: 'update',
callback: function () {
$this->domainsRefresh();
$this->domainsUpdate();
},
// mandatoryParameters: ['name'],
// optionalParameters: ['A=<IPv4>', 'AAAA=<IPv6>', 'apikey=<API-Key>'])))
description: 'Refresh domains')))
description: 'Update zone files')))
->addCommandGroup(commandGroup: (new CommandGroup(name: 'dyndns', description: 'handle DynDNS entries'))
->addCommand(command: new Command(
name: 'list',
@ -1417,45 +1417,45 @@ class CLIController
/**
*/
function domainsUpdate(): void
{
// check if we're correctly setup
if (!$this->domainController->checkPermissions()) {
echo 'You need to setup the bindAPI first.' . PHP_EOL;
exit(1);
}
$id = intval(value: $this->arguments[1] ?? 0);
$name = $this->arguments['name'] ?? '';
$panelName = $this->arguments['panel'] ?? '';
if ($id == 0) {
echo 'An ID is required' . PHP_EOL;
exit(1);
}
if (!$domain = $this->domainRepository->findByID(id: $id)) {
echo "Domain with ID : $id doesn't exist." . PHP_EOL;
exit(1);
}
if (!empty($panelName)) {
$panel = $this->panelRepository->findByName(name: $panelName);
}
if (empty($name) && empty($panel)) {
echo COLOR_DEFAULT . 'No name or panel given, just recreate the config file' . PHP_EOL;
$this->domainController->updateSlaveZones();
exit(1);
}
$newDomain = new Domain(name: $name, panel: $panelName, id: $domain->getId());
if ($this->domainRepository->update(domain: $newDomain) !== false) {
echo 'Domain server has been updated' . PHP_EOL;
$this->domainController->updateSlaveZones();
} else {
echo 'Error while updating domain server.' . PHP_EOL;
}
}
// function domainsUpdate(): void
// {
// // check if we're correctly setup
// if (!$this->domainController->checkPermissions()) {
// echo 'You need to setup the bindAPI first.' . PHP_EOL;
// exit(1);
// }
//
// $id = intval(value: $this->arguments[1] ?? 0);
// $name = $this->arguments['name'] ?? '';
// $panelName = $this->arguments['panel'] ?? '';
//
// if ($id == 0) {
// echo 'An ID is required' . PHP_EOL;
// exit(1);
// }
// if (!$domain = $this->domainRepository->findByID(id: $id)) {
// echo "Domain with ID : $id doesn't exist." . PHP_EOL;
// exit(1);
// }
//
// if (!empty($panelName)) {
// $panel = $this->panelRepository->findByName(name: $panelName);
// }
//
// if (empty($name) && empty($panel)) {
// echo COLOR_DEFAULT . 'No name or panel given, just recreate the config file' . PHP_EOL;
// $this->domainController->updateSlaveZones();
// exit(1);
// }
// $newDomain = new Domain(name: $name, panel: $panelName, id: $domain->getId());
//
// if ($this->domainRepository->update(domain: $newDomain) !== false) {
// echo 'Domain server has been updated' . PHP_EOL;
// $this->domainController->updateSlaveZones();
// } else {
// echo 'Error while updating domain server.' . PHP_EOL;
// }
// }
/**
@ -1738,9 +1738,9 @@ class CLIController
}
private function domainsRefresh(): void
private function domainsUpdate(): void
{
$this->logger->debug(message: "domainsRefresh()");
$this->logger->debug(message: "domainsUpdate()");
$panels = $this->panelRepository->findAll();