#!/usr/bin/env bash # Small, predictable operator entrypoint for Athena's Docker stack. set -Eeuo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ENV_FILE=${STACK_ENV:-/etc/mike-ai/stack.env} DRY_RUN=false usage() { cat <<'EOF' Usage: ./manage.sh [--dry-run] validate ./manage.sh [--dry-run] deploy core ./manage.sh [--dry-run] deploy SERVICE [SERVICE ...] ./manage.sh [--dry-run] purge-legacy `deploy SERVICE` deliberately uses --no-deps. It never recreates unrelated containers. `deploy core` is the complete Athena runtime and may start missing dependencies. Hermes und portable Fach-MCPs gehören nicht zu Athena. EOF } if [[ ${1:-} == --dry-run ]]; then DRY_RUN=true shift fi run() { printf '+ ' printf '%q ' "$@" printf '\n' $DRY_RUN || "$@" } compose=(docker compose --env-file "$ENV_FILE" -f "$ROOT_DIR/compose.yaml") command=${1:-} shift || true case "$command" in validate) run bash "$ROOT_DIR/dev/check.sh" run "${compose[@]}" config --quiet ;; deploy) [[ $# -gt 0 ]] || { usage >&2; exit 2; } run bash "$ROOT_DIR/dev/check.sh" if ! docker volume inspect portainer_data >/dev/null 2>&1; then run docker volume create portainer_data fi if [[ $1 == core ]]; then shift [[ $# -eq 0 ]] || { echo "core akzeptiert keine weiteren Services" >&2; exit 2; } run "$ROOT_DIR/platform/mcp/install-tools.sh" run "${compose[@]}" up -d --build \ wireguard-gateway qwen3-tts tts-gateway profile-controller router llama-dashboard portainer backup else run "${compose[@]}" up -d --build --no-deps "$@" fi ;; purge-legacy) # Entfernt nur ersetzte Athena-Oberflächen und ausgelagerte Fach-MCPs. for name in mike-ai-open-webui mike-ai-hermes mike-ai-hermes-webui \ mike-ai-hermes-webui-vpn-proxy mike-ai-mcp-web mike-ai-tools-searxng \ mike-ai-tools-tinysearch mike-ai-mcp-platform-context mike-ai-mcp-arr \ mike-ai-mcp-deemix mike-ai-mcp-github mike-ai-mcp-homeassistant \ mike-ai-mcp-navidrome; do if docker inspect "$name" >/dev/null 2>&1; then run docker rm -f "$name" fi done ;; -h|--help|"") usage ;; *) echo "Unbekannter Befehl: $command" >&2; usage >&2; exit 2 ;; esac