0.5.0: web terminal per VM (ttyd on the serial console, basic auth, auto-stop with the guest)

This commit is contained in:
Claw committed 2026-11-17 20:51:33 +01:00
1 parent b9ad09e717
commit b2a12eb72a
5 files changed
+161 -2

No files matched your search

+29
View File
@@ -24,6 +24,21 @@ if (strtoupper((string)($_SERVER['REQUEST_METHOD'] ?? '')) === 'POST' && isset($
$vmName = $name;
}
if ($verb === 'console_start') {
$res = vmm_console_start($name);
$_SESSION['vmmngr_error'] = $res['ok']
? sprintf(gettext('Web console on http://%s:%d'), $res['host'], $res['port'])
: (string)$res['error'];
header('Location: vmmngr_vm.php?name=' . urlencode($name));
exit;
}
if ($verb === 'console_stop') {
vmm_console_stop($name);
$_SESSION['vmmngr_error'] = gettext('Web console stopped.');
header('Location: vmmngr_vm.php?name=' . urlencode($name));
exit;
}
// media: attach ISOs (install) or eject them
if ($verb === 'install' || $verb === 'eject') {
if ($verb === 'eject') {
@@ -159,6 +174,20 @@ vmm_nav('dashboard');
<td class="celltag"><?=gettext('Serial');?></td>
<td class="celldata vmm-mono">cu -l /dev/nmdm-<?=vmm_h($name);?>.1B</td>
</tr>
<?php $con = vmm_console_status($name); ?>
<tr>
<td class="celltag"><?=gettext('Web terminal');?></td>
<td class="celldata">
<?php if ($con !== null): ?>
<a class="formbtn" href="http://<?=vmm_h((string)$con['host']);?>:<?=(int)$con['port'];?>/" target="_blank">console öffnen</a>
<span class="vmm-mono" style="margin-left:8px;"><?=vmm_h((string)$con['user']);?> / <?=vmm_h((string)$con['pass']);?></span>
<button type="submit" class="formbtn" name="act" value="console_stop:<?=vmm_h($name);?>" style="margin-left:8px;"><?=gettext('Stop');?></button>
<?php else: ?>
<button type="submit" class="formbtn" name="act" value="console_start:<?=vmm_h($name);?>"><?=gettext('Start web console');?></button>
<span style="opacity:.75;margin-left:8px;"><?=gettext('ttyd serves the serial console (text only) with basic auth.');?></span>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>
<?php endif; ?>