Files
crm-ai/scripts/public-https.sh
T
2026-10-23 10:35:28 +08:00

39 lines
1.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 启动/重启公网 HTTPS(Cloudflare Quick Tunnel),并把 LibreDesk root_url 指过去。
# 注意:quick tunnel 每次重启 URL 会变,需要重新跑本脚本(Meta 里的 webhook 也要同步改)。
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
docker compose up -d public-gateway cloudflared
URL=""
for _ in $(seq 1 30); do
URL=$(docker logs crmnew-cloudflared 2>&1 | grep -oE 'https://[a-zA-Z0-9.-]+\.trycloudflare\.com' | tail -1 || true)
[[ -n "$URL" ]] && break
sleep 1
done
if [[ -z "$URL" ]]; then
echo "未拿到 cloudflared 公网地址,请检查: docker logs crmnew-cloudflared" >&2
exit 1
fi
node scripts/set-public-url.js "$URL"
# 如果已经配置过 WhatsApp,同步更新 Meta 的 app 级 webhook(隧道 URL 变化时必须)
if grep -q '^WA_APP_ID=' .env 2>/dev/null; then
node scripts/set-wa-webhook.js "$URL"
fi
cat <<EOF
公网 HTTPS: $URL
WhatsApp webhook 地址: $URL/webhooks/whatsapp/<inbox_id>
仅暴露:
/webhooks/whatsapp/* (Meta 回调)
/hc/* (帮助中心,AI 引用链接)
/widget* /static/public/*
管理后台 / API 仍只在内网 http://192.168.31.61:9000
EOF