#!/bin/bash # 设备状态总检查。写成文件是因为 PowerShell 会吃掉 shell 的 $ 变量。 set -u echo "===== 三个服务 =====" for s in lanremote-relay lanremote-tunnel cf-login; do state=$(systemctl is-active "$s.service" 2>/dev/null) restarts=$(systemctl show "$s.service" -p NRestarts 2>/dev/null | cut -d= -f2) printf " %-20s %-10s 重启 %s 次\n" "$s" "$state" "$restarts" done echo echo "===== 中转健康 =====" curl -s --max-time 8 http://127.0.0.1:8080/v1/health echo echo echo "===== 隧道进程(应该只有 1 个)=====" pgrep -a -f 'cloudflared tunnel' | while read -r pid rest; do printf " PID %-6s %s\n" "$pid" "$rest" done COUNT=$(pgrep -c -f 'cloudflared tunnel' 2>/dev/null || echo 0) echo " 合计 $COUNT 个" echo echo "===== 内存 / 磁盘 =====" free -m | awk 'NR==1 {print " " $0} NR==2 {printf " 已用 %s MB 可用 %s MB\n", $3, $7}' df -h / | awk 'NR==2 {printf " 磁盘可用 %s (%s)\n", $4, $5}' echo echo "===== 隧道地址 =====" cat /root/lanremote-relay/public_url.txt 2>/dev/null || echo " (还没有)" echo echo "===== cf-login 状态 =====" systemctl status cf-login.service --no-pager 2>/dev/null | grep -E '^\s+Active' echo echo "===== cert.pem =====" if [ -f /root/.cloudflared/cert.pem ]; then echo " ✓ 已授权" else echo " ✗ 还没授权" fi