Files
ThothII/scripts/thothii-local.sh
CodexandClaude Haiku 5.5 b17d41802d feat: add local start/stop/status script for ThothII via tht
Wraps tht start/stop/status for the PSD installation. Before starting it
stops other thothii-* Compose projects (stop only, volumes kept) and fails
early if the published ports 8080, 8787 or 6333 are held by a non-Docker
process. It warns, without stopping them, when PeopleKitchens containers run.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-17 18:22:19 +02:00

74 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# thothii-local.sh — avvia, ferma e controlla lo stack locale ThothII tramite tht.
#
# Prima di avviare ferma gli altri progetti Compose thothii-* in esecuzione (solo stop: container
# e volumi restano) e verifica che le porte pubblicate siano libere. PeopleKitchens non viene
# toccato: lo script segnala solo che è attivo.
# Uso: ./scripts/thothii-local.sh start [--build] | stop | status
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
INSTALLATION="$ROOT/deploy/psd/thothii-installation.yaml"
PORTS=(8080 8787 6333)
tht_cmd() {
tht --installation "$INSTALLATION" "$@"
}
running_thothii_projects() {
docker ps --filter 'label=com.docker.compose.project' \
--format '{{.Label "com.docker.compose.project"}}' | sort -u | grep '^thothii' || true
}
warn_peoplekitchens() {
if docker ps --format '{{.Names}}' | grep -q '^peoplekitchens'; then
echo "ATTENZIONE: container PeopleKitchens attivi (consumo memoria, non fermati da questo script)." >&2
fi
}
stop_other_thothii_projects() {
local project
while read -r project; do
[[ -n "$project" ]] || continue
echo "Fermo il progetto Compose $project (container e volumi conservati)"
docker compose -p "$project" stop
done < <(running_thothii_projects)
}
check_ports_free() {
local port busy=0
for port in "${PORTS[@]}"; do
if lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1; then
echo "ERRORE: porta $port occupata da:" >&2
lsof -nP -iTCP:"$port" -sTCP:LISTEN >&2 || true
busy=1
fi
done
return "$busy"
}
case "${1:-}" in
start)
shift
warn_peoplekitchens
tht_cmd stop >/dev/null 2>&1 || true
stop_other_thothii_projects
check_ports_free
tht_cmd start "$@"
;;
stop)
tht_cmd stop
stop_other_thothii_projects
;;
status)
tht_cmd status
echo "--- progetti thothii in esecuzione:"
running_thothii_projects
warn_peoplekitchens
;;
*)
echo "Uso: $0 start [--build] | stop | status" >&2
exit 2
;;
esac