#!/bin/bash # Cloudflare Tunnel Start Script for PMFlow CONFIG_FILE="devops/tunnel/config.yml" SETUP_SCRIPT="devops/tunnel/setup.sh" echo "🚀 Checking Cloudflare Tunnel configuration..." # Check if config.yml exists if [ ! -f "$CONFIG_FILE" ]; then echo "⚠️ Named Tunnel Configuration not found." echo " If you have a domain, you can set up a stable tunnel." echo " If not, you can use Quick Tunnels (random URLs)." echo "" read -p "Do you have a domain and want to set up a named tunnel? (y/N): " SETUP_CHOICE if [[ "$SETUP_CHOICE" =~ ^[Yy]$ ]]; then if [ -f "$SETUP_SCRIPT" ]; then # Run setup script and check its exit code if ! bash "$SETUP_SCRIPT"; then echo "❌ Setup failed or was cancelled." exit 1 fi else echo "❌ Setup script not found at $SETUP_SCRIPT" exit 1 fi else echo "🔄 Falling back to Quick Tunnels..." bash devops/tunnel/start-quick.sh exit 0 fi fi # Re-check config after potential setup if [ -f "$CONFIG_FILE" ]; then echo "✅ Configuration found." echo "🌐 Starting tunnel for Frontend and Backend..." # Run the tunnel using the config file cloudflared tunnel run --config "$CONFIG_FILE" else echo "❌ Failed to establish configuration." exit 1 fi