Centralise dashboard and Docker versions.

Read the dashboard label from this repo's VERSION file, and show the installer VERSION in the footer only on hblink3-docker-install hosts.
This commit is contained in:
Shane Daley
2026-09-03 23:19:13 +01:00
parent ff70da6099
commit e8e065659d
9 changed files with 88 additions and 11 deletions
+61 -3
View File
@@ -1,4 +1,62 @@
<?php
define("VERSION", "Ver 2.0.2");
define("DASH", "ShaYmez-13122024");
?>
function hbmon_read_version_file($path) {
if ($path === '' || !is_readable($path)) {
return '';
}
$raw = @file_get_contents($path);
if ($raw === false) {
return '';
}
$raw = str_replace("\r", '', $raw);
$line = trim(strtok($raw, "\n"));
return $line;
}
function hbmon_dashboard_version() {
$candidates = array(
'/opt/HBMonv2/VERSION',
);
$repo = dirname(__DIR__, 2).'/VERSION';
if (!in_array($repo, $candidates, true)) {
$candidates[] = $repo;
}
foreach ($candidates as $path) {
$ver = hbmon_read_version_file($path);
if ($ver !== '') {
return $ver;
}
}
return '2.1.0';
}
function hbmon_docker_version() {
$compose = '/etc/hblink3/docker-compose.yml';
$marker = '/etc/hblink3/.installer_path';
if (!is_file($compose) && !is_file($marker)) {
return '';
}
$inst = hbmon_read_version_file($marker);
$candidates = array();
if ($inst !== '') {
$candidates[] = rtrim($inst, '/').'/VERSION';
}
$candidates[] = '/opt/hblink3-docker-install/VERSION';
foreach ($candidates as $path) {
$ver = hbmon_read_version_file($path);
if ($ver !== '') {
return $ver;
}
}
return '';
}
if (!defined('DASH')) {
define('DASH', hbmon_dashboard_version());
}
if (!defined('VERSION')) {
define('VERSION', 'Ver '.DASH);
}
if (!defined('DOCKER_VERSION')) {
define('DOCKER_VERSION', hbmon_docker_version());
}