fix(ops): handle sudo in verify-server.sh
Some checks failed
Some checks failed
Use SUDO_USER to resolve correct home directory when run with sudo. Use --project-directory instead of -f for docker compose lookups. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -178,7 +178,13 @@ fi
|
|||||||
|
|
||||||
if [ "$MODE" = "prod" ]; then
|
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"
|
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"
|
EXPECTED_CONTAINERS="db redis api celery-worker celery-beat flower prometheus grafana node-exporter cadvisor alertmanager redis-exporter"
|
||||||
for name in $EXPECTED_CONTAINERS; do
|
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
|
if [ -n "$container" ]; then
|
||||||
state=$(docker inspect --format='{{.State.Status}}' "$container" 2>/dev/null || echo "unknown")
|
state=$(docker inspect --format='{{.State.Status}}' "$container" 2>/dev/null || echo "unknown")
|
||||||
if [ "$state" = "running" ]; then
|
if [ "$state" = "running" ]; then
|
||||||
@@ -243,7 +249,7 @@ if [ "$MODE" = "prod" ]; then
|
|||||||
|
|
||||||
# Check for healthy status on containers with healthchecks
|
# Check for healthy status on containers with healthchecks
|
||||||
for name in db redis api celery-worker; do
|
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
|
if [ -n "$container" ]; then
|
||||||
health=$(docker inspect --format='{{.State.Health.Status}}' "$container" 2>/dev/null || echo "none")
|
health=$(docker inspect --format='{{.State.Health.Status}}' "$container" 2>/dev/null || echo "none")
|
||||||
if [ "$health" = "healthy" ]; then
|
if [ "$health" = "healthy" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user