changed exit code if error
Signed-off-by: tracer <tracer@24unix.net>
This commit is contained in:
parent
e6ed2271d5
commit
42ac2136a4
|
@ -11,12 +11,9 @@ error_reporting(E_ALL);
|
||||||
|
|
||||||
// 61e6ce5dd8a1b.bc1c314ce364f6878084c254fe4c6345801c43a49bb8eb71
|
// 61e6ce5dd8a1b.bc1c314ce364f6878084c254fe4c6345801c43a49bb8eb71
|
||||||
|
|
||||||
|
|
||||||
use LucidFrame\Console\ConsoleTable;
|
use LucidFrame\Console\ConsoleTable;
|
||||||
use PDO;
|
|
||||||
use UnhandledMatchError;
|
use UnhandledMatchError;
|
||||||
|
|
||||||
|
|
||||||
if (php_sapi_name() !== 'cli') {
|
if (php_sapi_name() !== 'cli') {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -46,15 +43,17 @@ class BindAPI
|
||||||
/**
|
/**
|
||||||
* @param bool|array $panel
|
* @param bool|array $panel
|
||||||
*
|
*
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function checkPing(bool|array $panel): void
|
public function checkPing(bool|array $panel): Bool
|
||||||
{
|
{
|
||||||
|
$error = false;
|
||||||
|
|
||||||
$a = $panel['a'] ?? '';
|
$a = $panel['a'] ?? '';
|
||||||
print(COLOR_YELLOW . $panel['name']);
|
print(COLOR_YELLOW . $panel['name']);
|
||||||
if (!empty($a)) {
|
if (!empty($a)) {
|
||||||
if ($this->checkController->sendCommand(serverName: $panel['name'], versionIP: 4, apiKey: $panel['apikey'], command: 'ping')) {
|
if ($this->checkController->sendCommand(serverName: $panel['name'], versionIP: 4, apiKey: $panel['apikey'], command: 'ping')) {
|
||||||
// if verbose …
|
// TODO if verbose …
|
||||||
print(COLOR_DEFAULT . ' ' . $panel['a'] . ': ' . COLOR_GREEN . 'pong');
|
print(COLOR_DEFAULT . ' ' . $panel['a'] . ': ' . COLOR_GREEN . 'pong');
|
||||||
} else {
|
} else {
|
||||||
$error = true;
|
$error = true;
|
||||||
|
@ -69,6 +68,7 @@ class BindAPI
|
||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,21 +195,28 @@ class BindAPI
|
||||||
function handlePanelsAPIPing()
|
function handlePanelsAPIPing()
|
||||||
{
|
{
|
||||||
$error = false;
|
$error = false;
|
||||||
|
|
||||||
$id = $this->argv[2] ?? 0;
|
$id = $this->argv[2] ?? 0;
|
||||||
|
|
||||||
if ($id != 0) {
|
if ($id != 0) {
|
||||||
$panel = $this->panelController->findByID($id);
|
$panel = $this->panelController->findByID($id);
|
||||||
$this->checkPing($panel);
|
if (!$this->checkPing($panel)) {
|
||||||
|
$error = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$panels = $this->panelController->findAll();
|
$panels = $this->panelController->findAll();
|
||||||
foreach ($panels as $panel) {
|
foreach ($panels as $panel) {
|
||||||
$this->checkPing(panel: $panel);
|
if (!$this->checkPing(panel: $panel)) {
|
||||||
|
$error = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
echo PHP_EOL;
|
||||||
|
if ($error) {
|
||||||
print(PHP_EOL);
|
exit(1);
|
||||||
|
} else {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue