#!/bin/bash # 诊断 + 恢复正常隧道。 # 我的 A/B 脚本把三个配置都试成了 0%,得先查清 + 恢复。 set -u echo "===== 1. 服务状态 =====" for s in lanremote-tunnel lanremote-tunnel-quic lanremote-relay \ lanremote-watchdog.timer; do printf " %-28s %s\n" "$s" "$(systemctl is-active "$s" 2>/dev/null)" done echo echo "===== 2. 当前 unit =====" if [ -f /etc/systemd/system/lanremote-tunnel.service ]; then grep -E 'ExecStart|Description' /etc/systemd/system/lanremote-tunnel.service \ | sed 's/^/ /' else echo " unit 文件不存在!" fi echo echo "===== 3. cloudflared 进程 =====" pgrep -a -f cloudflared | sed 's/^/ /' || echo " 没有进程" echo echo "===== 4. 隧道日志尾部 =====" tail -14 /root/lanremote-relay/tunnel.log 2>/dev/null | sed 's/^/ /' \ || echo " (没有日志)" echo echo "===== 5. 本地源站 =====" echo " relay: HTTP $(timeout 8 curl -s -o /dev/null -w '%{http_code}' \ http://127.0.0.1:8080/v1/health 2>/dev/null)" echo echo "===== 6. 隧道指标端口 =====" timeout 5 curl -s --max-time 4 http://127.0.0.1:20241/metrics 2>/dev/null \ | grep -E '^cloudflared_tunnel_(ha_connections|total_requests)' \ | sed 's/^/ /' || echo " 指标读不到(说明 cloudflared 没在跑)" echo echo "===== 7. 配置里的隧道 ID =====" grep -E 'tunnel|credentials' /root/.cloudflared/config.yml 2>/dev/null \ | sed 's/^/ /'