#!/bin/bash # Script completo para desplegar OpenVidu Meet con LiveKit local y UDP set -e echo "🚀 Desplegando OpenVidu Meet con LiveKit local (UDP)..." # Colores para output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Verificar Docker if ! command -v docker &> /dev/null; then echo -e "${RED}❌ Docker no está instalado${NC}" exit 1 fi if ! command -v docker-compose &> /dev/null; then echo -e "${RED}❌ Docker Compose no está instalado${NC}" exit 1 fi # Obtener IP local LOCAL_IP=$(hostname -I | awk '{print $1}') echo -e "${BLUE}🌐 IP Local detectada: $LOCAL_IP${NC}" # Crear .env para local echo -e "${YELLOW}📝 Creando configuración local...${NC}" cat > .env.local << EOF # Configuración LOCAL con LiveKit y UDP ADMIN_PASSWORD=admin123 REDIS_PASSWORD=redispassword # LiveKit Local LIVEKIT_URL=ws://$LOCAL_IP:7880 LIVEKIT_API_KEY=devkey LIVEKIT_API_SECRET=secretsecretsecretsecretsecretsecret # Redis Local REDIS_HOST=$LOCAL_IP REDIS_PORT=6379 EOF # Actualizar IP en livekit-local.yaml echo -e "${YELLOW}🔧 Configurando LiveKit para IP $LOCAL_IP...${NC}" sed -i "s/external_ip: \".*\"/external_ip: \"$LOCAL_IP\"/" livekit-local.yaml # Configurar firewall echo -e "${YELLOW}🔥 Configurando firewall...${NC}" ./configure-udp-ports.sh # Parar servicios existentes echo -e "${YELLOW}🛑 Parando servicios existentes...${NC}" docker-compose -f docker-compose-with-livekit.yml down 2>/dev/null || true # Construir imágenes echo -e "${YELLOW}🔨 Construyendo imágenes...${NC}" docker-compose -f docker-compose-with-livekit.yml build # Iniciar servicios echo -e "${YELLOW}🚀 Iniciando servicios completos...${NC}" docker-compose -f docker-compose-with-livekit.yml --env-file .env.local up -d # Esperar a que los servicios estén listos echo -e "${YELLOW}⏳ Esperando servicios...${NC}" sleep 15 # Verificar servicios echo -e "${BLUE}🔍 Verificando servicios...${NC}" services=( "redis:6379" "livekit:7880" "openvidu-meet:6080" "nginx:80" ) for service in "${services[@]}"; do name=$(echo $service | cut -d: -f1) port=$(echo $service | cut -d: -f2) if curl -s http://localhost:$port > /dev/null 2>&1; then echo -e "${GREEN}✅ $name funcionando en puerto $port${NC}" else echo -e "${RED}❌ $name no responde en puerto $port${NC}" fi done # Verificar puertos UDP echo -e "${BLUE}📊 Verificando puertos UDP...${NC}" if ss -tulnp | grep -q ":50000-60000"; then echo -e "${GREEN}✅ Puertos UDP 50000-60000 abiertos${NC}" else echo -e "${YELLOW}⚠️ No se detectan puertos UDP - verificar manualmente${NC}" fi # Mostrar URLs finales echo -e "${GREEN}" echo "=============================================" echo "🎉 DESPLIEGUE COMPLETADO" echo "=============================================" echo "📱 OpenVidu Meet: http://$LOCAL_IP" echo "👨‍💼 Admin Panel: http://$LOCAL_IP/admin" echo "🔧 LiveKit API: http://$LOCAL_IP:7880" echo "📊 Redis: $LOCAL_IP:6379" echo "" echo "🔐 Credenciales Admin:" echo " Usuario: admin" echo " Password: admin123" echo "" echo "⚠️ PUERTOS NECESARIOS:" echo " TCP: 80, 6080, 6379, 7880" echo " UDP: 50000-60000 (WebRTC)" echo "=============================================" echo -e "${NC}" # Mostrar logs en tiempo real (opcional) read -p "¿Ver logs en tiempo real? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then docker-compose -f docker-compose-with-livekit.yml --env-file .env.local logs -f fi