Compare commits
No commits in common. "94334694d47ae09c1283ab4956fcb217fc37eab5" and "8784acbed9c3e80f26cf33268d608ce6c209b2b0" have entirely different histories.
94334694d4
...
8784acbed9
|
@ -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": "1.0.7",
|
"version": "1.0.7",
|
||||||
"build_number": "351",
|
"build_number": "349",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Micha Espey",
|
"name": "Micha Espey",
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
Copy this files to /etc/systems/system, adapt the path in the service unit and enable the timer by issuing:
|
|
||||||
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable bindAPI.timer
|
|
||||||
systemctl start bindAPI.timer
|
|
||||||
systemctl list-timers
|
|
|
@ -1,5 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=BindAPI Service to check zone file and reload configuration
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/home/users/<user>/<bindApi>/bin/console cron:run -q
|
|
|
@ -1,10 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Runs BindAPI every minute
|
|
||||||
|
|
||||||
[Timer]
|
|
||||||
OnBootSec=1min
|
|
||||||
OnUnitActiveSec=1min
|
|
||||||
Unit=bindAPI.service
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=timers.target
|
|
|
@ -94,12 +94,7 @@ class CLIController
|
||||||
$this->apikeysDelete();
|
$this->apikeysDelete();
|
||||||
},
|
},
|
||||||
mandatoryParameters: ['ID'])))
|
mandatoryParameters: ['ID'])))
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'cron', description: 'Run zone fle maintenance'))
|
|
||||||
->addCommand(command: new Command(
|
|
||||||
name: 'run',
|
|
||||||
callback: function () {
|
|
||||||
$this->cronRun();
|
|
||||||
})))
|
|
||||||
->addCommandGroup(commandGroup: (new CommandGroup(name: 'check', description: 'health checks the system can perform'))
|
->addCommandGroup(commandGroup: (new CommandGroup(name: 'check', description: 'health checks the system can perform'))
|
||||||
->addCommand(command: new Command(
|
->addCommand(command: new Command(
|
||||||
name: 'permissions',
|
name: 'permissions',
|
||||||
|
@ -924,34 +919,13 @@ class CLIController
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->panelRepository->findByID(id: $id)) {
|
if (!$this->panelRepository->findByID(id: $id)) {
|
||||||
if (!$this->quiet) {
|
if (!$this->quiet) {
|
||||||
echo "Panel with ID : $id doesn't exist." . PHP_EOL;
|
echo "Panel with ID : $id doesn't exist." . PHP_EOL;
|
||||||
}
|
}
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($apikey) {
|
if ($apikey) {
|
||||||
// sanity check for panel apikey
|
|
||||||
if (!str_contains(haystack: $apikey, needle: '.')) {
|
|
||||||
$this->exitInvalidPanelApiKey();
|
|
||||||
} else {
|
|
||||||
[$prefix, $key] = explode(separator: '.', string: $apikey);
|
|
||||||
|
|
||||||
$prefixLen = strlen(string: $prefix);
|
|
||||||
if ($prefixLen != 8) {
|
|
||||||
$errorMessage = 'The prefix must be 8 characters long';
|
|
||||||
$this->exitInvalidPanelApiKey(details: $errorMessage);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var_dump($prefix, $key);
|
|
||||||
echo 'Length of prefix: ' . strlen($prefix) . PHP_EOL;
|
|
||||||
echo 'Length of key: ' . strlen($key) . PHP_EOL;
|
|
||||||
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
$panel = new Panel(name: $name, id: $id, a: $a, aaaa: $aaaa, passphrase: $apikey, self: $self);
|
$panel = new Panel(name: $name, id: $id, a: $a, aaaa: $aaaa, passphrase: $apikey, self: $self);
|
||||||
} 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);
|
||||||
|
@ -1126,9 +1100,7 @@ class CLIController
|
||||||
if ($result['data'] == 'pong') {
|
if ($result['data'] == 'pong') {
|
||||||
echo ' ' . COLOR_GREEN . $result['data'];
|
echo ' ' . COLOR_GREEN . $result['data'];
|
||||||
} else {
|
} else {
|
||||||
var_dump($result);
|
echo COLOR_BLUE . ' skip' . COLOR_DEFAULT;
|
||||||
die;
|
|
||||||
echo COLOR_BLUE . ' xxskip' . COLOR_DEFAULT;
|
|
||||||
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
||||||
echo ' ' . $result['data'];
|
echo ' ' . $result['data'];
|
||||||
}
|
}
|
||||||
|
@ -1685,22 +1657,6 @@ class CLIController
|
||||||
$this->domainController->checkDomains();
|
$this->domainController->checkDomains();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exitInvalidPanelApiKey(string $details = null): void
|
|
||||||
{
|
|
||||||
if (!$this->quiet) {
|
|
||||||
if ($details) {
|
|
||||||
echo COLOR_YELLOW . $details . COLOR_DEFAULT . PHP_EOL;
|
|
||||||
}
|
|
||||||
echo 'This is no valid panel apikey. A valid key looks like this one:' . PHP_EOL;
|
|
||||||
echo COLOR_YELLOW . 'A7hjZx52.u8Rzj2S5KUvqozPlQwh4k3eDCrLikL8ZYlcdPr488QkbOW2JaS6Hg5syNllgnNOpQv6TntNMzt62LiH5CTlrMovRQhMcwZzM5dOfLKzqEePFRv1y6qZ7CT9' . PHP_EOL;
|
|
||||||
}
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function exitInvalidNameserverApiKey(string $details = null): void
|
|
||||||
{
|
|
||||||
echo 'fixme';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -1819,7 +1775,7 @@ class CLIController
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($result['error'])) {
|
if (!empty($result['error'])) {
|
||||||
echo 'Error: ' . $result['data'] . PHP_EOL;
|
echo $result['data'] . PHP_EOL;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!empty($result['data'])) {
|
if (!empty($result['data'])) {
|
||||||
|
@ -2186,10 +2142,4 @@ class CLIController
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cronRun()
|
|
||||||
{
|
|
||||||
$this->logger->debug(message: 'cronRun()');
|
|
||||||
$this->domainsUpdate();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,16 +111,11 @@ class DomainController
|
||||||
if (!$this->quiet) {
|
if (!$this->quiet) {
|
||||||
echo 'Removing stale zone: ' . COLOR_YELLOW . $zone . COLOR_DEFAULT . PHP_EOL;
|
echo 'Removing stale zone: ' . COLOR_YELLOW . $zone . COLOR_DEFAULT . PHP_EOL;
|
||||||
}
|
}
|
||||||
echo $zone . PHP_EOL;
|
|
||||||
unlink(filename: $zone);
|
unlink(filename: $zone);
|
||||||
}
|
}
|
||||||
|
|
||||||
$semaphore = $this->localZonesDir . 'zones.flag';
|
|
||||||
if (file_exists(filename: $semaphore)) {
|
|
||||||
unlink(filename: $semaphore);
|
|
||||||
$this->createIncludeFile();
|
$this->createIncludeFile();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function deleteOnNameservers(Domain $domain): void
|
function deleteOnNameservers(Domain $domain): void
|
||||||
|
@ -328,8 +323,6 @@ class DomainController
|
||||||
*/
|
*/
|
||||||
public function createSlaveZoneFile(Domain $domain): bool
|
public function createSlaveZoneFile(Domain $domain): bool
|
||||||
{
|
{
|
||||||
touch(filename: $this->localZonesDir . 'zones.flag');
|
|
||||||
|
|
||||||
$domainName = $domain->getName();
|
$domainName = $domain->getName();
|
||||||
$this->logger->info(message: "createZoneFile($domainName)");
|
$this->logger->info(message: "createZoneFile($domainName)");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue