#!/usr/bin/env bash
# Print a comprehensive status report of the VPS + disclosure stack.
source "$(dirname "$0")/_lib.sh"

vps_ssh "bash -s" <<EOF
echo "=== HOST ==="
hostname; uname -r
[ -f /etc/os-release ] && . /etc/os-release && echo "\$PRETTY_NAME"
uptime

echo ""
echo "=== RESOURCES ==="
free -h
echo ""
df -h | grep -vE 'tmpfs|loop|overlay'

echo ""
echo "=== DISCLOSURE STACK ==="
if [ -d "$VPS_DEPLOY_ROOT" ]; then
  cd "$VPS_DEPLOY_ROOT" || exit
  if [ -f docker-compose.yml ]; then
    docker compose ps 2>/dev/null || echo "(docker compose not running for this stack)"
  else
    echo "(no docker-compose.yml in $VPS_DEPLOY_ROOT yet — run scripts/deploy.sh first)"
  fi
else
  echo "(deploy root not yet created: $VPS_DEPLOY_ROOT)"
fi

echo ""
echo "=== ALL CONTAINERS ON HOST ==="
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' | head -40

echo ""
echo "=== EXPOSED PORTS ==="
ss -tlnp 2>/dev/null | awk '/LISTEN/' | head -30
EOF
