- src/*.ts: Port von mcp/*.php (helpers, tools, server) - Bun.serve() statt php -S — production-grade HTTP, POST funktioniert - dist/mua-1.0.0-x86_64-1.txz: Slackware-Paket (Binary + rc.mua + mua.page + PHP-Helper) - plugin/mua.plg: .txz-Installation via upgradepkg - scripts/rc.mua: Binary statt php -S - scripts/mua.page: Binary-Info statt PHP-Version - scripts/package.sh: .txz-Builder Fix: MCP-POST-Endpunkt lieferte leeren Body (php -S Limitation). Bun.serve() löst das Problem.
104 lines
3.6 KiB
Plaintext
104 lines
3.6 KiB
Plaintext
---
|
|
Menu="OtherSettings"
|
|
Type="xmenu"
|
|
Title="MUA"
|
|
Icon="cubes"
|
|
---
|
|
<?php
|
|
/**
|
|
* MUA - Mikes Unraid Agent
|
|
* WebGUI-Tab (mua.page)
|
|
* Unraid-Standard .page-Format
|
|
*/
|
|
|
|
$plugin_dir = '/usr/local/emhttp/plugins/mua';
|
|
$port = 3002;
|
|
$pidfile = '/var/run/mua.pid';
|
|
$binary = '/usr/local/bin/mua';
|
|
$endpoint = 'http://' . ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1') . ':' . $port . '/mcp';
|
|
|
|
// Status bestimmen
|
|
$running = false;
|
|
$pid = null;
|
|
if (file_exists($pidfile)) {
|
|
$pid = trim(file_get_contents($pidfile));
|
|
if ($pid && is_numeric($pid) && @posix_kill((int)$pid, 0)) {
|
|
$running = true;
|
|
}
|
|
}
|
|
|
|
// Health-Check
|
|
$health = null;
|
|
$health_code = 0;
|
|
$ch = curl_init('http://127.0.0.1:' . $port . '/health');
|
|
curl_setopt_array($ch, [
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_TIMEOUT => 3,
|
|
CURLOPT_CONNECTTIMEOUT => 2,
|
|
]);
|
|
$health = curl_exec($ch);
|
|
$health_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
$health_ok = ($health_code === 200);
|
|
|
|
$binary_exists = file_exists($binary);
|
|
$tool_count = 21;
|
|
$host_ip = $_SERVER['SERVER_ADDR'] ?? '127.0.0.1';
|
|
?>
|
|
<style>
|
|
.mua-status { padding: 12px 16px; border-radius: 6px; margin: 12px 0; font-size: 0.95em; }
|
|
.mua-status.ok { background: #e8f5e9; border: 1px solid #4caf50; color: #2e7d32; }
|
|
.mua-status.err { background: #ffebee; border: 1px solid #f44336; color: #c62828; }
|
|
.mua-status.warn { background: #fff3e0; border: 1px solid #ff9800; color: #e65100; }
|
|
.mua-endpoint { font-size: 1.1em; color: #4a90d9; font-weight: 600; }
|
|
</style>
|
|
|
|
<?php if ($running): ?>
|
|
<div class="mua-status ok">✅ <strong>MCP-Server läuft</strong> (PID <?= $pid ?>, Port <?= $port ?>)</div>
|
|
<?php else: ?>
|
|
<div class="mua-status err">❌ <strong>MCP-Server läuft nicht</strong> — starte mit <code>/etc/rc.d/rc.mua start</code></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($health_ok): ?>
|
|
<div class="mua-status ok">✅ Health-Check: OK</div>
|
|
<?php elseif ($health !== false): ?>
|
|
<div class="mua-status warn">⚠️ Health-Check: HTTP <?= $health_code ?></div>
|
|
<?php else: ?>
|
|
<div class="mua-status warn">⚠️ Health-Check: nicht erreichbar</div>
|
|
<?php endif; ?>
|
|
|
|
<h2>MCP-Endpunkt</h2>
|
|
<p class="mua-endpoint"><?= $endpoint ?></p>
|
|
<p>Transport: <code>Streamable HTTP</code> (POST-only) · JSON-RPC 2.0</p>
|
|
|
|
<h2>Details</h2>
|
|
<table>
|
|
<tr><th>Plugin</th><td>MUA (Mikes Unraid Agent)</td></tr>
|
|
<tr><th>Version</th><td>1.0.0</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</th><td><?= $port ?></td></tr>
|
|
<tr><th>Host-IP</th><td><?= $host_ip ?></td></tr>
|
|
<tr><th>Tools</th><td><?= $tool_count ?> (Docker: 14, Netzwerk: 6, System: 1)</td></tr>
|
|
<tr><th>Plugin-Verzeichnis</th><td><code><?= $plugin_dir ?></code></td></tr>
|
|
<tr><th>Service</th><td><code>/etc/rc.d/rc.mua</code> (SysVinit)</td></tr>
|
|
</table>
|
|
|
|
<h2>Verwaltung</h2>
|
|
<table>
|
|
<tr><th>Aktion</th><th>Befehl</th></tr>
|
|
<tr><td>Starten</td><td><code>/etc/rc.d/rc.mua start</code></td></tr>
|
|
<tr><td>Stoppen</td><td><code>/etc/rc.d/rc.mua stop</code></td></tr>
|
|
<tr><td>Neu starten</td><td><code>/etc/rc.d/rc.mua restart</code></td></tr>
|
|
<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>Tools</h2>
|
|
<table>
|
|
<tr><th>Kategorie</th><th>Tools</th></tr>
|
|
<tr><td>Docker (14)</td><td>list, inspect, logs, analyze_logs, processes, stats, info, start, stop, restart, create, modify, update, rebuild</td></tr>
|
|
<tr><td>Netzwerk (6)</td><td>inventory, list, inspect, host_state, audit_tcp, lan_probe</td></tr>
|
|
<tr><td>System (1)</td><td>connection_test</td></tr>
|
|
</table>
|