87 lines
2.9 KiB
Bash
Executable File
87 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Baut und verwaltet ausschließlich den eigenständigen ARR-MCP-Container.
|
|
set -Eeuo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
APPDATA_DIR=${ARR_MCP_APPDATA_DIR:-/mnt/nvme-storage/appdata/ARR-MCP}
|
|
ENV_FILE=${ARR_MCP_ENV_FILE:-$APPDATA_DIR/arr-mcp.env}
|
|
PUBLIC_PORT=${ARR_MCP_PUBLIC_PORT:-8207}
|
|
TEMPLATE_SOURCE="$REPO_ROOT/config/unraid-templates/my-ARR-MCP.xml"
|
|
TEMPLATE_DEST=${ARR_MCP_TEMPLATE_DEST:-/boot/config/plugins/dockerMan/templates-user/my-ARR-MCP.xml}
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Verwendung:
|
|
./services/arr-mcp/install-on-unraid.sh
|
|
./services/arr-mcp/install-on-unraid.sh uninstall
|
|
|
|
Der erste Lauf legt nur dann eine Beispielkonfiguration an, wenn noch keine
|
|
existiert. Echte Schlüssel werden niemals überschrieben oder ausgegeben.
|
|
EOF
|
|
}
|
|
|
|
command=${1:-install}
|
|
case "$command" in
|
|
-h|--help) usage; exit 0 ;;
|
|
install|uninstall) ;;
|
|
*) usage >&2; exit 2 ;;
|
|
esac
|
|
|
|
command -v docker >/dev/null 2>&1 || { echo "Docker wurde nicht gefunden." >&2; exit 1; }
|
|
docker compose version >/dev/null 2>&1 || { echo "Docker Compose v2 wurde nicht gefunden." >&2; exit 1; }
|
|
|
|
compose=(docker compose -f "$SCRIPT_DIR/compose.yaml")
|
|
|
|
if [[ $command == uninstall ]]; then
|
|
ARR_MCP_ENV_FILE="$ENV_FILE" ARR_MCP_PUBLIC_PORT="$PUBLIC_PORT" \
|
|
"${compose[@]}" down --remove-orphans
|
|
echo "ARR-MCP wurde entfernt. Appdata und Konfiguration bleiben erhalten: $APPDATA_DIR"
|
|
exit 0
|
|
fi
|
|
|
|
install -d -m 0700 "$APPDATA_DIR"
|
|
if [[ ! -e $ENV_FILE ]]; then
|
|
install -m 0600 "$SCRIPT_DIR/arr-mcp.env.example" "$ENV_FILE"
|
|
echo "Beispielkonfiguration angelegt: $ENV_FILE"
|
|
echo "Bitte SONARR_TOKEN und RADARR_TOKEN eintragen und denselben Befehl erneut starten."
|
|
exit 3
|
|
fi
|
|
|
|
# Nur Vollständigkeit prüfen; Werte niemals ausgeben.
|
|
for key in SONARR_TOKEN RADARR_TOKEN; do
|
|
if ! grep -Eq "^${key}=[^[:space:]]+" "$ENV_FILE" \
|
|
|| grep -Eq "^${key}=CHANGE_ME$" "$ENV_FILE"; then
|
|
echo "In $ENV_FILE fehlt noch $key." >&2
|
|
exit 3
|
|
fi
|
|
done
|
|
|
|
docker build \
|
|
--build-arg ARR_MCP_VERSION=1.0.1 \
|
|
-f "$SCRIPT_DIR/Dockerfile" \
|
|
-t mike-ai/arr-mcp:1.1.0 \
|
|
"$REPO_ROOT"
|
|
|
|
ARR_MCP_ENV_FILE="$ENV_FILE" ARR_MCP_PUBLIC_PORT="$PUBLIC_PORT" \
|
|
"${compose[@]}" up -d --no-build
|
|
|
|
if [[ -d $(dirname "$TEMPLATE_DEST") ]]; then
|
|
install -m 0644 "$TEMPLATE_SOURCE" "$TEMPLATE_DEST"
|
|
fi
|
|
|
|
for _ in {1..30}; do
|
|
health=$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' ARR-MCP 2>/dev/null || true)
|
|
[[ $health == healthy ]] && break
|
|
sleep 1
|
|
done
|
|
|
|
health=$(docker inspect --format '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' ARR-MCP 2>/dev/null || true)
|
|
[[ $health == healthy ]] || {
|
|
echo "ARR-MCP wurde gestartet, ist aber noch nicht healthy (Status: ${health:-unbekannt})." >&2
|
|
echo "Prüfen mit: docker logs --tail 100 ARR-MCP" >&2
|
|
exit 1
|
|
}
|
|
|
|
echo "ARR-MCP läuft: http://$(hostname -I | awk '{print $1}'):$PUBLIC_PORT/mcp"
|