diff --git a/scripts/verify-server.sh b/scripts/verify-server.sh index 708fb195..79ecd9ba 100755 --- a/scripts/verify-server.sh +++ b/scripts/verify-server.sh @@ -178,7 +178,13 @@ fi if [ "$MODE" = "prod" ]; then - ORION_DIR="${ORION_DIR:-$HOME/apps/orion}" + # When run with sudo, $HOME is /root. Use SUDO_USER's home instead. + if [ -n "${SUDO_USER:-}" ]; then + REAL_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6) + else + REAL_HOME="$HOME" + fi + ORION_DIR="${ORION_DIR:-$REAL_HOME/apps/orion}" # ----------------------------------------------------------------------- section "1. fail2ban" @@ -228,7 +234,7 @@ if [ "$MODE" = "prod" ]; then EXPECTED_CONTAINERS="db redis api celery-worker celery-beat flower prometheus grafana node-exporter cadvisor alertmanager redis-exporter" for name in $EXPECTED_CONTAINERS; do - container=$(docker compose --profile full -f "$ORION_DIR/docker-compose.yml" ps --format '{{.Name}}' 2>/dev/null | grep "$name" || true) + container=$(docker compose --profile full --project-directory "$ORION_DIR" ps --format '{{.Name}}' 2>/dev/null | grep "$name" || true) if [ -n "$container" ]; then state=$(docker inspect --format='{{.State.Status}}' "$container" 2>/dev/null || echo "unknown") if [ "$state" = "running" ]; then @@ -243,7 +249,7 @@ if [ "$MODE" = "prod" ]; then # Check for healthy status on containers with healthchecks for name in db redis api celery-worker; do - container=$(docker compose --profile full -f "$ORION_DIR/docker-compose.yml" ps --format '{{.Name}}' 2>/dev/null | grep "$name" || true) + container=$(docker compose --profile full --project-directory "$ORION_DIR" ps --format '{{.Name}}' 2>/dev/null | grep "$name" || true) if [ -n "$container" ]; then health=$(docker inspect --format='{{.State.Health.Status}}' "$container" 2>/dev/null || echo "none") if [ "$health" = "healthy" ]; then