Files
dock/cl穿透
2026-01-20 22:20:33 +08:00

27 lines
853 B
Bash
Raw 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 Token
# ==========================================
TUNNEL_TOKEN="这里填入你的Token"
# 检查 Token 是否已填写
if [ "$TUNNEL_TOKEN" = "这里填入你的Token" ] || [ -z "$TUNNEL_TOKEN" ]; then
echo -e "\033[31m[错误] 请先在脚本中填入你的 Tunnel Token\033[0m"
exit 1
fi
echo -e "\033[32m[启动] 正在启动 Cloudflare Tunnel 容器...\033[0m"
# 运行 Docker 容器
docker run -d \
--name cf-tunnel \
--restart always \
cloudflare/cloudflared:latest \
tunnel --no-autoupdate run --token "$TUNNEL_TOKEN"
if [ $? -eq 0 ]; then
echo -e "\033[32m[成功] Tunnel 容器已在后台运行。\033[0m"
else
echo -e "\033[31m[失败] 容器启动失败,请检查 Docker 安装情况。\033[0m"
fi