Files
onion-dmp/setup-tunnel.sh
2026-04-08 14:52:09 +08:00

83 lines
2.3 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.
#!/bin/bash
# Cloudflare Tunnel 设置脚本
echo "================================================"
echo " 🔧 DMP Cloudflare Tunnel 设置向导"
echo "================================================"
echo ""
echo "📧 Cloudflare 账号: huinkling@gmail.com"
echo "🌐 域名: ink1ing.tech"
echo "🎯 子域名: dmp.ink1ing.tech"
echo ""
echo "================================================"
# 进入项目目录
cd "$(dirname "$0")"
# 检查是否已经登录
echo ""
echo "步骤 1/4: 检查 Cloudflare 登录状态..."
if [ -d "$HOME/.cloudflared" ] && [ -f "$HOME/.cloudflared/cert.pem" ]; then
echo "✅ 已经登录到 Cloudflare"
else
echo "❌ 未登录,需要先登录"
echo ""
echo "请运行以下命令登录到 Cloudflare"
echo ""
echo " cloudflared tunnel login"
echo ""
echo "这将打开浏览器,请使用 huinkling@gmail.com 登录"
echo ""
read -p "按回车键继续..." dummy
cloudflared tunnel login
fi
echo ""
echo "步骤 2/4: 创建 Tunnel..."
# 检查 tunnel 是否已存在
if cloudflared tunnel list 2>/dev/null | grep -q "dmp-tunnel"; then
echo "✅ Tunnel 'dmp-tunnel' 已存在"
else
echo "创建新的 tunnel..."
cloudflared tunnel create dmp-tunnel
fi
echo ""
echo "步骤 3/4: 配置 DNS..."
echo ""
echo "请确认要将 dmp.ink1ing.tech 指向这个 tunnel"
read -p "是否继续配置 DNS? (y/n): " confirm
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
echo "配置 DNS 记录..."
cloudflared tunnel route dns dmp-tunnel dmp.ink1ing.tech
echo "✅ DNS 配置完成"
else
echo "⚠️ 跳过 DNS 配置"
echo ""
echo "你可以稍后手动运行:"
echo " cloudflared tunnel route dns dmp-tunnel dmp.ink1ing.tech"
fi
echo ""
echo "步骤 4/4: 验证配置..."
cloudflared tunnel list
echo ""
echo "================================================"
echo " ✅ 设置完成!"
echo "================================================"
echo ""
echo "下一步:"
echo ""
echo "1. 双击运行 'start-tunnel.command' 启动服务"
echo " 或在终端运行: ./start-tunnel.sh"
echo ""
echo "2. 访问 https://dmp.ink1ing.tech 查看你的应用"
echo ""
echo "3. 本地访问: http://localhost:3456"
echo ""
echo "================================================"