PMFlow/devops/tunnel/start.sh

36 lines
927 B
Bash
Executable File

#!/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 "⚠️ Configuration not found. Starting setup..."
if [ -f "$SETUP_SCRIPT" ]; then
# Run setup script and check its exit code
if ! ./$SETUP_SCRIPT; then
echo "❌ Setup failed or was cancelled."
exit 1
fi
else
echo "❌ Setup script not found at $SETUP_SCRIPT"
exit 1
fi
fi
# Re-check config after potential setup
if [ -f "$CONFIG_FILE" ]; then
echo "✅ Configuration found."
echo "🌐 Starting tunnel..."
# Run the tunnel using the config file
cloudflared tunnel run --config "$CONFIG_FILE"
else
echo "❌ Failed to establish configuration."
exit 1
fi