2798e29d / scripts /start /cloudflared-start.sh
autoface's picture
first commit
9b205e1
raw
history blame contribute delete
717 Bytes
#!/bin/bash
set -e
# Log function
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [CLOUDFLARED] $*"
}
# Check if Cloudflared is enabled and token is provided
if [[ "${CLOUDFLARED_ENABLED:-false}" == "true" && -n "$CLOUDFLARED_TUNNEL_TOKEN" ]]; then
log "Starting Cloudflare tunnel..."
log "Token: ${CLOUDFLARED_TUNNEL_TOKEN:0:10}..."
# Check if cloudflared binary exists
if ! command -v cloudflared &> /dev/null; then
log "ERROR: cloudflared binary not found in PATH"
exit 1
fi
# Start cloudflared in background
exec cloudflared tunnel run --token "$CLOUDFLARED_TUNNEL_TOKEN"
else
log "Cloudflared is disabled or CLOUDFLARED_TUNNEL_TOKEN is not set"
exit 0
fi