#!/bin/bash echo "=== Ranking CAPES - Iniciando sistema ===" pkill -f "ngrok http 5173" 2>/dev/null docker network create shared_network 2>/dev/null echo "[1/3] Liberando portas ocupadas..." sudo lsof -i :8000 -t 2>/dev/null | xargs -r sudo kill -9 sudo lsof -i :5173 -t 2>/dev/null | xargs -r sudo kill -9 echo "[2/3] Subindo containers Docker..." cd /home/fred/projetos/ranking docker compose up -d backend frontend sleep 3 if ! docker ps | grep -q ranking_backend; then echo "ERRO: Backend não subiu!" exit 1 fi if ! docker ps | grep -q ranking_frontend; then echo "ERRO: Frontend não subiu!" exit 1 fi echo "[3/3] Iniciando ngrok..." ngrok http 5173 --log=stdout > /tmp/ngrok-ranking.log 2>&1 & sleep 4 NGROK_URL=$(curl -s http://127.0.0.1:4040/api/tunnels 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['tunnels'][0]['public_url'])" 2>/dev/null) if [ -z "$NGROK_URL" ]; then echo "ERRO: ngrok não iniciou corretamente" exit 1 fi echo "" echo "==========================================" echo " Sistema Ranking CAPES iniciado!" echo "==========================================" echo "" echo " URL Publica (ngrok): $NGROK_URL" echo "" echo " URLs Locais:" echo " - Frontend: http://localhost:5173" echo " - Backend: http://localhost:8000" echo " - Ngrok UI: http://localhost:4040" echo "" echo "=========================================="