#!/bin/bash
# Show core_room status
#
# Usage:
#   ./status.sh

# Change to parent directory (services are in ../service_name)
cd "$(dirname "$0")/.."

# Export core_room/.env vars
if [ -f ".env" ]; then
    export $(grep -v '^#' .env | grep -v '^$' | xargs)
fi

SERVICE_DIRS=()

# Find all service directories (have docker-compose.yml, exclude ctrl/nginx)
for dir in */; do
    dirname="${dir%/}"
    if [ -f "$dir/docker-compose.yml" ] && [ "$dirname" != "ctrl" ] && [ "$dirname" != "nginx" ]; then
        SERVICE_DIRS+=("$dirname")
    fi
done

# ROOM_NAME comes from core_room/.env
ROOM_NAME=${ROOM_NAME:-core_room}

echo "=== Room Status: $ROOM_NAME ==="
echo ""

echo "Containers:"
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep -E "(${ROOM_NAME}|NAMES)" || echo "  No containers running"

echo ""
echo "Networks:"
docker network ls | grep -E "(${ROOM_NAME}|NETWORK)" || echo "  No networks"

echo ""
echo "Volumes:"
docker volume ls | grep -E "(${ROOM_NAME}|VOLUME)" || echo "  No volumes"

echo ""
