#!/bin/bash # 查为什么开机自启没生效。 set -u echo "===== 开机多久了 / 到哪个 target =====" uptime echo " default target: $(systemctl get-default)" echo " multi-user: $(systemctl is-active multi-user.target)" echo " graphical: $(systemctl is-active graphical.target)" echo echo "===== wants 软链接建了吗 =====" ls -l /etc/systemd/system/multi-user.target.wants/ 2>/dev/null | grep -i lanremote || echo " ✗ 没有软链接" echo echo " graphical.target.wants:" ls -l /etc/systemd/system/graphical.target.wants/ 2>/dev/null | grep -i lanremote || echo " (没有)" echo echo "===== 这次开机 systemd 有没有处理过这两个单元 =====" journalctl -b --no-pager -u lanremote-relay 2>/dev/null | tail -8 echo " ---" journalctl -b --no-pager -u lanremote-tunnel 2>/dev/null | tail -6 echo " (上面为空 = 这次开机 systemd 压根没碰过它们)" echo echo "===== network-online 为什么没到 =====" systemctl is-enabled NetworkManager-wait-online.service 2>/dev/null || echo " 没有 NetworkManager-wait-online" systemctl is-active NetworkManager-wait-online.service 2>/dev/null echo echo "===== 现在两个服务什么状态 =====" systemctl is-active lanremote-relay lanremote-tunnel echo echo "===== 手动都拉起来看看行不行 =====" systemctl start lanremote-relay sleep 3 systemctl start lanremote-tunnel sleep 5 systemctl is-active lanremote-relay lanremote-tunnel echo tail -3 /root/lanremote-relay/tunnel.log 2>/dev/null