vmmngr 0.1.0-preview: read-only VM Manager extension (installer, vmm-ctl, GUI)

This commit is contained in:
Claw committed 2026-11-17 19:16:16 +01:00
commit 5f664cc8c2
14 files changed
+1422

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
<?php
/**
* vmmngr-boot.inc - bootstrap for all VM Manager pages.
*
* Works both in the extension tree and through the symlinks in /usr/local/www:
* realpath() resolves the link, so the shared library is found either way.
*/
require_once 'auth.inc';
require_once 'guiconfig.inc';
$vmm_self = realpath(__FILE__);
$vmm_root = dirname(dirname($vmm_self));
require_once $vmm_root . '/bin/vmm-lib.php';
if (!function_exists('vmm_badge')) {
function vmm_badge(string $state): string
{
$map = [
'running' => ['vmm-running', gettext('Running')],
'stopped' => ['vmm-stopped', gettext('Stopped')],
'suspended' => ['vmm-suspended', gettext('Suspended')],
'starting' => ['vmm-starting', gettext('Starting')],
'locked' => ['vmm-locked', gettext('Locked')],
];
[$cls, $label] = $map[$state] ?? ['vmm-unknown', ucfirst($state)];
return sprintf('<span class="vmm-badge %s">%s</span>', $cls, htmlspecialchars($label));
}
function vmm_h(string $s): string
{
return htmlspecialchars($s, ENT_QUOTES, 'UTF-8');
}
function vmm_source_label(array $p): string
{
$icon = match ($p['source']) {
'system' => '🖥',
'bundle' => '📦',
default => '⚠',
};
return sprintf('%s %s', $icon, $p['source']);
}
}