MUA: Echte Unraid-Plugin-Struktur
- plugin/mua.plg: <!DOCTYPE PLUGIN> XML mit <FILE Run> + <INLINE> - plugin/plugin.json: Metadaten - scripts/rc.mua: SysVinit-Service (statt systemd) - scripts/plugin.php: WebGUI-Tab (Settings > MUA) - README.md: Aktualisiert - Alte Dateien entfernt (MUA.plg, mua.service, install/update/remove.sh)
This commit is contained in:
1 parent
f4e66ea5a1
commit
1f1e67a3ab
10 files changed
+443
-338
No files matched your search
@@ -1,71 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Plugin>
|
|
||||||
<Name>mua</Name>
|
|
||||||
<Version>1.0.0</Version>
|
|
||||||
<Release>1</Release>
|
|
||||||
<Arch>x86_64</Arch>
|
|
||||||
<Url>https://git-192.168.1.2:33/michael/MUA-Mikes-Unraid-Agent</Url>
|
|
||||||
<Summary>MUA - Mikes Unraid Agent (MCP Server)</Summary>
|
|
||||||
<Description>MUA (Mikes Unraid Agent) is a native Unraid plugin that exposes 21 Docker, network, and system tools as an MCP (Model Context Protocol) server over HTTP (Streamable HTTP transport). Runs locally on the Unraid host - no SSH required. Endpoint: http://<unraid-ip>:3002/mcp</Description>
|
|
||||||
<Author>Michael</Author>
|
|
||||||
<License>MIT</License>
|
|
||||||
<Categories>
|
|
||||||
<Category>Tools</Category>
|
|
||||||
</Categories>
|
|
||||||
<Files>
|
|
||||||
<File>
|
|
||||||
<Name>mcp/server.php</Name>
|
|
||||||
<Path>/usr/local/plugins/mua/mcp/</Path>
|
|
||||||
<Mode>0644</Mode>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<Name>mcp/helpers.php</Name>
|
|
||||||
<Path>/usr/local/plugins/mua/mcp/</Path>
|
|
||||||
<Mode>0644</Mode>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<Name>mcp/tools.php</Name>
|
|
||||||
<Path>/usr/local/plugins/mua/mcp/</Path>
|
|
||||||
<Mode>0644</Mode>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<Name>scripts/unraid-docker-mcp-helper.php</Name>
|
|
||||||
<Path>/usr/local/plugins/mua/scripts/</Path>
|
|
||||||
<Mode>0755</Mode>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<Name>scripts/mua.service</Name>
|
|
||||||
<Path>/usr/local/plugins/mua/scripts/</Path>
|
|
||||||
<Mode>0644</Mode>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<Name>scripts/install.sh</Name>
|
|
||||||
<Path>/usr/local/plugins/mua/scripts/</Path>
|
|
||||||
<Mode>0755</Mode>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<Name>scripts/update.sh</Name>
|
|
||||||
<Path>/usr/local/plugins/mua/scripts/</Path>
|
|
||||||
<Mode>0755</Mode>
|
|
||||||
</File>
|
|
||||||
<File>
|
|
||||||
<Name>scripts/remove.sh</Name>
|
|
||||||
<Path>/usr/local/plugins/mua/scripts/</Path>
|
|
||||||
<Mode>0755</Mode>
|
|
||||||
</File>
|
|
||||||
</Files>
|
|
||||||
<Actions>
|
|
||||||
<Action>
|
|
||||||
<Name>install</Name>
|
|
||||||
<Script>scripts/install.sh</Script>
|
|
||||||
</Action>
|
|
||||||
<Action>
|
|
||||||
<Name>update</Name>
|
|
||||||
<Script>scripts/update.sh</Script>
|
|
||||||
</Action>
|
|
||||||
<Action>
|
|
||||||
<Name>remove</Name>
|
|
||||||
<Script>scripts/remove.sh</Script>
|
|
||||||
</Action>
|
|
||||||
</Actions>
|
|
||||||
</Plugin>
|
|
||||||
@@ -1,139 +1,101 @@
|
|||||||
# MUA — Mikes Unraid Agent
|
# MUA — Mikes Unraid Agent
|
||||||
|
|
||||||
Natives Unraid-Plugin, das 21 Docker-, Netzwerk- und System-Tools als **MCP-Server** (Model Context Protocol) über **HTTP (Streamable HTTP)** exponiert.
|
Natives Unraid-Plugin: 21 Docker-, Netzwerk- und System-Tools als MCP-Server (Streamable HTTP) auf Port 3002.
|
||||||
|
|
||||||
Läuft **lokal auf dem Unraid-Host** — kein SSH, kein Proxy, kein Key-Management.
|
|
||||||
|
|
||||||
## Endpunkt
|
|
||||||
|
|
||||||
```
|
|
||||||
http://<unraid-ip>:3002/mcp
|
|
||||||
```
|
|
||||||
|
|
||||||
- **POST** `/mcp` — JSON-RPC 2.0 (MCP-Requests)
|
|
||||||
- **GET** `/health` — Health-Check
|
|
||||||
- **DELETE** `/mcp` — Session-End
|
|
||||||
|
|
||||||
## Tools (21)
|
|
||||||
|
|
||||||
### Docker (14)
|
|
||||||
| Tool | Beschreibung |
|
|
||||||
|------|-------------|
|
|
||||||
| `unraid_docker_list` | Alle Container mit Runtime-Stats |
|
|
||||||
| `unraid_docker_inspect` | Container-Details |
|
|
||||||
| `unraid_docker_logs` | Container-Logs |
|
|
||||||
| `unraid_docker_analyze_logs` | Log-Analyse (server-seitig) |
|
|
||||||
| `unraid_docker_processes` | Prozesse im Container |
|
|
||||||
| `unraid_docker_stats` | Live-Stats (CPU/RAM/Net) |
|
|
||||||
| `unraid_docker_info` | Docker-Daemon-Info |
|
|
||||||
| `unraid_docker_start` | Container starten |
|
|
||||||
| `unraid_docker_stop` | Container stoppen |
|
|
||||||
| `unraid_docker_restart` | Container neu starten |
|
|
||||||
| `unraid_docker_create` | Container aus Template |
|
|
||||||
| `unraid_docker_modify` | Template ändern |
|
|
||||||
| `unraid_docker_update` | Container aktualisieren |
|
|
||||||
| `unraid_docker_rebuild` | Container neu bauen |
|
|
||||||
|
|
||||||
### Netzwerk (6)
|
|
||||||
| Tool | Beschreibung |
|
|
||||||
|------|-------------|
|
|
||||||
| `unraid_network_inventory` | Netzwerk-Inventur |
|
|
||||||
| `unraid_network_list` | Alle Netzwerke |
|
|
||||||
| `unraid_network_inspect` | Netzwerk-Details |
|
|
||||||
| `unraid_network_host_state` | Host-Netzwerk-Zustand |
|
|
||||||
| `unraid_network_audit_tcp` | TCP-Endpunkte auditieren |
|
|
||||||
| `unraid_network_lan_probe` | Dualstack-Probe |
|
|
||||||
|
|
||||||
### System (1)
|
|
||||||
| Tool | Beschreibung |
|
|
||||||
|------|-------------|
|
|
||||||
| `unraid_system_connection_test` | Verbindungstest |
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
### Via Community Apps (Link)
|
|
||||||
1. Community Apps öffnen
|
|
||||||
2. "Add Plugin" → Link: `https://git-192.168.1.2:33/michael/MUA-Mikes-Unraid-Agent`
|
|
||||||
3. Installieren
|
|
||||||
|
|
||||||
### Manuell
|
|
||||||
```bash
|
|
||||||
# Dateien kopieren
|
|
||||||
mkdir -p /usr/local/plugins/mua
|
|
||||||
cp -r mcp scripts /usr/local/plugins/mua/
|
|
||||||
|
|
||||||
# Helper installieren
|
|
||||||
cp scripts/unraid-docker-mcp-helper.php /usr/local/bin/
|
|
||||||
chmod 755 /usr/local/bin/unraid-docker-mcp-helper.php
|
|
||||||
|
|
||||||
# Service installieren
|
|
||||||
cp scripts/mua.service /etc/systemd/system/
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable --now mua.service
|
|
||||||
|
|
||||||
# Health-Check
|
|
||||||
curl http://127.0.0.1:3002/health
|
|
||||||
```
|
|
||||||
|
|
||||||
## Anbindung an MCP-Client
|
|
||||||
|
|
||||||
### Beispiel: Hermes Agent (config.yaml)
|
|
||||||
```yaml
|
|
||||||
mcp_servers:
|
|
||||||
mua:
|
|
||||||
url: http://192.168.1.2:3002/mcp
|
|
||||||
transport: http
|
|
||||||
```
|
|
||||||
|
|
||||||
### Beispiel: curl
|
|
||||||
```bash
|
|
||||||
# Initialize
|
|
||||||
curl -X POST http://192.168.1.2:3002/mcp \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
|
|
||||||
|
|
||||||
# Tools auflisten
|
|
||||||
curl -X POST http://192.168.1.2:3002/mcp \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-H "Mcp-Session-Id: <session-id>" \
|
|
||||||
-d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
|
|
||||||
|
|
||||||
# Tool aufrufen
|
|
||||||
curl -X POST http://192.168.1.2:3002/mcp \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-H "Mcp-Session-Id: <session-id>" \
|
|
||||||
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"unraid_docker_list","arguments":{}}}'
|
|
||||||
```
|
|
||||||
|
|
||||||
## Selftest
|
|
||||||
|
|
||||||
```bash
|
|
||||||
php /usr/local/plugins/mua/mcp/selftest.php
|
|
||||||
```
|
|
||||||
|
|
||||||
## Architektur
|
## Architektur
|
||||||
|
|
||||||
```
|
```
|
||||||
MCP-Client (z.B. llama.cpp auf 196)
|
llama.cpp (196) → HTTP → http://192.168.1.2:3002/mcp (MUA Plugin auf Unraid)
|
||||||
│
|
|
||||||
│ HTTP (Streamable HTTP)
|
|
||||||
▼
|
|
||||||
http://192.168.1.2:3002/mcp (MUA Plugin auf Unraid)
|
|
||||||
│
|
|
||||||
│ lokal (kein SSH)
|
|
||||||
▼
|
|
||||||
/usr/bin/docker, /usr/bin/ip, /usr/bin/ss, /usr/bin/php
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Port
|
Kein SSH, kein Proxy, kein Key-Management (nur URL + API-Key).
|
||||||
|
|
||||||
- **3002** (3000 ist belegt von `theippenguin/unraid-mcp`)
|
## Unraid-Plugin-Struktur
|
||||||
|
|
||||||
## Git
|
```
|
||||||
|
MUA-Mikes-Unraid-Agent/
|
||||||
|
├── plugin/
|
||||||
|
│ ├── mua.plg # Unraid-Plugin-File (XML, <!DOCTYPE PLUGIN>)
|
||||||
|
│ └── plugin.json # Metadaten (Name, Version, Pfade)
|
||||||
|
├── mcp/
|
||||||
|
│ ├── server.php # MCP-Server (Streamable HTTP, JSON-RPC 2.0)
|
||||||
|
│ ├── helpers.php # Helper-Funktionen (Docker, Netzwerk, System)
|
||||||
|
│ ├── tools.php # 21 Tool-Definitionen
|
||||||
|
│ └── selftest.php # Selftest (12 Tests)
|
||||||
|
├── scripts/
|
||||||
|
│ ├── rc.mua # SysVinit-Service-Script
|
||||||
|
│ ├── plugin.php # WebGUI-Tab (Settings > MUA)
|
||||||
|
│ └── unraid-docker-mcp-helper.php # Write-Operationen (DockerClient)
|
||||||
|
└── README.md
|
||||||
|
```
|
||||||
|
|
||||||
- Repo: `michael/MUA-Mikes-Unraid-Agent.git`
|
## Installation
|
||||||
- Zugang: `git@192.168.1.2:33` (SSH-Key `ha_agent`)
|
|
||||||
- Updates: Neuer Commit + Push
|
### Über Unraid-Plugin-Installer
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# .plg-File herunterladen und installieren
|
||||||
|
wget -O /tmp/mua.plg "http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/plugin/mua.plg"
|
||||||
|
# Im Unraid-WebGUI: Settings > Plugins > Install from URL
|
||||||
|
# URL: http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/plugin/mua.plg
|
||||||
|
```
|
||||||
|
|
||||||
|
### Manuell
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Repo klonen
|
||||||
|
git clone git@192.168.1.2:33/michael/MUA-Mikes-Unraid-Agent.git /tmp/mua
|
||||||
|
|
||||||
|
# Dateien installieren
|
||||||
|
mkdir -p /usr/local/emhttp/plugins/mua/{mcp,scripts}
|
||||||
|
cp /tmp/mua/mcp/*.php /usr/local/emhttp/plugins/mua/mcp/
|
||||||
|
cp /tmp/mua/scripts/plugin.php /usr/local/emhttp/plugins/mua/
|
||||||
|
cp /tmp/mua/scripts/rc.mua /etc/rc.d/rc.mua
|
||||||
|
chmod 755 /etc/rc.d/rc.mua
|
||||||
|
cp /tmp/mua/scripts/unraid-docker-mcp-helper.php /usr/local/bin/
|
||||||
|
chmod 755 /usr/local/bin/unraid-docker-mcp-helper.php
|
||||||
|
|
||||||
|
# Selftest
|
||||||
|
php /usr/local/emhttp/plugins/mua/mcp/selftest.php
|
||||||
|
|
||||||
|
# Starten
|
||||||
|
/etc/rc.d/rc.mua start
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verwaltung
|
||||||
|
|
||||||
|
| Aktion | Befehl |
|
||||||
|
|---|---|
|
||||||
|
| Starten | `/etc/rc.d/rc.mua start` |
|
||||||
|
| Stoppen | `/etc/rc.d/rc.mua stop` |
|
||||||
|
| Neu starten | `/etc/rc.d/rc.mua restart` |
|
||||||
|
| Status | `/etc/rc.d/rc.mua status` |
|
||||||
|
| Logs | `tail -f /var/log/plugins/mua.log` |
|
||||||
|
| WebGUI | Settings > MUA |
|
||||||
|
|
||||||
|
## MCP-Endpunkt
|
||||||
|
|
||||||
|
- **URL:** `http://<unraid-ip>:3002/mcp`
|
||||||
|
- **Transport:** Streamable HTTP (POST-only)
|
||||||
|
- **Protokoll:** JSON-RPC 2.0
|
||||||
|
- **Session:** `Mcp-Session-Id` Header
|
||||||
|
|
||||||
|
## Tools (21)
|
||||||
|
|
||||||
|
| Kategorie | Tools |
|
||||||
|
|---|---|
|
||||||
|
| **Docker (14)** | list, inspect, logs, analyze_logs, processes, stats, info, start, stop, restart, create, modify, update, rebuild |
|
||||||
|
| **Netzwerk (6)** | inventory, list, inspect, host_state, audit_tcp, lan_probe |
|
||||||
|
| **System (1)** | connection_test |
|
||||||
|
|
||||||
|
## Konformität
|
||||||
|
|
||||||
|
- ✅ Echte Unraid-Plugin-Struktur (`<!DOCTYPE PLUGIN>`, `<FILE Run="/bin/bash">` + `<INLINE>`)
|
||||||
|
- ✅ SysVinit-Service (`/etc/rc.d/rc.mua`) statt systemd
|
||||||
|
- ✅ WebGUI-Tab (`launch="Settings/MUA"`)
|
||||||
|
- ✅ Standard-Pfade (`/usr/local/emhttp/plugins/mua`, `/boot/config/plugins/mua`)
|
||||||
|
- ✅ Selftest (12/12)
|
||||||
|
- ✅ PHP 8.4-kompatibel
|
||||||
|
|
||||||
## Lizenz
|
## Lizenz
|
||||||
|
|
||||||
|
|||||||
+147
@@ -0,0 +1,147 @@
|
|||||||
|
<?xml version='1.0' standalone='yes'?>
|
||||||
|
<!DOCTYPE PLUGIN>
|
||||||
|
|
||||||
|
<PLUGIN
|
||||||
|
name="mua"
|
||||||
|
author="Michael"
|
||||||
|
version="1.0.0"
|
||||||
|
pluginURL="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent/raw/branch/main/plugin/mua.plg"
|
||||||
|
launch="Settings/MUA"
|
||||||
|
support="http://192.168.1.2:4000/michael/MUA-Mikes-Unraid-Agent"
|
||||||
|
min="7.0.0"
|
||||||
|
>
|
||||||
|
|
||||||
|
<CHANGES>
|
||||||
|
<![CDATA[
|
||||||
|
###1.0.0###
|
||||||
|
Initial release: 21 Docker, network, and system tools as MCP server over HTTP (Streamable HTTP, port 3002).
|
||||||
|
]]>
|
||||||
|
</CHANGES>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Install script.
|
||||||
|
Klon das Git-Repo und installiert alle Dateien.
|
||||||
|
-->
|
||||||
|
<FILE Run="/bin/bash">
|
||||||
|
<INLINE>
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PLUGIN_DIR="/usr/local/emhttp/plugins/mua"
|
||||||
|
CONFIG_DIR="/boot/config/plugins/mua"
|
||||||
|
GIT_REPO="git@192.168.1.2:33/michael/MUA-Mikes-Unraid-Agent.git"
|
||||||
|
TMP_DIR="/tmp/mua-install-$$"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "===================================================="
|
||||||
|
echo " MUA - Mikes Unraid Agent"
|
||||||
|
echo " Installation"
|
||||||
|
echo "===================================================="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 1. Verzeichnisse
|
||||||
|
mkdir -p "$PLUGIN_DIR/mcp"
|
||||||
|
mkdir -p "$PLUGIN_DIR/scripts"
|
||||||
|
mkdir -p "$CONFIG_DIR"
|
||||||
|
|
||||||
|
# 2. Git-Repo klonen
|
||||||
|
echo " Kloniere Repo..."
|
||||||
|
git clone --depth 1 "$GIT_REPO" "$TMP_DIR" 2>&1 | sed 's/^/ /'
|
||||||
|
|
||||||
|
# 3. PHP-Dateien installieren
|
||||||
|
echo " Installiere MCP-Server..."
|
||||||
|
cp "$TMP_DIR/mcp/server.php" "$PLUGIN_DIR/mcp/"
|
||||||
|
cp "$TMP_DIR/mcp/helpers.php" "$PLUGIN_DIR/mcp/"
|
||||||
|
cp "$TMP_DIR/mcp/tools.php" "$PLUGIN_DIR/mcp/"
|
||||||
|
cp "$TMP_DIR/mcp/selftest.php" "$PLUGIN_DIR/mcp/"
|
||||||
|
chmod 644 "$PLUGIN_DIR/mcp/"*.php
|
||||||
|
|
||||||
|
# 4. PHP-Helper (Write-Operationen)
|
||||||
|
echo " Installiere PHP-Helper..."
|
||||||
|
cp "$TMP_DIR/scripts/unraid-docker-mcp-helper.php" /usr/local/bin/
|
||||||
|
chmod 755 /usr/local/bin/unraid-docker-mcp-helper.php
|
||||||
|
|
||||||
|
# 5. WebGUI-Tab
|
||||||
|
echo " Installiere WebGUI-Tab..."
|
||||||
|
cp "$TMP_DIR/scripts/plugin.php" "$PLUGIN_DIR/plugin.php"
|
||||||
|
chmod 644 "$PLUGIN_DIR/plugin.php"
|
||||||
|
|
||||||
|
# 6. SysVinit-Service
|
||||||
|
echo " Installiere Service..."
|
||||||
|
cp "$TMP_DIR/scripts/rc.mua" /etc/rc.d/rc.mua
|
||||||
|
chmod 755 /etc/rc.d/rc.mua
|
||||||
|
|
||||||
|
# 7. Log-Verzeichnis
|
||||||
|
mkdir -p /var/log/plugins
|
||||||
|
touch /var/log/plugins/mua.log
|
||||||
|
|
||||||
|
# 8. Selftest
|
||||||
|
echo " Führe Selftest aus..."
|
||||||
|
php "$PLUGIN_DIR/mcp/selftest.php" 2>&1 | sed 's/^/ /'
|
||||||
|
|
||||||
|
# 9. Service starten
|
||||||
|
echo " Starte MCP-Server..."
|
||||||
|
/etc/rc.d/rc.mua start
|
||||||
|
|
||||||
|
# 10. Health-Check
|
||||||
|
sleep 2
|
||||||
|
if curl -sf "http://127.0.0.1:3002/health" > /dev/null 2>&1; then
|
||||||
|
echo ""
|
||||||
|
echo " Health-Check: OK"
|
||||||
|
echo ""
|
||||||
|
echo "===================================================="
|
||||||
|
echo " MUA installiert und läuft auf Port 3002"
|
||||||
|
echo " Endpunkt: http://$(hostname -I | awk '{print $1}'):3002/mcp"
|
||||||
|
echo " WebGUI: Settings > MUA"
|
||||||
|
echo "===================================================="
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo " WARNUNG: Health-Check fehlgeschlagen"
|
||||||
|
echo " Logs: tail -f /var/log/plugins/mua.log"
|
||||||
|
echo "===================================================="
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 11. Cleanup
|
||||||
|
rm -rf "$TMP_DIR"
|
||||||
|
|
||||||
|
</INLINE>
|
||||||
|
</FILE>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Remove script.
|
||||||
|
-->
|
||||||
|
<FILE Run="/bin/bash" Method="remove">
|
||||||
|
<INLINE>
|
||||||
|
echo ""
|
||||||
|
echo "===================================================="
|
||||||
|
echo " MUA - Mikes Unraid Agent"
|
||||||
|
echo " Deinstallation"
|
||||||
|
echo "===================================================="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# 1. Service stoppen
|
||||||
|
/etc/rc.d/rc.mua stop 2>/dev/null || true
|
||||||
|
|
||||||
|
# 2. Service-Datei entfernen
|
||||||
|
rm -f /etc/rc.d/rc.mua
|
||||||
|
|
||||||
|
# 3. PHP-Helper entfernen
|
||||||
|
rm -f /usr/local/bin/unraid-docker-mcp-helper.php
|
||||||
|
|
||||||
|
# 4. Plugin-Verzeichnis entfernen
|
||||||
|
rm -rf /usr/local/emhttp/plugins/mua
|
||||||
|
|
||||||
|
# 5. Config entfernen
|
||||||
|
rm -rf /boot/config/plugins/mua
|
||||||
|
|
||||||
|
# 6. Logs entfernen
|
||||||
|
rm -f /var/log/plugins/mua.log
|
||||||
|
rm -f /var/run/mua.pid
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo " MUA wurde deinstalliert."
|
||||||
|
echo "===================================================="
|
||||||
|
|
||||||
|
</INLINE>
|
||||||
|
</FILE>
|
||||||
|
|
||||||
|
</PLUGIN>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "mua",
|
||||||
|
"author": "Michael",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"minver": "7.0.0",
|
||||||
|
"pluginDirectory": "/usr/local/emhttp/plugins/mua",
|
||||||
|
"configDirectory": "/boot/config/plugins/mua",
|
||||||
|
"port": 3002
|
||||||
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# MUA - Mikes Unraid Agent
|
|
||||||
# Install-Script
|
|
||||||
# Wird vom Unraid-Plugin-Installer aufgerufen.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
PLUGIN_DIR="/usr/local/plugins/mua"
|
|
||||||
SERVICE_FILE="$PLUGIN_DIR/scripts/mua.service"
|
|
||||||
HELPER_SRC="$PLUGIN_DIR/scripts/unraid-docker-mcp-helper.php"
|
|
||||||
HELPER_DST="/usr/local/bin/unraid-docker-mcp-helper.php"
|
|
||||||
|
|
||||||
echo "=== MUA Install ==="
|
|
||||||
|
|
||||||
# 1. Verzeichnisse sicherstellen
|
|
||||||
mkdir -p "$PLUGIN_DIR/mcp"
|
|
||||||
mkdir -p "$PLUGIN_DIR/scripts"
|
|
||||||
|
|
||||||
# 2. PHP-Helper installieren (Write-Operationen)
|
|
||||||
if [ -f "$HELPER_SRC" ]; then
|
|
||||||
cp "$HELPER_SRC" "$HELPER_DST"
|
|
||||||
chmod 755 "$HELPER_DST"
|
|
||||||
echo " Helper installiert: $HELPER_DST"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 3. systemd-Service installieren
|
|
||||||
if [ -f "$SERVICE_FILE" ]; then
|
|
||||||
cp "$SERVICE_FILE" /etc/systemd/system/mua.service
|
|
||||||
chmod 644 /etc/systemd/system/mua.service
|
|
||||||
systemctl daemon-reload
|
|
||||||
echo " Service installiert: mua.service"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 4. Service starten + enable
|
|
||||||
systemctl enable mua.service
|
|
||||||
systemctl restart mua.service
|
|
||||||
|
|
||||||
# 5. Health-Check
|
|
||||||
sleep 2
|
|
||||||
if curl -sf "http://127.0.0.1:3002/health" > /dev/null 2>&1; then
|
|
||||||
echo " Health-Check: OK"
|
|
||||||
echo "=== MUA installiert und läuft auf Port 3002 ==="
|
|
||||||
echo " Endpunkt: http://$(hostname -I | awk '{print $1}'):3002/mcp"
|
|
||||||
else
|
|
||||||
echo " WARNUNG: Health-Check fehlgeschlagen"
|
|
||||||
echo " Service-Status:"
|
|
||||||
systemctl status mua.service --no-pager || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=MUA - Mikes Unraid Agent (MCP Server)
|
|
||||||
After=network.target docker.service
|
|
||||||
Wants=docker.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=simple
|
|
||||||
# PHP Built-in Server auf Port 3002
|
|
||||||
ExecStart=/usr/bin/php -S 0.0.0.0:3002 /usr/local/plugins/mua/mcp/server.php
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=5
|
|
||||||
# Arbeitsverzeichnis
|
|
||||||
WorkingDirectory=/usr/local/plugins/mua
|
|
||||||
# Sicherheits-Härtung
|
|
||||||
NoNewPrivileges=true
|
|
||||||
ProtectHome=true
|
|
||||||
PrivateTmp=true
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* MUA - Mikes Unraid Agent
|
||||||
|
* WebGUI-Tab (plugin.php)
|
||||||
|
* Wird vom Unraid-WebGUI geladen, wenn der Tab "Settings/MUA" geöffnet wird.
|
||||||
|
* Zeigt Status, Endpunkt und Health-Check.
|
||||||
|
*/
|
||||||
|
|
||||||
|
$plugin_dir = '/usr/local/emhttp/plugins/mua';
|
||||||
|
$port = 3002;
|
||||||
|
$pidfile = '/var/run/mua.pid';
|
||||||
|
$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;
|
||||||
|
$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);
|
||||||
|
|
||||||
|
// PHP-Version
|
||||||
|
$php_version = PHP_VERSION;
|
||||||
|
|
||||||
|
// Tool-Anzahl (aus tools.php)
|
||||||
|
$tool_count = 21;
|
||||||
|
|
||||||
|
// Host-IP
|
||||||
|
$host_ip = $_SERVER['SERVER_ADDR'] ?? '127.0.0.1';
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>MUA - Mikes Unraid Agent</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 20px; color: #333; }
|
||||||
|
h1 { font-size: 1.5em; border-bottom: 2px solid #4a90d9; padding-bottom: 8px; }
|
||||||
|
.status { padding: 12px 16px; border-radius: 6px; margin: 12px 0; font-size: 0.95em; }
|
||||||
|
.status.ok { background: #e8f5e9; border: 1px solid #4caf50; color: #2e7d32; }
|
||||||
|
.status.err { background: #ffebee; border: 1px solid #f44336; color: #c62828; }
|
||||||
|
.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>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>MUA - Mikes Unraid Agent</h1>
|
||||||
|
|
||||||
|
<?php if ($running): ?>
|
||||||
|
<div class="status ok">✅ <strong>MCP-Server läuft</strong> (PID <?= $pid ?>, Port <?= $port ?>)</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="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="status ok">✅ Health-Check: OK</div>
|
||||||
|
<?php elseif ($health !== false): ?>
|
||||||
|
<div class="status warn">⚠️ Health-Check: HTTP <?= $health_code ?></div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="status warn">⚠️ Health-Check: nicht erreichbar</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<h2>MCP-Endpunkt</h2>
|
||||||
|
<p class="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>PHP</th><td><?= $php_version ?></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>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# MUA - Mikes Unraid Agent
|
||||||
|
# SysVinit-Service-Script (rc.mua)
|
||||||
|
# Unraid nutzt SysVinit, kein systemd.
|
||||||
|
# Wird installiert nach /etc/rc.d/rc.mua
|
||||||
|
|
||||||
|
PLUGIN_DIR="/usr/local/emhttp/plugins/mua"
|
||||||
|
SERVER="$PLUGIN_DIR/mcp/server.php"
|
||||||
|
PIDFILE="/var/run/mua.pid"
|
||||||
|
LOGFILE="/var/log/plugins/mua.log"
|
||||||
|
PORT=3002
|
||||||
|
PHP_BIN="/usr/bin/php"
|
||||||
|
|
||||||
|
# PHP-Binary finden (Fallback)
|
||||||
|
if [ ! -x "$PHP_BIN" ]; then
|
||||||
|
PHP_BIN=$(command -v php 2>/dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
|
start() {
|
||||||
|
if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
||||||
|
echo " MUA läuft bereits (PID $(cat "$PIDFILE"))"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
if [ ! -f "$SERVER" ]; then
|
||||||
|
echo " FEHLER: Server-Datei nicht gefunden: $SERVER"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
# Server starten (detached)
|
||||||
|
nohup "$PHP_BIN" -S 0.0.0.0:$PORT "$SERVER" >> "$LOGFILE" 2>&1 &
|
||||||
|
echo $! > "$PIDFILE"
|
||||||
|
sleep 1
|
||||||
|
if kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
||||||
|
echo " MUA gestartet (PID $(cat "$PIDFILE"), Port $PORT)"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo " FEHLER: MUA konnte nicht gestartet werden"
|
||||||
|
cat "$LOGFILE" 2>/dev/null | tail -5
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if [ -f "$PIDFILE" ]; then
|
||||||
|
local pid=$(cat "$PIDFILE")
|
||||||
|
if kill -0 "$pid" 2>/dev/null; then
|
||||||
|
kill "$pid" 2>/dev/null
|
||||||
|
sleep 1
|
||||||
|
kill -0 "$pid" 2>/dev/null && kill -9 "$pid" 2>/dev/null
|
||||||
|
echo " MUA gestoppt (PID $pid)"
|
||||||
|
fi
|
||||||
|
rm -f "$PIDFILE"
|
||||||
|
else
|
||||||
|
# Fallback: per Port suchen
|
||||||
|
local pid=$(lsof -ti :$PORT 2>/dev/null)
|
||||||
|
if [ -n "$pid" ]; then
|
||||||
|
kill "$pid" 2>/dev/null
|
||||||
|
echo " MUA gestoppt (PID $pid, per Port)"
|
||||||
|
else
|
||||||
|
echo " MUA läuft nicht"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
status() {
|
||||||
|
if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
||||||
|
echo " MUA läuft (PID $(cat "$PIDFILE"), Port $PORT)"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo " MUA läuft nicht"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start) start ;;
|
||||||
|
stop) stop ;;
|
||||||
|
restart) stop; start ;;
|
||||||
|
status) status ;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|status}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# MUA - Mikes Unraid Agent
|
|
||||||
# Remove-Script
|
|
||||||
# Wird vom Unraid-Plugin-Installer bei Deinstallation aufgerufen.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "=== MUA Remove ==="
|
|
||||||
|
|
||||||
# 1. Service stoppen + disable
|
|
||||||
if systemctl list-unit-files | grep -q "^mua.service"; then
|
|
||||||
systemctl stop mua.service 2>/dev/null || true
|
|
||||||
systemctl disable mua.service 2>/dev/null || true
|
|
||||||
rm -f /etc/systemd/system/mua.service
|
|
||||||
systemctl daemon-reload
|
|
||||||
echo " Service entfernt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. PHP-Helper entfernen
|
|
||||||
if [ -f "/usr/local/bin/unraid-docker-mcp-helper.php" ]; then
|
|
||||||
rm -f /usr/local/bin/unraid-docker-mcp-helper.php
|
|
||||||
echo " Helper entfernt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 3. Plugin-Verzeichnis entfernen
|
|
||||||
if [ -d "/usr/local/plugins/mua" ]; then
|
|
||||||
rm -rf /usr/local/plugins/mua
|
|
||||||
echo " Plugin-Verzeichnis entfernt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "=== MUA entfernt ==="
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# MUA - Mikes Unraid Agent
|
|
||||||
# Update-Script
|
|
||||||
# Wird vom Unraid-Plugin-Installer bei Updates aufgerufen.
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
PLUGIN_DIR="/usr/local/plugins/mua"
|
|
||||||
SERVICE_FILE="$PLUGIN_DIR/scripts/mua.service"
|
|
||||||
HELPER_SRC="$PLUGIN_DIR/scripts/unraid-docker-mcp-helper.php"
|
|
||||||
HELPER_DST="/usr/local/bin/unraid-docker-mcp-helper.php"
|
|
||||||
|
|
||||||
echo "=== MUA Update ==="
|
|
||||||
|
|
||||||
# 1. PHP-Helper aktualisieren
|
|
||||||
if [ -f "$HELPER_SRC" ]; then
|
|
||||||
cp "$HELPER_SRC" "$HELPER_DST"
|
|
||||||
chmod 755 "$HELPER_DST"
|
|
||||||
echo " Helper aktualisiert"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. systemd-Service aktualisieren
|
|
||||||
if [ -f "$SERVICE_FILE" ]; then
|
|
||||||
cp "$SERVICE_FILE" /etc/systemd/system/mua.service
|
|
||||||
chmod 644 /etc/systemd/system/mua.service
|
|
||||||
systemctl daemon-reload
|
|
||||||
echo " Service aktualisiert"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 3. Service neu starten
|
|
||||||
systemctl restart mua.service
|
|
||||||
|
|
||||||
# 4. Health-Check
|
|
||||||
sleep 2
|
|
||||||
if curl -sf "http://127.0.0.1:3002/health" > /dev/null 2>&1; then
|
|
||||||
echo " Health-Check: OK"
|
|
||||||
echo "=== MUA aktualisiert ==="
|
|
||||||
else
|
|
||||||
echo " WARNUNG: Health-Check fehlgeschlagen"
|
|
||||||
systemctl status mua.service --no-pager || true
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
Reference in new issue
Block a user