Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save abhijayrajvansh/f40af79a5532cd27a9ef88d7b84db8ca to your computer and use it in GitHub Desktop.

Select an option

Save abhijayrajvansh/f40af79a5532cd27a9ef88d7b84db8ca to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
# usage:
# ./generate-env.sh
# ./generate-env.sh https://your-tunnel.trycloudflare.com
#
# prints env lines for openclaw-comfyui-skill .env
BASE_URL="${1:-}"
WORKFLOW_PATH="${WORKFLOW_PATH:-./workflow-api.json}"
OUTPUT_DIR="${OUTPUT_DIR:-./downloads}"
# try auto-detect bearer token from caddy config
TOKEN=""
if [[ -f /etc/Caddyfile ]]; then
TOKEN=$(grep -Eo 'Authorization "Bearer [a-f0-9]{32,}"' /etc/Caddyfile | head -n1 | sed -E 's/.*Bearer ([a-f0-9]{32,})/\1/' || true)
if [[ -z "$TOKEN" ]]; then
TOKEN=$(grep -Eo 'auth_token=[a-f0-9]{32,}' /etc/Caddyfile | head -n1 | cut -d= -f2 || true)
fi
fi
# try auto-detect trycloudflare url from common logs if base url wasn't passed
if [[ -z "$BASE_URL" ]]; then
BASE_URL=$(grep -RhoE 'https://[a-z0-9-]+\.trycloudflare\.com' /var/log /tmp /workspace 2>/dev/null | head -n1 || true)
fi
if [[ -z "$BASE_URL" ]]; then
BASE_URL="https://your-comfy-endpoint.trycloudflare.com"
fi
if [[ -z "$TOKEN" ]]; then
TOKEN="your_bearer_token_here"
fi
cat <<EOF
COMFY_BASE_URL=$BASE_URL
COMFY_BEARER_TOKEN=$TOKEN
WORKFLOW_PATH=$WORKFLOW_PATH
OUTPUT_DIR=$OUTPUT_DIR
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment