run checkup withput wrong assumptions
This commit is contained in:
parent
0f9e66bf90
commit
b9925f232f
|
@ -2,7 +2,6 @@
|
||||||
<module type="WEB_MODULE" version="4">
|
<module type="WEB_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="App\" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="App\" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/bindAPI/vendor/composer" />
|
<excludeFolder url="file://$MODULE_DIR$/bindAPI/vendor/composer" />
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="MessDetectorOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCSFixerOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||||
|
<option name="codingStandard" value="Custom" />
|
||||||
|
<option name="customRuleset" value="$PROJECT_DIR$/phpcs.xml.dist" />
|
||||||
|
<option name="highlightLevel" value="WARNING" />
|
||||||
|
<option name="installedPaths" value="$PROJECT_DIR$/vendor/doctrine/coding-standard/lib/Doctrine" />
|
||||||
|
<option name="useInstalledPaths" value="true" />
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
<component name="PhpCodeSniffer">
|
<component name="PhpCodeSniffer">
|
||||||
<phpcs_settings>
|
<phpcs_settings>
|
||||||
<PhpCSConfiguration tool_path="$PROJECT_DIR$/vendor/bin/phpcs" />
|
<PhpCSConfiguration tool_path="$PROJECT_DIR$/vendor/bin/phpcs" />
|
||||||
|
@ -72,9 +86,15 @@
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.1">
|
<component name="PhpProjectSharedConfiguration" php_language_level="8.1">
|
||||||
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
<option name="suggestChangeDefaultLanguageLevel" value="false" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="PhpStanOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
<component name="PhpUnit">
|
<component name="PhpUnit">
|
||||||
<phpunit_settings>
|
<phpunit_settings>
|
||||||
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" phpunit_phar_path="" />
|
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" phpunit_phar_path="" />
|
||||||
</phpunit_settings>
|
</phpunit_settings>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="PsalmOptionsConfiguration">
|
||||||
|
<option name="transferred" value="true" />
|
||||||
|
</component>
|
||||||
</project>
|
</project>
|
33
bin/console
33
bin/console
|
@ -11,13 +11,11 @@ use Exception;
|
||||||
error_reporting(error_level: E_ALL & ~E_DEPRECATED);
|
error_reporting(error_level: E_ALL & ~E_DEPRECATED);
|
||||||
|
|
||||||
if (php_sapi_name() !== 'cli') {
|
if (php_sapi_name() !== 'cli') {
|
||||||
|
echo 'This application must be run on the command line.' . PHP_EOL;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// version, store that somewhere else
|
|
||||||
$version = '0.0.1';
|
|
||||||
|
|
||||||
if (!is_file(filename: dirname(path: __DIR__).'/vendor/autoload.php')) {
|
if (!is_file(filename: dirname(path: __DIR__).'/vendor/autoload.php')) {
|
||||||
die('Required runtime components are missing. Try running "composer install".' . PHP_EOL);
|
die('Required runtime components are missing. Try running "composer install".' . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +24,7 @@ require dirname(path: __DIR__) . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
|
||||||
$shortOpts = 'v::'; // version
|
$shortOpts = 'v::'; // version
|
||||||
$shortOpts = 'q::'; // version
|
$shortOpts .= 'q::'; // quiet
|
||||||
$shortOpts .= "V::"; // verbose
|
$shortOpts .= "V::"; // verbose
|
||||||
$shortOpts .= "h::"; // help
|
$shortOpts .= "h::"; // help
|
||||||
|
|
||||||
|
@ -39,28 +37,29 @@ $longOpts = [
|
||||||
|
|
||||||
$options = getopt(short_options: $shortOpts, long_options: $longOpts, rest_index: $restIndex);
|
$options = getopt(short_options: $shortOpts, long_options: $longOpts, rest_index: $restIndex);
|
||||||
|
|
||||||
|
$arguments = array_slice(array: $argv, offset: $restIndex);
|
||||||
|
|
||||||
if (array_key_exists(key: 'v', array: $options) || array_key_exists(key: 'version', array: $options)) {
|
if (array_key_exists(key: 'v', array: $options) || array_key_exists(key: 'version', array: $options)) {
|
||||||
|
$arguments = 'showVersion';
|
||||||
|
|
||||||
$composerJson = json_decode(json: file_get_contents(filename: dirname(path: __DIR__) . '/composer.json'), associative: true);
|
$composerJson = json_decode(json: file_get_contents(filename: dirname(path: __DIR__) . '/composer.json'), associative: true);
|
||||||
$name = $composerJson['name'];
|
$name = $composerJson['name'];
|
||||||
$decription = $composerJson['decription'];
|
$description = $composerJson['description'];
|
||||||
$version = $composerJson['version'];
|
$version = $composerJson['version'];
|
||||||
$build_number = $composerJson['build_number'];
|
$buildNumber = $composerJson['build_number'];
|
||||||
$authorName = $composerJson['authors'][0]['name'];
|
$authorName = $composerJson['authors'][0]['name'];
|
||||||
$authorEmail = $composerJson['authors'][0]['email'];
|
$authorEmail = $composerJson['authors'][0]['email'];
|
||||||
|
|
||||||
echo "Name: $name\n";
|
echo "Name: $name\n";
|
||||||
echo "Description: $decription\n";
|
echo "Description: $description\n";
|
||||||
echo "Version: $version\n";
|
echo "Version: $version\n";
|
||||||
echo "Build Number: $build_number\n";
|
echo "Build Number: $buildNumber\n";
|
||||||
echo "Author: $authorName ($authorEmail)\n";
|
echo "Author: $authorName ($authorEmail)\n";
|
||||||
|
|
||||||
print("bindAPI version: $version" . PHP_EOL);
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists(key: 'h', array: $options) || array_key_exists(key: 'help', array: $options)) {
|
if (array_key_exists(key: 'h', array: $options) || array_key_exists(key: 'help', array: $options)) {
|
||||||
print("Help …" . PHP_EOL);
|
$arguments = "showUsage";
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists(key: 'q', array: $options) || array_key_exists(key: 'quiet', array: $options)) {
|
if (array_key_exists(key: 'q', array: $options) || array_key_exists(key: 'quiet', array: $options)) {
|
||||||
|
@ -76,7 +75,6 @@ if (array_key_exists(key: 'V', array: $options) || array_key_exists(key: 'verbos
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$arguments = array_slice(array: $argv, offset: $restIndex);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$app = new BindAPI(verbose: $verbose, quiet: $quiet);
|
$app = new BindAPI(verbose: $verbose, quiet: $quiet);
|
||||||
|
@ -88,13 +86,6 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param String $message
|
|
||||||
* @param array $options
|
|
||||||
* @param string $default
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function confirm(string $message = 'Are you sure? ', array $options = ['y', 'n'], string $default = 'n'): bool
|
function confirm(string $message = 'Are you sure? ', array $options = ['y', 'n'], string $default = 'n'): bool
|
||||||
{
|
{
|
||||||
// first $options means true, any other false
|
// first $options means true, any other false
|
||||||
|
@ -102,7 +93,7 @@ function confirm(string $message = 'Are you sure? ', array $options = ['y', 'n']
|
||||||
$first = true;
|
$first = true;
|
||||||
foreach ($options as $option) {
|
foreach ($options as $option) {
|
||||||
// mark default
|
// mark default
|
||||||
if ($option == $default) {
|
if ($option === $default) {
|
||||||
$option = strtoupper(string: $option);
|
$option = strtoupper(string: $option);
|
||||||
}
|
}
|
||||||
if ($first) {
|
if ($first) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"name": "24unix/bindapi",
|
"name": "24unix/bindapi",
|
||||||
"decription": "fo",
|
"description": "manage Bind9 DNS server via REST API",
|
||||||
"version": "2023.0.1",
|
"version": "2023.0.1",
|
||||||
"build_number": "1",
|
"build_number": "322",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Micha Espey",
|
"name": "Micha Espey",
|
||||||
|
|
|
@ -37,9 +37,6 @@ if (php_sapi_name() !== 'cli') {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class CLIController
|
class CLIController
|
||||||
{
|
{
|
||||||
private array $arguments;
|
private array $arguments;
|
||||||
|
@ -261,12 +258,12 @@ class CLIController
|
||||||
$this->webmailDelete();
|
$this->webmailDelete();
|
||||||
},
|
},
|
||||||
mandatoryParameters: ['ID'])));
|
mandatoryParameters: ['ID'])));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function runCheckSetup(): void
|
function runCheckSetup(): void
|
||||||
{
|
{
|
||||||
if (!$this->domainController->checkPermissions(disableVerbose: false)) {
|
if (!$this->domainController->checkPermissions(verbose: false)) {
|
||||||
echo COLOR_RED . 'You need to setup the bindAPI first.' . COLOR_DEFAULT .PHP_EOL;
|
echo COLOR_RED . 'You need to setup the bindAPI first.' . COLOR_DEFAULT .PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,11 +314,6 @@ class CLIController
|
||||||
|
|
||||||
$debug = $this->configController->getConfig(configKey: 'debug');
|
$debug = $this->configController->getConfig(configKey: 'debug');
|
||||||
echo 'bindAPI version: todo (env: todo) ';
|
echo 'bindAPI version: todo (env: todo) ';
|
||||||
if ($debug) {
|
|
||||||
echo 'true';
|
|
||||||
} else {
|
|
||||||
echo 'false';
|
|
||||||
}
|
|
||||||
echo COLOR_DEFAULT . ')' . PHP_EOL;
|
echo COLOR_DEFAULT . ')' . PHP_EOL;
|
||||||
|
|
||||||
echo COLOR_YELLOW . 'Usage:' . PHP_EOL;
|
echo COLOR_YELLOW . 'Usage:' . PHP_EOL;
|
||||||
|
|
|
@ -141,18 +141,18 @@ class DomainController
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function checkPermissions(bool $disableVerbose = false): bool
|
function checkPermissions(bool $verbose = false, bool $quiet = false): bool
|
||||||
{
|
{
|
||||||
|
$this->logger->debug(message: "checkPermissions()");
|
||||||
$setupIsValid = true;
|
$setupIsValid = true;
|
||||||
|
|
||||||
|
if (!$verbose) {
|
||||||
if (!$disableVerbose) {
|
|
||||||
$verbose = $this->configController->getConfig(configKey: 'verbose');
|
$verbose = $this->configController->getConfig(configKey: 'verbose');
|
||||||
} else {
|
|
||||||
$verbose = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->logger->debug(message: "checkPermissions()");
|
if (!$quiet) {
|
||||||
|
$quiet = $this->configController->getConfig(configKey: 'quiet');
|
||||||
|
}
|
||||||
|
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
echo 'Checking permissions...' . PHP_EOL;
|
echo 'Checking permissions...' . PHP_EOL;
|
||||||
|
@ -227,7 +227,6 @@ class DomainController
|
||||||
echo COLOR_RED . "\t❌Group needs write permission!" . PHP_EOL;
|
echo COLOR_RED . "\t❌Group needs write permission!" . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo 'setup is valid:' . $setupIsValid ? 'true' : 'false';
|
|
||||||
return $setupIsValid;
|
return $setupIsValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue