#!/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] stop-legacy `deploy SERVICE` deliberately uses --no-deps. It never recreates unrelated containers. `deploy core` is the complete Athena runtime and may start missing dependencies, but does not start OpenWebUI, Hermes or portable Fach-MCPs. 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 python3 "$ROOT_DIR/platform/scripts/sync-profile-matrix.py" --check run python3 "$ROOT_DIR/platform/scripts/render-mcp-registry.py" --check run "${compose[@]}" config --quiet ;; deploy) [[ $# -gt 0 ]] || { usage >&2; exit 2; } run python3 "$ROOT_DIR/platform/scripts/sync-profile-matrix.py" --check run python3 "$ROOT_DIR/platform/scripts/render-mcp-registry.py" --check 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 piper xtts tts-gateway profile-controller router backup else run "${compose[@]}" up -d --build --no-deps "$@" fi ;; stop-legacy) # Reversible cleanup: stop only obsolete Athena frontends/tool backends. 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; do if docker inspect "$name" >/dev/null 2>&1; then run docker stop "$name" fi done ;; -h|--help|"") usage ;; *) echo "Unbekannter Befehl: $command" >&2; usage >&2; exit 2 ;; esac