|
|
|
@ -4,13 +4,6 @@ namespace App\Controller;
|
|
|
|
|
|
|
|
|
|
error_reporting(error_level: E_ALL);
|
|
|
|
|
|
|
|
|
|
define(constant_name: 'COLOR_RED', value: "\033[31m");
|
|
|
|
|
define(constant_name: 'COLOR_GREEN', value: "\033[32m");
|
|
|
|
|
define(constant_name: 'COLOR_YELLOW', value: "\033[33m");
|
|
|
|
|
define(constant_name: 'COLOR_BLUE', value: "\033[34m");
|
|
|
|
|
define(constant_name: 'COLOR_WHITE', value: "\033[37m");
|
|
|
|
|
define(constant_name: 'COLOR_DEFAULT', value: "\033[39m");
|
|
|
|
|
|
|
|
|
|
use App\Controller\Commands\Command;
|
|
|
|
|
use App\Controller\Commands\CommandGroup;
|
|
|
|
|
use App\Controller\Commands\CommandGroupContainer;
|
|
|
|
@ -27,6 +20,7 @@ use App\Repository\NameserverRepository;
|
|
|
|
|
use App\Repository\PanelRepository;
|
|
|
|
|
use App\Repository\SettingsRepository;
|
|
|
|
|
use App\Service\ApiClient;
|
|
|
|
|
use App\Utilities\Colors;
|
|
|
|
|
use Arubacao\TldChecker\Validator;
|
|
|
|
|
use Exception;
|
|
|
|
|
use JsonMapper;
|
|
|
|
@ -333,8 +327,8 @@ class CLIController
|
|
|
|
|
function runCheckSetup(): void
|
|
|
|
|
{
|
|
|
|
|
if (!$this->domainController->checkPermissions()) {
|
|
|
|
|
echo COLOR_RED . 'You need to setup the bindAPI permission first.' . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo 'Run ' . COLOR_YELLOW . './bin/console check:setup' . COLOR_DEFAULT . ' as root or with sudo.' . PHP_EOL;
|
|
|
|
|
echo Colors::RED . 'You need to setup the bindAPI permission first.' . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
echo 'Run ' . Colors::YELLOW . './bin/console check:setup' . Colors::DEFAULT . ' as root or with sudo.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -370,14 +364,14 @@ class CLIController
|
|
|
|
|
|
|
|
|
|
$debug = $this->configController->getConfig(configKey: 'debug');
|
|
|
|
|
|
|
|
|
|
echo COLOR_YELLOW . 'Usage:' . PHP_EOL;
|
|
|
|
|
echo COLOR_DEFAULT . "\t./bin/console {options} {arguments}" . PHP_EOL . PHP_EOL;
|
|
|
|
|
echo Colors::YELLOW . 'Usage:' . PHP_EOL;
|
|
|
|
|
echo Colors::DEFAULT . "\t./bin/console {options} {arguments}" . PHP_EOL . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
echo COLOR_YELLOW . 'Options:' . PHP_EOL;
|
|
|
|
|
echo COLOR_GREEN . "\t-v, --version\t\t" . COLOR_DEFAULT . "Display the version of the API" . PHP_EOL;
|
|
|
|
|
echo COLOR_GREEN . "\t-q, --quiet\t\t" . COLOR_DEFAULT . "No output to stdout, for cronjobs" . PHP_EOL . PHP_EOL;
|
|
|
|
|
echo Colors::YELLOW . 'Options:' . PHP_EOL;
|
|
|
|
|
echo Colors::GREEN . "\t-v, --version\t\t" . Colors::DEFAULT . "Display the version of the API" . PHP_EOL;
|
|
|
|
|
echo Colors::GREEN . "\t-q, --quiet\t\t" . Colors::DEFAULT . "No output to stdout, for cronjobs" . PHP_EOL . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
echo COLOR_YELLOW . 'Arguments: ' . COLOR_WHITE . '<mandatory> {optional}' . PHP_EOL;
|
|
|
|
|
echo Colors::YELLOW . 'Arguments: ' . Colors::WHITE . '<mandatory> {optional}' . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
$this->commandGroupContainer->printCommands();
|
|
|
|
|
|
|
|
|
@ -392,9 +386,9 @@ class CLIController
|
|
|
|
|
$this->logger->debug(message: "checkPermissions()");
|
|
|
|
|
|
|
|
|
|
if (!$this->domainController->checkPermissions()) {
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo PHP_EOL . COLOR_DEFAULT;
|
|
|
|
|
echo 'Missing permissions, please run ' . COLOR_YELLOW . './bin/console check:setup' . COLOR_DEFAULT . ' as root or with sudo.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo PHP_EOL . Colors::DEFAULT;
|
|
|
|
|
echo 'Missing permissions, please run ' . Colors::YELLOW . './bin/console check:setup' . Colors::DEFAULT . ' as root or with sudo.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
@ -430,7 +424,7 @@ class CLIController
|
|
|
|
|
|
|
|
|
|
// for /etc/bind/local.zones file
|
|
|
|
|
if (!file_exists(filename: $this->domainController->localZoneFile)) {
|
|
|
|
|
echo 'Could not find ' . COLOR_YELLOW . $this->domainController->localZoneFile . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Could not find ' . Colors::YELLOW . $this->domainController->localZoneFile . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Creating …';
|
|
|
|
|
touch(filename: $this->domainController->localZoneFile);
|
|
|
|
|
if (!file_exists(filename: $this->domainController->localZoneFile)) {
|
|
|
|
@ -449,9 +443,9 @@ class CLIController
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// check /etc/bind/local.zones permissions
|
|
|
|
|
echo 'Found ' . COLOR_YELLOW . $this->domainController->localZoneFile . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Found ' . Colors::YELLOW . $this->domainController->localZoneFile . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
echo 'Check permissions for ' . COLOR_YELLOW . $this->domainController->localZoneFile . COLOR_DEFAULT . ' …';
|
|
|
|
|
echo 'Check permissions for ' . Colors::YELLOW . $this->domainController->localZoneFile . Colors::DEFAULT . ' …';
|
|
|
|
|
|
|
|
|
|
// dont repeat yourself, use check from DomainController FIXME
|
|
|
|
|
$this->domainController->checkPermissions(impersonatedUserId: $impersonatedUserId);
|
|
|
|
@ -460,26 +454,26 @@ class CLIController
|
|
|
|
|
// /etc/bind/local.zones file must be included in /etc/bind/named.conf.local
|
|
|
|
|
$namedConfLocal = file_get_contents(filename: $this->domainController->namedConfLocalFile);
|
|
|
|
|
if (str_contains(haystack: $namedConfLocal, needle: $this->domainController->localZoneFile)) {
|
|
|
|
|
echo 'Found ' . COLOR_YELLOW . $this->domainController->localZoneFile . COLOR_DEFAULT . ' included ' . COLOR_YELLOW . $this->domainController->namedConfLocalFile . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Found ' . Colors::YELLOW . $this->domainController->localZoneFile . Colors::DEFAULT . ' included ' . Colors::YELLOW . $this->domainController->namedConfLocalFile . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Could not find ' . COLOR_YELLOW . $this->domainController->localZoneFile . COLOR_DEFAULT . ' in ' . COLOR_YELLOW . $this->domainController->namedConfLocalFile . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Could not find ' . Colors::YELLOW . $this->domainController->localZoneFile . Colors::DEFAULT . ' in ' . Colors::YELLOW . $this->domainController->namedConfLocalFile . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Adding …';
|
|
|
|
|
$namedConfLocal .= PHP_EOL . 'include "' . $this->domainController->localZoneFile . '";' . PHP_EOL;
|
|
|
|
|
file_put_contents(filename: $this->domainController->namedConfLocalFile, data: $namedConfLocal);
|
|
|
|
|
if (str_contains(haystack: $namedConfLocal, needle: $this->domainController->localZoneFile)) {
|
|
|
|
|
echo ' done.' . PHP_EOL;
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Could not add ' . COLOR_YELLOW . $this->domainController->localZoneFile . COLOR_DEFAULT . ' to ' . COLOR_YELLOW . $this->domainController->namedConfLocalFile . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Could not add ' . Colors::YELLOW . $this->domainController->localZoneFile . Colors::DEFAULT . ' to ' . Colors::YELLOW . $this->domainController->namedConfLocalFile . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check /etc/bind/zones exists
|
|
|
|
|
echo 'Check for ' . COLOR_YELLOW . $this->domainController->localZonesDir . COLOR_DEFAULT . ' …';
|
|
|
|
|
echo 'Check for ' . Colors::YELLOW . $this->domainController->localZonesDir . Colors::DEFAULT . ' …';
|
|
|
|
|
if (is_dir(filename: $this->domainController->localZonesDir)) {
|
|
|
|
|
echo " exists." . PHP_EOL;
|
|
|
|
|
} else {
|
|
|
|
|
echo ' Could not find ' . COLOR_YELLOW . $this->domainController->localZonesDir . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo ' Could not find ' . Colors::YELLOW . $this->domainController->localZonesDir . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Creating …';
|
|
|
|
|
mkdir(directory: $this->domainController->localZonesDir, permissions: 0775, recursive: true);
|
|
|
|
|
echo ' done.' . PHP_EOL;
|
|
|
|
@ -533,7 +527,7 @@ class CLIController
|
|
|
|
|
$this->logger->debug(message: "checkSinglePanel()");
|
|
|
|
|
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . 'KeyHelp-Panel: ' . COLOR_YELLOW . $panel->getName() . COLOR_DEFAULT;
|
|
|
|
|
echo Colors::DEFAULT . 'KeyHelp-Panel: ' . Colors::YELLOW . $panel->getName() . Colors::DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$encryptionKey = $this->configController->getConfig(configKey: 'encryptionKey');
|
|
|
|
@ -541,7 +535,7 @@ class CLIController
|
|
|
|
|
|
|
|
|
|
$f = $panel->getA();
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . ' IPv4: ' . COLOR_YELLOW . $f . COLOR_DEFAULT;
|
|
|
|
|
echo Colors::DEFAULT . ' IPv4: ' . Colors::YELLOW . $f . Colors::DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($panel->getA())) {
|
|
|
|
@ -570,7 +564,7 @@ class CLIController
|
|
|
|
|
$responseTime = 'n/a';
|
|
|
|
|
}
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . ' KeyHelp version: ' . $panelVersion . " ($responseTime seconds)" . PHP_EOL;
|
|
|
|
|
echo Colors::DEFAULT . ' KeyHelp version: ' . $panelVersion . " ($responseTime seconds)" . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($panel->getA())) {
|
|
|
|
@ -631,7 +625,7 @@ class CLIController
|
|
|
|
|
$domainCount = 0;
|
|
|
|
|
foreach ($tmpDomainList as $domain) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . " Domain: " . COLOR_YELLOW . str_pad(string: $domain->getDomain(), length: $maxDomainNameLength);
|
|
|
|
|
echo Colors::DEFAULT . " Domain: " . Colors::YELLOW . str_pad(string: $domain->getDomain(), length: $maxDomainNameLength);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$domain->isSubdomain()) {
|
|
|
|
@ -642,7 +636,7 @@ class CLIController
|
|
|
|
|
|
|
|
|
|
if ($domainCount == 0) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'No second level domains found.' . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo 'No second level domains found.' . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
@ -744,7 +738,7 @@ class CLIController
|
|
|
|
|
$decryptedKey = $this->encryptionController->safeDecrypt(encrypted: $nameserver->getApikey(), key: $encryptionKey);
|
|
|
|
|
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_YELLOW . ' ' . $nameserver->getName();
|
|
|
|
|
echo Colors::YELLOW . ' ' . $nameserver->getName();
|
|
|
|
|
}
|
|
|
|
|
if (!empty($nameserver->getA())) {
|
|
|
|
|
$result = $this->apiClient->sendCommand(
|
|
|
|
@ -767,17 +761,17 @@ class CLIController
|
|
|
|
|
switch ($result['header']) {
|
|
|
|
|
case 200:
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_GREEN . ' OK';
|
|
|
|
|
echo Colors::GREEN . ' OK';
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 401:
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_RED . ' Error: ' . COLOR_YELLOW . $result['data'] . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo Color::RED . ' Error: ' . Colors::YELLOW . $result['data'] . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
case 404:
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_RED . ' ' . $result['header'] . COLOR_DEFAULT;
|
|
|
|
|
echo Color::RED . ' ' . $result['header'] . Colors::DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
if (!empty($this->arguments['fix']) && $this->arguments['fix'] == 'yes') {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
@ -814,7 +808,7 @@ class CLIController
|
|
|
|
|
die("make error handling");
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_GREEN . 'OK' . COLOR_DEFAULT;
|
|
|
|
|
echo Colors::GREEN . 'OK' . Colors::DEFAULT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -985,7 +979,7 @@ class CLIController
|
|
|
|
|
}
|
|
|
|
|
if ($this->panelRepository->update(panel: $panel) !== false) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Panel ' . COLOR_YELLOW . $id . COLOR_DEFAULT . ' has been updated' . PHP_EOL;
|
|
|
|
|
echo 'Panel ' . Colors::YELLOW . $id . Colors::DEFAULT . ' has been updated' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
@ -1040,7 +1034,7 @@ class CLIController
|
|
|
|
|
$error = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "Unknown $type ID $id" . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
$error = true;
|
|
|
|
@ -1101,8 +1095,8 @@ class CLIController
|
|
|
|
|
$maxAAAA = $this->panelRepository->getLongestEntry(field: 'aaaa');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo COLOR_YELLOW . str_pad(string: $server->getName(), length: $maxName);
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo Colors::YELLOW . str_pad(string: $server->getName(), length: $maxName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$encryptionKey = $this->configController->getConfig(configKey: 'encryptionKey');
|
|
|
|
@ -1112,8 +1106,8 @@ class CLIController
|
|
|
|
|
$a = $server->getA() ?? '';
|
|
|
|
|
if (!empty($a)) {
|
|
|
|
|
$this->logger->debug("check a");
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo COLOR_DEFAULT . ' ' . str_pad(string: $a, length: $maxA, pad_type: STR_PAD_LEFT) . ' ';
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo Colors::DEFAULT . ' ' . str_pad(string: $a, length: $maxA, pad_type: STR_PAD_LEFT) . ' ';
|
|
|
|
|
}
|
|
|
|
|
if ($result = $this->apiClient->sendCommand(
|
|
|
|
|
requestType: 'GET',
|
|
|
|
@ -1122,12 +1116,12 @@ class CLIController
|
|
|
|
|
apiKey: $decryptedKey,
|
|
|
|
|
command: 'ping',
|
|
|
|
|
serverType: $type)) {
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
if ($result['data'] == 'pong') {
|
|
|
|
|
echo ' ' . COLOR_GREEN . $result['data'];
|
|
|
|
|
echo ' ' . Colors::GREEN . $result['data'];
|
|
|
|
|
} else {
|
|
|
|
|
echo COLOR_BLUE . ' skip' . COLOR_DEFAULT;
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo Colors::BLUE . ' skip' . Colors::DEFAULT;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo ' ' . $result['data'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1139,8 +1133,8 @@ class CLIController
|
|
|
|
|
$aaaa = $server->getAaaa() ?? '';
|
|
|
|
|
if (!empty($aaaa)) {
|
|
|
|
|
$this->logger->debug("check aaaa");
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo COLOR_DEFAULT . ' ' . str_pad(string: $aaaa, length: $maxAAAA, pad_type: STR_PAD_LEFT) . ' ';
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo Colors::DEFAULT . ' ' . str_pad(string: $aaaa, length: $maxAAAA, pad_type: STR_PAD_LEFT) . ' ';
|
|
|
|
|
}
|
|
|
|
|
if ($result = $this->apiClient->sendCommand(
|
|
|
|
|
requestType: 'GET',
|
|
|
|
@ -1149,12 +1143,12 @@ class CLIController
|
|
|
|
|
apiKey: $decryptedKey,
|
|
|
|
|
command: 'ping',
|
|
|
|
|
serverType: $type)) {
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
if ($result['data'] == 'pong') {
|
|
|
|
|
echo ' ' . COLOR_GREEN . $result['data'];
|
|
|
|
|
echo ' ' . Colors::GREEN . $result['data'];
|
|
|
|
|
} else {
|
|
|
|
|
echo COLOR_BLUE . ' xxskip' . COLOR_DEFAULT;
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo Colors::BLUE . ' xxskip' . Colors::DEFAULT;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo ' ' . $result['data'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1169,8 +1163,8 @@ class CLIController
|
|
|
|
|
exit($e->getMessage() . PHP_EOL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
return !$error;
|
|
|
|
|
}
|
|
|
|
@ -1199,17 +1193,17 @@ class CLIController
|
|
|
|
|
if ($result['error'] === false) {
|
|
|
|
|
$data = $result['data'];
|
|
|
|
|
$decodedData = json_decode(json: $data);
|
|
|
|
|
echo COLOR_DEFAULT . ' Version: ' . COLOR_YELLOW . $decodedData->version;
|
|
|
|
|
echo COLOR_DEFAULT . ' (Build: ' . COLOR_YELLOW . $decodedData->buildnumber . COLOR_DEFAULT . ')' . PHP_EOL;
|
|
|
|
|
echo Colors::DEFAULT . ' Version: ' . Colors::YELLOW . $decodedData->version;
|
|
|
|
|
echo Colors::DEFAULT . ' (Build: ' . Colors::YELLOW . $decodedData->buildnumber . Colors::DEFAULT . ')' . PHP_EOL;
|
|
|
|
|
} else {
|
|
|
|
|
echo COLOR_RED . ' Error: ' . COLOR_YELLOW . $result['data'] . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo Color::RED . ' Error: ' . Colors::YELLOW . $result['data'] . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
// var_dump($result);
|
|
|
|
|
$skipAAAA = true;
|
|
|
|
|
// if ($result['data'] == 'pong') {
|
|
|
|
|
// echo ' ' . COLOR_GREEN . $result['data'];
|
|
|
|
|
// echo ' ' . Colors::GREEN . $result['data'];
|
|
|
|
|
// } else {
|
|
|
|
|
// echo COLOR_BLUE . ' skip' . COLOR_DEFAULT;
|
|
|
|
|
// echo Colors::BLUE . ' skip' . Colors::DEFAULT;
|
|
|
|
|
// if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
// echo ' ' . $result['data'];
|
|
|
|
|
// }
|
|
|
|
@ -1233,9 +1227,9 @@ class CLIController
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo $result;
|
|
|
|
|
// if ($result['data'] == 'pong') {
|
|
|
|
|
// echo ' ' . COLOR_GREEN . $result['data'];
|
|
|
|
|
// echo ' ' . Colors::GREEN . $result['data'];
|
|
|
|
|
// } else {
|
|
|
|
|
// echo COLOR_BLUE . ' xxskip' . COLOR_DEFAULT;
|
|
|
|
|
// echo Colors::BLUE . ' xxskip' . Colors::DEFAULT;
|
|
|
|
|
// if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
// echo ' ' . $result['data'];
|
|
|
|
|
// }
|
|
|
|
@ -1251,8 +1245,8 @@ class CLIController
|
|
|
|
|
exit($e->getMessage() . PHP_EOL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
return !$error;
|
|
|
|
|
}
|
|
|
|
@ -1283,13 +1277,13 @@ class CLIController
|
|
|
|
|
$result = $this->apikeyRepository->insert(apikey: $apikey);
|
|
|
|
|
|
|
|
|
|
if ($name) {
|
|
|
|
|
echo 'API key ' . COLOR_YELLOW . $name . COLOR_DEFAULT;
|
|
|
|
|
echo 'API key ' . Colors::YELLOW . $name . Colors::DEFAULT;
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Unnamed API key ';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo ' with ID ' . COLOR_YELLOW . $result . COLOR_DEFAULT . ' has been generated. Store it in a safe place, it cannot be recovered.' . PHP_EOL;
|
|
|
|
|
echo COLOR_YELLOW . $apiKeyPrefix . '.' . $apikeyRand . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo ' with ID ' . Colors::YELLOW . $result . Colors::DEFAULT . ' has been generated. Store it in a safe place, it cannot be recovered.' . PHP_EOL;
|
|
|
|
|
echo Colors::YELLOW . $apiKeyPrefix . '.' . $apikeyRand . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1357,10 +1351,10 @@ class CLIController
|
|
|
|
|
}
|
|
|
|
|
if ($this->apikeyRepository->findByID(id: $id)) {
|
|
|
|
|
$this->apikeyRepository->delete(id: $id);
|
|
|
|
|
echo 'API key ' . COLOR_YELLOW . $id . COLOR_DEFAULT . ' has been deleted.' . PHP_EOL;
|
|
|
|
|
echo 'API key ' . Colors::YELLOW . $id . Colors::DEFAULT . ' has been deleted.' . PHP_EOL;
|
|
|
|
|
exit(0);
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Unknown ID ' . COLOR_YELLOW . $id . '.' . PHP_EOL;
|
|
|
|
|
echo 'Unknown ID ' . Colors::YELLOW . $id . '.' . PHP_EOL;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1463,20 +1457,20 @@ class CLIController
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo "Found domain: " . COLOR_YELLOW . $foundDomain . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "Found domain: " . Colors::YELLOW . $foundDomain . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get host
|
|
|
|
|
|
|
|
|
|
if ($this->dynDNSRepository->findByName(name: $name)) {
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo "DynDNS host " . COLOR_YELLOW . $name . COLOR_DEFAULT . "already exists." . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "DynDNS host " . Colors::YELLOW . $name . Colors::DEFAULT . "already exists." . PHP_EOL;
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
echo "DynDNS host " . COLOR_YELLOW . $name . COLOR_DEFAULT . "will be created." . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "DynDNS host " . Colors::YELLOW . $name . Colors::DEFAULT . "will be created." . PHP_EOL;
|
|
|
|
|
// insert in db
|
|
|
|
|
$dyndnsHost = new DynDNS(name: $name);
|
|
|
|
|
// why is the property set in the cunstructor and afterwards again? FIXME
|
|
|
|
@ -1494,12 +1488,12 @@ class CLIController
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->panelRepository->findByName(name: $panel)) {
|
|
|
|
|
echo 'Unknown panel: ' . COLOR_YELLOW . $panel . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Unknown panel: ' . Colors::YELLOW . $panel . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
$domain = new Domain(name: $name, panel: $panel);
|
|
|
|
|
$result = $this->domainRepository->insert(domain: $domain);
|
|
|
|
|
echo 'Domain' . COLOR_YELLOW . $name . COLOR_DEFAULT . ' has been created with id ' . COLOR_YELLOW . $result . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Domain' . Colors::YELLOW . $name . Colors::DEFAULT . ' has been created with id ' . Colors::YELLOW . $result . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
$this->domainController->createSlaveZoneFile(domain: $domain);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
@ -1539,12 +1533,12 @@ class CLIController
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->panelRepository->findByName(name: $panel)) {
|
|
|
|
|
echo 'Unknown panel: ' . COLOR_YELLOW . $panel . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Unknown panel: ' . Colors::YELLOW . $panel . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
$domain = new Domain(name: $name, panel: $panel);
|
|
|
|
|
$result = $this->domainRepository->insert(domain: $domain);
|
|
|
|
|
echo 'Domain' . COLOR_YELLOW . $name . COLOR_DEFAULT . ' has been created with id ' . COLOR_YELLOW . $result . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'Domain' . Colors::YELLOW . $name . Colors::DEFAULT . ' has been created with id ' . Colors::YELLOW . $result . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
$this->domainController->createSlaveZoneFile(domain: $domain);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
@ -1578,7 +1572,7 @@ class CLIController
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (empty($name) && empty($panel)) {
|
|
|
|
|
// echo COLOR_DEFAULT . 'No name or panel given, just recreate the config file' . PHP_EOL;
|
|
|
|
|
// echo Colors::DEFAULT . 'No name or panel given, just recreate the config file' . PHP_EOL;
|
|
|
|
|
// $this->domainController->updateSlaveZones();
|
|
|
|
|
// exit(1);
|
|
|
|
|
// }
|
|
|
|
@ -1658,7 +1652,7 @@ class CLIController
|
|
|
|
|
} else {
|
|
|
|
|
$nameserver = new Nameserver(name: $name, a: $a, aaaa: $aaaa, passphrase: $apikey, self: $self);
|
|
|
|
|
$result = $this->nameserverRepository->insert(nameserver: $nameserver);
|
|
|
|
|
echo 'Nameserver ' . COLOR_YELLOW . $name . COLOR_DEFAULT . ' has been created with id ' . COLOR_YELLOW . $result . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo 'Nameserver ' . Colors::YELLOW . $name . Colors::DEFAULT . ' has been created with id ' . Colors::YELLOW . $result . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
$this->createOpenAPIBootstrap();
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
@ -1691,7 +1685,7 @@ class CLIController
|
|
|
|
|
$versionSting = $dbVersion->version->major . '.' . $dbVersion->version->minor . '.' . $dbVersion->version->patch;
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_RED . 'Error: ' . COLOR_DEFAULT . 'Check version settings.' . PHP_EOL;
|
|
|
|
|
echo Color::RED . 'Error: ' . Colors::DEFAULT . 'Check version settings.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
@ -1759,7 +1753,7 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
if (!$this->nameserverRepository->findByID(id: intval(value: $id))) {
|
|
|
|
|
echo 'Nameserver with ID ' . COLOR_YELLOW . $id . COLOR_DEFAULT . " doesn't exist." . PHP_EOL;
|
|
|
|
|
echo 'Nameserver with ID ' . Colors::YELLOW . $id . Colors::DEFAULT . " doesn't exist." . PHP_EOL;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1772,11 +1766,11 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
if ($this->nameserverRepository->update(nameserver: $nameserver) !== false) {
|
|
|
|
|
$this->createOpenAPIBootstrap();
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Nameserver ' . COLOR_YELLOW . $id . COLOR_DEFAULT . ' has been updated.' . PHP_EOL;
|
|
|
|
|
echo 'Nameserver ' . Colors::YELLOW . $id . Colors::DEFAULT . ' has been updated.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Error while updating nameserver ' . COLOR_YELLOW . $id . '.' . PHP_EOL;
|
|
|
|
|
echo 'Error while updating nameserver ' . Colors::YELLOW . $id . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1796,13 +1790,13 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
$id = intval(value: $this->arguments[1] ?? 0);
|
|
|
|
|
if ($id == 0) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Nameserver with ID ' . COLOR_YELLOW . $id . COLOR_DEFAULT . ' not found.' . PHP_EOL;
|
|
|
|
|
echo 'Nameserver with ID ' . Colors::YELLOW . $id . Colors::DEFAULT . ' not found.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
if (!$this->nameserverRepository->findByID(id: $id)) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'There is no nameserver with ID ' . COLOR_YELLOW . $id . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'There is no nameserver with ID ' . Colors::YELLOW . $id . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
@ -1810,7 +1804,7 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
$this->createOpenAPIBootstrap();
|
|
|
|
|
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'The nameserver with ID ' . COLOR_YELLOW . $id . COLOR_DEFAULT . ' has been deleted.' . PHP_EOL;
|
|
|
|
|
echo 'The nameserver with ID ' . Colors::YELLOW . $id . Colors::DEFAULT . ' has been deleted.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1828,8 +1822,8 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo COLOR_DEFAULT . 'You need to add these lines to ' . COLOR_YELLOW . '/etc/bind/local.bindapi.options' . COLOR_DEFAULT . ' on every panel and make sure' . PHP_EOL;
|
|
|
|
|
echo 'that ' . COLOR_YELLOW . 'include "/etc/bind/local.bindapi.options";' . COLOR_DEFAULT . ' exists in ' . COLOR_YELLOW . '/etc/bind/named.conf.options' . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo Colors::DEFAULT . 'You need to add these lines to ' . Colors::YELLOW . '/etc/bind/local.bindapi.options' . Colors::DEFAULT . ' on every panel and make sure' . PHP_EOL;
|
|
|
|
|
echo 'that ' . Colors::YELLOW . 'include "/etc/bind/local.bindapi.options";' . Colors::DEFAULT . ' exists in ' . Colors::YELLOW . '/etc/bind/named.conf.options' . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
$ip = [];
|
|
|
|
|
foreach ($nameservers as $nameserver) {
|
|
|
|
|
if (!empty($nameserver->getA())) {
|
|
|
|
@ -1847,8 +1841,8 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
foreach ($ip as $currentIp)
|
|
|
|
|
echo "\t$currentIp;" . PHP_EOL;
|
|
|
|
|
echo '};' . PHP_EOL;
|
|
|
|
|
echo PHP_EOL . 'After the modification feel free to run ' . COLOR_YELLOW . 'named-checkconf' . COLOR_DEFAULT . ' to ensure there were no errors.' . PHP_EOL;
|
|
|
|
|
echo PHP_EOL . 'Run ' . COLOR_YELLOW . 'rndc reload' . COLOR_DEFAULT . ' to activate the changes.' . PHP_EOL;
|
|
|
|
|
echo PHP_EOL . 'After the modification feel free to run ' . Colors::YELLOW . 'named-checkconf' . Colors::DEFAULT . ' to ensure there were no errors.' . PHP_EOL;
|
|
|
|
|
echo PHP_EOL . 'Run ' . Colors::YELLOW . 'rndc reload' . Colors::DEFAULT . ' to activate the changes.' . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -1864,10 +1858,10 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
{
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
if ($details) {
|
|
|
|
|
echo COLOR_YELLOW . $details . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo Colors::YELLOW . $details . Colors::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;
|
|
|
|
|
echo Colors::YELLOW . 'A7hjZx52.u8Rzj2S5KUvqozPlQwh4k3eDCrLikL8ZYlcdPr488QkbOW2JaS6Hg5syNllgnNOpQv6TntNMzt62LiH5CTlrMovRQhMcwZzM5dOfLKzqEePFRv1y6qZ7CT9' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
@ -1888,7 +1882,7 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "Updating DynDNS host: $hostName" . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1923,7 +1917,7 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($result['header'] == 200) {
|
|
|
|
|
if (!$this->configController->getConfig(configKey: 'quiet')) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
$data = $result['data'];
|
|
|
|
|
$decodedData = json_decode(json: $data, associative: true);
|
|
|
|
|
echo $decodedData['message'] . PHP_EOL;
|
|
|
|
@ -1947,7 +1941,7 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$key = sodium_bin2hex(string: sodium_crypto_secretbox_keygen());
|
|
|
|
|
echo 'Suggested new key : "' . COLOR_YELLOW . $key . COLOR_DEFAULT . '".' . PHP_EOL;
|
|
|
|
|
echo 'Suggested new key : "' . Colors::YELLOW . $key . Colors::DEFAULT . '".' . PHP_EOL;
|
|
|
|
|
echo PHP_EOL;
|
|
|
|
|
exit(0);
|
|
|
|
|
} catch (SodiumException $e) {
|
|
|
|
@ -1966,7 +1960,7 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
|
|
|
|
|
foreach ($panels as $panel) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . 'Checking panel ' . COLOR_YELLOW . $panel->getName() . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo Colors::DEFAULT . 'Checking panel ' . Colors::YELLOW . $panel->getName() . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
$longestEntry = $this->domainRepository->getLongestEntry(field: 'name');
|
|
|
|
|
}
|
|
|
|
|
$encryptionKey = $this->configController->getConfig(configKey: 'encryptionKey');
|
|
|
|
@ -2009,7 +2003,7 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
foreach ($domains as $domain) {
|
|
|
|
|
$domainCount++;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_YELLOW . ' ' . str_pad(string: $domain->domain, length: $longestEntry + 1, pad_type: STR_PAD_RIGHT);
|
|
|
|
|
echo Colors::YELLOW . ' ' . str_pad(string: $domain->domain, length: $longestEntry + 1, pad_type: STR_PAD_RIGHT);
|
|
|
|
|
}
|
|
|
|
|
if ($currentDomain = $this->domainRepository->findByName(name: $domain->domain)) {
|
|
|
|
|
$currentPanel = $currentDomain->getPanel();
|
|
|
|
@ -2018,24 +2012,24 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
$currentDomain->setPanel(panel: $panelName);
|
|
|
|
|
$this->domainRepository->update(domain: $currentDomain);
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . ' updated to: ' . COLOR_YELLOW . $panelName;
|
|
|
|
|
echo Colors::DEFAULT . ' updated to: ' . Colors::YELLOW . $panelName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_GREEN . ' OK' . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo Colors::GREEN . ' OK' . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$newDomain = new Domain(name: $domain->domain, panel: $panel->getName());
|
|
|
|
|
$result = $this->domainRepository->insert(domain: $newDomain);
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . ' has been created with id ' . COLOR_YELLOW . $result . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo Colors::DEFAULT . ' has been created with id ' . Colors::YELLOW . $result . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
unset($currentDomains[$domain->domain]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($domainCount == 0) {
|
|
|
|
|
echo 'No second level domains found.' . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo 'No second level domains found.' . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//clean up stale domains
|
|
|
|
@ -2057,31 +2051,29 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
|
|
|
|
|
public function webmailCheck(): void
|
|
|
|
|
{
|
|
|
|
|
$quiet = $this->configController->getConfig(configKey: 'quiet');
|
|
|
|
|
|
|
|
|
|
if (empty($this->arguments[1])) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . 'You need to supply a domain name.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo Colors::DEFAULT . 'You need to supply a domain name.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
|
$domainName = $this->arguments[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . 'Checking domain ' . COLOR_YELLOW . $domainName . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo Colors::DEFAULT . 'Checking domain ' . Colors::YELLOW . $domainName . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$domain = $this->domainRepository->findByName(name: $domainName)) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo COLOR_DEFAULT . 'Domain ' . $domainName . ' not found on this server.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo Colors::DEFAULT . 'Domain ' . $domainName . ' not found on this server.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$this->domainController->isMasterZone(domain: $domain)) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'This server is not responsible for ' . COLOR_YELLOW . $domainName . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'This server is not responsible for ' . Colors::YELLOW . $domainName . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
@ -2094,8 +2086,8 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
$webmailDomain = 'webmail.' . $domainName;
|
|
|
|
|
|
|
|
|
|
if (!empty($panel->getAAAA())) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'Check using IPv6: ' . COLOR_YELLOW . $panel->getAaaa() . '.' . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Check using IPv6: ' . Colors::YELLOW . $panel->getAaaa() . '.' . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
$result = $this->apiClient->sendCommand(
|
|
|
|
|
requestType: 'GET',
|
|
|
|
@ -2105,8 +2097,8 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
command: 'domains/name/' . $webmailDomain,
|
|
|
|
|
serverType: 'panel');
|
|
|
|
|
} else {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'Check using IPv4: ' . COLOR_YELLOW . $panel->getA() . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Check using IPv4: ' . Colors::YELLOW . $panel->getA() . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
$result = $this->apiClient->sendCommand(
|
|
|
|
|
requestType: 'GET',
|
|
|
|
@ -2118,58 +2110,58 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($result['header'] === 404) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'The domain ' . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . " doesn't exist." . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'The domain ' . Colors::YELLOW . $webmailDomain . Colors::DEFAULT . " doesn't exist." . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'Found ' . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Found ' . Colors::YELLOW . $webmailDomain . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($v4 = dns_get_record(hostname: $webmailDomain, type: DNS_A)[0]) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo "Found IPv4 entry: " . COLOR_YELLOW . $v4['ip'] . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "Found IPv4 entry: " . Colors::YELLOW . $v4['ip'] . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
$v4Test = $this->apiClient->fileGetContents(url: $webmailDomain, versionIP: 4);
|
|
|
|
|
|
|
|
|
|
if ($v4Test['error']) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'There was an error: ' . COLOR_YELLOW . $v4Test['errorMessage'] . COLOR_DEFAULT . '.';
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'There was an error: ' . Colors::YELLOW . $v4Test['errorMessage'] . Colors::DEFAULT . '.';
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'Successfully connected to webserver via ' . COLOR_YELLOW . 'IPv4' . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Successfully connected to webserver via ' . Colors::YELLOW . 'IPv4' . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo "Found no IPv4 entry for " . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "Found no IPv4 entry for " . Colors::YELLOW . $webmailDomain . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($v6 = dns_get_record(hostname: $webmailDomain, type: DNS_AAAA)[0]) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo "Found IPv6 entry: " . COLOR_YELLOW . $v6['ipv6'] . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "Found IPv6 entry: " . Colors::YELLOW . $v6['ipv6'] . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
$v6Test = $this->apiClient->fileGetContents(url: $webmailDomain, versionIP: 6);
|
|
|
|
|
|
|
|
|
|
if ($v6Test['error']) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'There was an error: ' . COLOR_YELLOW . $v6Test['errorMessage'] . COLOR_DEFAULT . '.';
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'There was an error: ' . Colors::YELLOW . $v6Test['errorMessage'] . Colors::DEFAULT . '.';
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo 'Successfully connected to webserver via ' . COLOR_YELLOW . 'IPv6' . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Successfully connected to webserver via ' . Colors::YELLOW . 'IPv6' . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
echo "Found no IPv6 entry for " . COLOR_YELLOW . $webmailDomain . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo "Found no IPv6 entry for " . Colors::YELLOW . $webmailDomain . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2181,12 +2173,12 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
$httpsDirectives = $apacheData->https_directives . PHP_EOL;
|
|
|
|
|
|
|
|
|
|
if (!str_contains(haystack: $httpsDirectives, needle: '# bindAPI - webmailer')) {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Generated config is missing.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
} else {
|
|
|
|
|
if (!$quiet) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Generated config is valid.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(0);
|
|
|
|
@ -2228,7 +2220,7 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
$action = $this->arguments[1];
|
|
|
|
|
if ($action !== 'update') {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'The only allowed argument is "' . COLOR_YELLOW . 'update' . COLOR_DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
echo 'The only allowed argument is "' . Colors::YELLOW . 'update' . Colors::DEFAULT . '.' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
@ -2338,23 +2330,23 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
if ($panelCount != 1) {
|
|
|
|
|
if ($panelCount == 0) {
|
|
|
|
|
echo 'No panel marked as this server.' . PHP_EOL;
|
|
|
|
|
echo 'Use ' . COLOR_YELLOW . 'panels:update <ID> self=yes ' . COLOR_DEFAULT . 'to mark this panel.' . PHP_EOL;
|
|
|
|
|
echo 'Use ' . Colors::YELLOW . 'panels:update <ID> self=yes ' . Colors::DEFAULT . 'to mark this panel.' . PHP_EOL;
|
|
|
|
|
} else {
|
|
|
|
|
echo 'Only one panel can be marked as self.' . PHP_EOL;
|
|
|
|
|
echo 'Use ' . COLOR_YELLOW . 'panels:update <ID> self=no ' . COLOR_DEFAULT . 'to remove the stale panel' . PHP_EOL;
|
|
|
|
|
echo 'Use ' . Colors::YELLOW . 'panels:update <ID> self=no ' . Colors::DEFAULT . 'to remove the stale panel' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Only one panel is designated as our host' . COLOR_GREEN . ' OK' . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo 'Only one panel is designated as our host' . Colors::GREEN . ' OK' . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
$self = $this->panelRepository->getSelf();
|
|
|
|
|
$selfName = $self->getName();
|
|
|
|
|
echo 'The panel is configured to be ' . COLOR_YELLOW . $selfName;
|
|
|
|
|
echo 'The panel is configured to be ' . Colors::YELLOW . $selfName;
|
|
|
|
|
$hostname = gethostname();
|
|
|
|
|
if (strcmp(string1: $hostname, string2: $selfName) === 0) {
|
|
|
|
|
echo COLOR_DEFAULT . ' and that seems to be valid.' . PHP_EOL;
|
|
|
|
|
echo Colors::DEFAULT . ' and that seems to be valid.' . PHP_EOL;
|
|
|
|
|
} else {
|
|
|
|
|
echo PHP_EOL;
|
|
|
|
|
echo $selfName . COLOR_DEFAULT . ' and ' . COLOR_YELLOW . $hostname . COLOR_DEFAULT . ' differ.' . PHP_EOL;
|
|
|
|
|
echo $selfName . Colors::DEFAULT . ' and ' . Colors::YELLOW . $hostname . Colors::DEFAULT . ' differ.' . PHP_EOL;
|
|
|
|
|
echo 'Name mismatch, maybe panel:self not set?' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2373,19 +2365,19 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'No nameserver marked as this server.' . PHP_EOL;
|
|
|
|
|
echo 'The setting is used to generate the default nameserver in SwaggerUI.' . PHP_EOL;
|
|
|
|
|
echo 'Use ' . COLOR_YELLOW . 'nameservers:update <ID> self=yes ' . COLOR_DEFAULT . 'to mark this nameserver.' . PHP_EOL;
|
|
|
|
|
echo 'Use ' . Colors::YELLOW . 'nameservers:update <ID> self=yes ' . Colors::DEFAULT . 'to mark this nameserver.' . PHP_EOL;
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Only one nameserver should be marked as self.' . PHP_EOL;
|
|
|
|
|
echo 'The setting is used to generate the default nameserver in SwaggerUI.' . PHP_EOL;
|
|
|
|
|
echo 'Use ' . COLOR_YELLOW . 'nameservers:update <ID> self=no ' . COLOR_DEFAULT . 'to remove the stale nameserver' . PHP_EOL;
|
|
|
|
|
echo 'Use ' . Colors::YELLOW . 'nameservers:update <ID> self=no ' . Colors::DEFAULT . 'to remove the stale nameserver' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo 'Only one nameserver is designated as our host' . COLOR_GREEN . ' OK' . COLOR_DEFAULT . PHP_EOL;
|
|
|
|
|
echo 'Only one nameserver is designated as our host' . Colors::GREEN . ' OK' . Colors::DEFAULT . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2407,9 +2399,19 @@ const VERSION = '{$versionSting}';
|
|
|
|
|
$nameservers = $this->nameserverRepository->findAll();
|
|
|
|
|
foreach ($nameservers as $nameserver) {
|
|
|
|
|
if (!$this->quiet) {
|
|
|
|
|
echo COLOR_YELLOW . $nameserver->getName();
|
|
|
|
|
echo Colors::YELLOW . $nameserver->getName();
|
|
|
|
|
$this->checkNameserverVersion(server: $nameserver);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function checkCache()
|
|
|
|
|
{
|
|
|
|
|
if (function_exists(function: 'opcache_reset')) {
|
|
|
|
|
opcache_reset();
|
|
|
|
|
echo 'Cache cleared.' . PHP_EOL;
|
|
|
|
|
} else {
|
|
|
|
|
echo Color::RED . 'Errror: ' . Colors::DEFAULT . 'Missing function opcache_clear()' . PHP_EOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|