games_app/deploy/vps-hardening/diag-pg-docker2.sh
Your Name 5ce6a6811a
Some checks failed
CI / test-and-build (push) Failing after 25s
Add Gitea CI/CD stack, tloto-deploy, and tagged Compose images
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 19:56:39 +02:00

40 lines
1.3 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
cd ~/games_app
echo "== docker0 / bridges =="
ip -4 addr show | grep -E 'inet |^[0-9]+:' || true
echo "== host-gateway resolve =="
sudo docker run --rm --add-host=host.docker.internal:host-gateway alpine \
getent hosts host.docker.internal || true
echo "== ufw =="
sudo ufw status verbose || true
echo "== iptables 5432 =="
sudo iptables -L INPUT -n -v | head -40
sudo iptables -L DOCKER-USER -n -v 2>/dev/null || true
sudo iptables -L FORWARD -n -v | head -20
echo "== pg_hba docker lines =="
sudo grep -E '172\.|192\.168|tloto' /etc/postgresql/*/main/pg_hba.conf || true
echo "== try connect to docker0 IP if any =="
DOCKER0=$(ip -4 -o addr show docker0 2>/dev/null | awk '{print $4}' | cut -d/ -f1 || true)
echo "docker0=$DOCKER0"
PGPASS=$(python3 - <<'PY'
import re
from pathlib import Path
m=re.search(r'^POSTGRES_PASSWORD=(.*)$', Path('.env').read_text(), re.M)
print(m.group(1).strip() if m else '')
PY
)
export PGPASSWORD="$PGPASS"
if [[ -n "${DOCKER0:-}" ]]; then
timeout 5 psql -h "$DOCKER0" -U postgres -d games_platform_db -c 'SELECT 1 AS via_docker0;' || echo "via_docker0 FAIL"
fi
timeout 5 psql -h 172.16.0.1 -U postgres -d games_platform_db -c 'SELECT 1 AS via_172_16;' || echo "via_172.16.0.1 FAIL"
echo "DIAG_DONE"