Refactor: Doku-konformes Plugin-Format (DOCTYPE Entities, Method=update, .page-WebUI)

This commit is contained in:
Mikei386
2026-08-18 07:35:49 +02:00
parent 2c78574aa6
commit 3de8cb055a
2 changed files with 115 additions and 86 deletions
+94 -49
View File
@@ -1,36 +1,39 @@
<?xml version='1.0' standalone='yes'?> <?xml version='1.0' standalone='yes'?>
<!DOCTYPE PLUGIN> <!DOCTYPE PLUGIN [
<!ENTITY name "mua">
<!ENTITY author "Michael">
<!ENTITY version "1.0.0">
<!ENTITY launch "Settings/MUA">
<!ENTITY pluginURL "http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/plugin/mua.plg">
<!ENTITY pluginLOC "/boot/config/plugins/&name;">
<!ENTITY emhttpLOC "/usr/local/emhttp/plugins/&name;">
]>
<PLUGIN <PLUGIN name="&name;"
name="mua" author="&author;"
author="Michael" version="&version;"
version="1.0.0" launch="&launch;"
pluginURL="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/plugin/mua.plg" pluginURL="&pluginURL;"
launch="Settings/MUA" icon="cubes"
support="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent"
min="7.0.0" min="7.0.0"
support="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent"
project="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent"
> >
<CHANGES> <CHANGES>
<![CDATA[ ### 1.0.0
###1.0.0### - Initial release: 21 Docker, network, and system tools as MCP server over HTTP (Streamable HTTP, port 3002).
Initial release: 21 Docker, network, and system tools as MCP server over HTTP (Streamable HTTP, port 3002).
]]>
</CHANGES> </CHANGES>
<!-- <!--
Install script. ===========================================
Klon das Git-Repo und installiert alle Dateien. PRE-INSTALL: Cleanup + Verzeichnisse
===========================================
--> -->
<FILE Run="/bin/bash"> <FILE Run="/bin/bash">
<INLINE> <INLINE>
set -e set -e
PLUGIN_DIR="/usr/local/emhttp/plugins/mua"
CONFIG_DIR="/boot/config/plugins/mua"
GIT_REPO="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent.git"
TMP_DIR="/tmp/mua-install-$$"
echo "" echo ""
echo "====================================================" echo "===================================================="
echo " MUA - Mikes Unraid Agent" echo " MUA - Mikes Unraid Agent"
@@ -38,60 +41,85 @@ echo " Installation"
echo "====================================================" echo "===================================================="
echo "" echo ""
# 1. Verzeichnisse # Verzeichnisse
mkdir -p "$PLUGIN_DIR/mcp" mkdir -p &emhttpLOC;/mcp
mkdir -p "$PLUGIN_DIR/scripts" mkdir -p &emhttpLOC;/scripts
mkdir -p "$CONFIG_DIR" mkdir -p &pluginLOC;
mkdir -p /var/log/plugins
touch /var/log/plugins/mua.log
</INLINE>
</FILE>
<!--
===========================================
GIT-CLONE + DATEIEN INSTALLIEREN
===========================================
-->
<FILE Run="/bin/bash">
<INLINE>
set -e
GIT_REPO="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent.git"
TMP_DIR="/tmp/mua-install-$$"
# 2. Git-Repo klonen
echo " Kloniere Repo..." echo " Kloniere Repo..."
git clone --depth 1 "$GIT_REPO" "$TMP_DIR" 2&gt;&amp;1 | sed 's/^/ /' git clone --depth 1 "$GIT_REPO" "$TMP_DIR" 2&gt;&amp;1 | sed 's/^/ /'
# 3. PHP-Dateien installieren # MCP-Server (PHP)
echo " Installiere MCP-Server..." echo " Installiere MCP-Server..."
cp "$TMP_DIR/mcp/server.php" "$PLUGIN_DIR/mcp/" cp "$TMP_DIR/mcp/server.php" &emhttpLOC;/mcp/
cp "$TMP_DIR/mcp/helpers.php" "$PLUGIN_DIR/mcp/" cp "$TMP_DIR/mcp/helpers.php" &emhttpLOC;/mcp/
cp "$TMP_DIR/mcp/tools.php" "$PLUGIN_DIR/mcp/" cp "$TMP_DIR/mcp/tools.php" &emhttpLOC;/mcp/
cp "$TMP_DIR/mcp/selftest.php" "$PLUGIN_DIR/mcp/" cp "$TMP_DIR/mcp/selftest.php" &emhttpLOC;/mcp/
chmod 644 "$PLUGIN_DIR/mcp/"*.php chmod 644 &emhttpLOC;/mcp/*.php
# 4. PHP-Helper (Write-Operationen) # PHP-Helper (Write-Operationen)
echo " Installiere PHP-Helper..." echo " Installiere PHP-Helper..."
cp "$TMP_DIR/scripts/unraid-docker-mcp-helper.php" /usr/local/bin/ cp "$TMP_DIR/scripts/unraid-docker-mcp-helper.php" /usr/local/bin/
chmod 755 /usr/local/bin/unraid-docker-mcp-helper.php chmod 755 /usr/local/bin/unraid-docker-mcp-helper.php
# 5. WebGUI-Tab # WebGUI-Tab (.page-Format)
echo " Installiere WebGUI-Tab..." echo " Installiere WebGUI-Tab..."
cp "$TMP_DIR/scripts/plugin.php" "$PLUGIN_DIR/plugin.php" cp "$TMP_DIR/scripts/mua.page" &emhttpLOC;/mua.page
chmod 644 "$PLUGIN_DIR/plugin.php" chmod 644 &emhttpLOC;/mua.page
# 6. SysVinit-Service # SysVinit-Service
echo " Installiere Service..." echo " Installiere Service..."
cp "$TMP_DIR/scripts/rc.mua" /etc/rc.d/rc.mua cp "$TMP_DIR/scripts/rc.mua" /etc/rc.d/rc.mua
chmod 755 /etc/rc.d/rc.mua chmod 755 /etc/rc.d/rc.mua
# 7. Log-Verzeichnis # Cleanup
mkdir -p /var/log/plugins rm -rf "$TMP_DIR"
touch /var/log/plugins/mua.log
</INLINE>
</FILE>
<!--
===========================================
POST-INSTALL: Selftest + Service starten
===========================================
-->
<FILE Run="/bin/bash">
<INLINE>
set +e
# 8. Selftest
echo " Führe Selftest aus..." echo " Führe Selftest aus..."
php "$PLUGIN_DIR/mcp/selftest.php" 2&gt;&amp;1 | sed 's/^/ /' php &emhttpLOC;/mcp/selftest.php 2&gt;&amp;1 | sed 's/^/ /'
# 9. Service starten
echo " Starte MCP-Server..." echo " Starte MCP-Server..."
/etc/rc.d/rc.mua start /etc/rc.d/rc.mua start
# 10. Health-Check # Health-Check
sleep 2 sleep 2
if curl -sf "http://127.0.0.1:3002/health" > /dev/null 2&gt;&amp;1; then if curl -sf "http://127.0.0.1:3002/health" &gt; /dev/null 2&gt;&amp;1; then
echo "" echo ""
echo " Health-Check: OK" echo " Health-Check: OK"
echo "" echo ""
echo "====================================================" echo "===================================================="
echo " MUA installiert und läuft auf Port 3002" echo " MUA installiert und läuft auf Port 3002"
echo " Endpunkt: http://$(hostname -I | awk '{print $1}'):3002/mcp" echo " Endpunkt: http://$(hostname -I | awk '{print $1}'):3002/mcp"
echo " WebGUI: Settings > MUA" echo " WebGUI: Settings &gt; MUA"
echo "====================================================" echo "===================================================="
else else
echo "" echo ""
@@ -100,14 +128,31 @@ else
echo "====================================================" echo "===================================================="
fi fi
# 11. Cleanup exit 0
rm -rf "$TMP_DIR"
</INLINE> </INLINE>
</FILE> </FILE>
<!-- <!--
Remove script. ===========================================
UPDATE: Alte Dateien bereinigen
===========================================
-->
<FILE Run="/bin/bash" Method="update">
<INLINE>
# Alte Dateien entfernen vor Reinstall
rm -rf &emhttpLOC;/mcp
rm -rf &emhttpLOC;/scripts
rm -f &emhttpLOC;/mua.page
rm -f &emhttpLOC;/plugin.php
</INLINE>
</FILE>
<!--
===========================================
REMOVE: Deinstallation
===========================================
--> -->
<FILE Run="/bin/bash" Method="remove"> <FILE Run="/bin/bash" Method="remove">
<INLINE> <INLINE>
@@ -128,10 +173,10 @@ rm -f /etc/rc.d/rc.mua
rm -f /usr/local/bin/unraid-docker-mcp-helper.php rm -f /usr/local/bin/unraid-docker-mcp-helper.php
# 4. Plugin-Verzeichnis entfernen # 4. Plugin-Verzeichnis entfernen
rm -rf /usr/local/emhttp/plugins/mua rm -rf &emhttpLOC;
# 5. Config entfernen # 5. Config entfernen
rm -rf /boot/config/plugins/mua rm -rf &pluginLOC;
# 6. Logs entfernen # 6. Logs entfernen
rm -f /var/log/plugins/mua.log rm -f /var/log/plugins/mua.log
+20 -36
View File
@@ -1,9 +1,14 @@
---
Menu="OtherSettings"
Type="xmenu"
Title="MUA"
Icon="cubes"
---
<?php <?php
/** /**
* MUA - Mikes Unraid Agent * MUA - Mikes Unraid Agent
* WebGUI-Tab (plugin.php) * WebGUI-Tab (mua.page)
* Wird vom Unraid-WebGUI geladen, wenn der Tab "Settings/MUA" geöffnet wird. * Unraid-Standard .page-Format
* Zeigt Status, Endpunkt und Health-Check.
*/ */
$plugin_dir = '/usr/local/emhttp/plugins/mua'; $plugin_dir = '/usr/local/emhttp/plugins/mua';
@@ -23,6 +28,7 @@ if (file_exists($pidfile)) {
// Health-Check // Health-Check
$health = null; $health = null;
$health_code = 0;
$ch = curl_init('http://127.0.0.1:' . $port . '/health'); $ch = curl_init('http://127.0.0.1:' . $port . '/health');
curl_setopt_array($ch, [ curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true, CURLOPT_RETURNTRANSFER => true,
@@ -34,53 +40,34 @@ $health_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch); curl_close($ch);
$health_ok = ($health_code === 200); $health_ok = ($health_code === 200);
// PHP-Version
$php_version = PHP_VERSION; $php_version = PHP_VERSION;
// Tool-Anzahl (aus tools.php)
$tool_count = 21; $tool_count = 21;
// Host-IP
$host_ip = $_SERVER['SERVER_ADDR'] ?? '127.0.0.1'; $host_ip = $_SERVER['SERVER_ADDR'] ?? '127.0.0.1';
?> ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MUA - Mikes Unraid Agent</title>
<style> <style>
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 20px; color: #333; } .mua-status { padding: 12px 16px; border-radius: 6px; margin: 12px 0; font-size: 0.95em; }
h1 { font-size: 1.5em; border-bottom: 2px solid #4a90d9; padding-bottom: 8px; } .mua-status.ok { background: #e8f5e9; border: 1px solid #4caf50; color: #2e7d32; }
.status { padding: 12px 16px; border-radius: 6px; margin: 12px 0; font-size: 0.95em; } .mua-status.err { background: #ffebee; border: 1px solid #f44336; color: #c62828; }
.status.ok { background: #e8f5e9; border: 1px solid #4caf50; color: #2e7d32; } .mua-status.warn { background: #fff3e0; border: 1px solid #ff9800; color: #e65100; }
.status.err { background: #ffebee; border: 1px solid #f44336; color: #c62828; } .mua-endpoint { font-size: 1.1em; color: #4a90d9; font-weight: 600; }
.status.warn { background: #fff3e0; border: 1px solid #ff9800; color: #e65100; }
table { border-collapse: collapse; margin: 12px 0; }
td, th { padding: 8px 12px; border: 1px solid #ddd; text-align: left; }
th { background: #f5f5f5; font-weight: 600; }
code { background: #f5f5f5; padding: 2px 6px; border-radius: 3px; font-size: 0.9em; }
.endpoint { font-size: 1.1em; color: #4a90d9; font-weight: 600; }
</style> </style>
</head>
<body>
<h1>MUA - Mikes Unraid Agent</h1>
<?php if ($running): ?> <?php if ($running): ?>
<div class="status ok">✅ <strong>MCP-Server läuft</strong> (PID <?= $pid ?>, Port <?= $port ?>)</div> <div class="mua-status ok">✅ <strong>MCP-Server läuft</strong> (PID <?= $pid ?>, Port <?= $port ?>)</div>
<?php else: ?> <?php else: ?>
<div class="status err">❌ <strong>MCP-Server läuft nicht</strong> — starte mit <code>/etc/rc.d/rc.mua start</code></div> <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 endif; ?>
<?php if ($health_ok): ?> <?php if ($health_ok): ?>
<div class="status ok">✅ Health-Check: OK</div> <div class="mua-status ok">✅ Health-Check: OK</div>
<?php elseif ($health !== false): ?> <?php elseif ($health !== false): ?>
<div class="status warn">⚠️ Health-Check: HTTP <?= $health_code ?></div> <div class="mua-status warn">⚠️ Health-Check: HTTP <?= $health_code ?></div>
<?php else: ?> <?php else: ?>
<div class="status warn">⚠️ Health-Check: nicht erreichbar</div> <div class="mua-status warn">⚠️ Health-Check: nicht erreichbar</div>
<?php endif; ?> <?php endif; ?>
<h2>MCP-Endpunkt</h2> <h2>MCP-Endpunkt</h2>
<p class="endpoint"><?= $endpoint ?></p> <p class="mua-endpoint"><?= $endpoint ?></p>
<p>Transport: <code>Streamable HTTP</code> (POST-only) · JSON-RPC 2.0</p> <p>Transport: <code>Streamable HTTP</code> (POST-only) · JSON-RPC 2.0</p>
<h2>Details</h2> <h2>Details</h2>
@@ -112,6 +99,3 @@ code { background: #f5f5f5; padding: 2px 6px; border-radius: 3px; font-size: 0.9
<tr><td>Netzwerk (6)</td><td>inventory, list, inspect, host_state, audit_tcp, lan_probe</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> <tr><td>System (1)</td><td>connection_test</td></tr>
</table> </table>
</body>
</html>