r004: Auto-Restart + WebGUI-Restart-Button + dynamische Version

- Auto-Restart: Binary erkennt Update auf Platte (mtime/size) → rc.mua restart
- WebGUI: 'MUA neu starten'-Button (POST /restart über Config-Server)
- POST-INSTALL/UPDATE: Service wird nach Installation/Update automatisch neu gestartet
- WebGUI: Version dynamisch aus /health (kein hartkodiertes rNNN)
- MUA_VERSION in helpers.ts auf r004
- .txz neu gepackt, SHA256 aktualisiert
This commit is contained in:
Mikei386
2026-08-18 11:40:17 +02:00
parent b05cc89a3d
commit aec6ba76ce
9 changed files with 122 additions and 14 deletions
+36 -1
View File
@@ -49,6 +49,13 @@ $health_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$health_ok = ($health_code === 200);
// Version aus /health lesen (dynamisch, kein hartkodiertes rNNN)
$running_version = '';
if ($health_ok && $health !== false) {
$h = json_decode($health, true);
$running_version = $h['version'] ?? '';
}
// ── Config vom Config-Server laden (Port 3003) ──────────────────────────
$config = null;
$ch = curl_init('http://127.0.0.1:' . $config_port . '/config');
@@ -91,6 +98,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$payload['enabledTools'] = $selected;
}
// C) Service neu starten
if (isset($_POST['action']) && $_POST['action'] === 'restart') {
$ch = curl_init('http://127.0.0.1:' . $config_port . '/restart');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
CURLOPT_CONNECTTIMEOUT => 3,
CURLOPT_POST => true,
]);
$resp_raw = curl_exec($ch);
$resp_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($resp_code === 200) {
$flash_msg = 'MUA wird neu gestartet (Service restart).';
$flash_type = 'ok';
} else {
$flash_msg = 'Fehler beim Neustart (HTTP ' . $resp_code . ')';
$flash_type = 'err';
}
}
if (!empty($payload)) {
$ch = curl_init('http://127.0.0.1:' . $config_port . '/config');
curl_setopt_array($ch, [
@@ -248,7 +276,7 @@ $tool_groups = [
<h2>Details</h2>
<table>
<tr><th>Plugin</th><td>MUA (Mikes Unraid Agent)</td></tr>
<tr><th>Version</th><td>2026.08.18.r003</td></tr>
<tr><th>Version</th><td><?php echo $running_version ? htmlspecialchars($running_version) : '—'; ?></td></tr>
<tr><th>Runtime</th><td>TypeScript (Bun Runtime, kompiliertes Binary)</td></tr>
<tr><th>Binary</th><td><code><?= $binary ?></code> <?= $binary_exists ? '✅' : '❌ fehlt' ?></td></tr>
<tr><th>Port (MCP)</th><td><?= $port ?></td></tr>
@@ -268,3 +296,10 @@ $tool_groups = [
<tr><td>Status</td><td><code>/etc/rc.d/rc.mua status</code></td></tr>
<tr><td>Logs</td><td><code>tail -f /var/log/plugins/mua.log</code></td></tr>
</table>
<h2>Service neu starten</h2>
<p>Startet den MCP-Service neu (z.&nbsp;B. nach einem Plugin-Update, wenn sich das Binary geändert hat).</p>
<form method="post" onsubmit="return confirm('MUA-Service neu starten?');">
<input type="hidden" name="action" value="restart">
<button type="submit" class="btn btn-primary">🔄 MUA neu starten</button>
</form>