89 lines
2.9 KiB
Bash
Executable File
89 lines
2.9 KiB
Bash
Executable File
#!/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 python3 "$ROOT_DIR/platform/scripts/sync-profile-matrix.py" --check
|
|
run "${compose[@]}" config --quiet
|
|
;;
|
|
deploy)
|
|
[[ $# -gt 0 ]] || { usage >&2; exit 2; }
|
|
run python3 "$ROOT_DIR/platform/scripts/sync-profile-matrix.py" --check
|
|
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"
|
|
# Release the old gateway namespace (and its fixed network addresses)
|
|
# before replacing its owner. Otherwise Docker can strand the host with
|
|
# the old namespace still held by these two consumers.
|
|
run "${compose[@]}" stop llama-dashboard portainer
|
|
run "${compose[@]}" up -d --build \
|
|
wireguard-gateway piper xtts tts-gateway profile-controller router llama-dashboard portainer backup
|
|
else
|
|
rebind_gateway=false
|
|
for service in "$@"; do
|
|
[[ $service == wireguard-gateway ]] && rebind_gateway=true
|
|
done
|
|
if [[ $rebind_gateway == true ]]; then
|
|
run "${compose[@]}" stop llama-dashboard portainer
|
|
fi
|
|
run "${compose[@]}" up -d --build --no-deps "$@"
|
|
if [[ $rebind_gateway == true ]]; then
|
|
run "${compose[@]}" up -d --no-deps --force-recreate llama-dashboard portainer
|
|
fi
|
|
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
|