aboutsummaryrefslogtreecommitdiff
path: root/cli/health.php
diff options
context:
space:
mode:
Diffstat (limited to 'cli/health.php')
-rwxr-xr-xcli/health.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/cli/health.php b/cli/health.php
index a001f43aa..c6a9c38b7 100755
--- a/cli/health.php
+++ b/cli/health.php
@@ -4,15 +4,15 @@ declare(strict_types=1);
if (php_sapi_name() !== 'cli') {
echo 'Error: This script may only be invoked from command line!', PHP_EOL;
- die(2);
+ die(3);
}
$options = getopt('', ['url::', 'connect_timeout::', 'timeout::']);
-$address = is_string($options['url'] ?? null) ? $options['url'] : 'http://localhost/i/';
+$address = is_string($options['url'] ?? null) ? $options['url'] : 'http://localhost/api/';
$ch = curl_init($address);
if ($ch === false) {
fwrite(STDERR, 'Error: Failed to initialize cURL!' . PHP_EOL);
- die(3);
+ die(4);
}
curl_setopt_array($ch, [
CURLOPT_CONNECTTIMEOUT => is_numeric($options['connect_timeout'] ?? null) ? (int)$options['connect_timeout'] : 3,
@@ -26,6 +26,11 @@ curl_setopt_array($ch, [
$content = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-if ($httpCode !== 200 || !is_string($content) || !str_contains($content, 'jsonVars') || !str_contains($content, '</html>')) {
+if ($httpCode !== 200 || !is_string($content)) {
die(1);
}
+
+$content = rtrim($content, "\n\r");
+if (!str_starts_with($content, '<!DOCTYPE html>') || !str_ends_with($content, '</html>') || !str_contains($content, '/scripts/api.js')) {
+ die(2);
+}