fix: clawd-rfkill.service failed due to systemd $ expansion
systemd expands $rf as env var (empty), breaking the inline script. Move rfkill logic to standalone script to avoid escaping issues. Also use quoted heredoc to prevent bash expansion in install.sh. Made-with: Cursor
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
fix: kill NetworkManager's dnsmasq before starting our own
|
fix: clawd-rfkill.service failed due to systemd $ expansion
|
||||||
|
|
||||||
NetworkManager auto-starts its own dnsmasq when creating a hotspot,
|
systemd expands $rf as env var (empty), breaking the inline script.
|
||||||
which conflicts with our DNS-hijacking dnsmasq on the same interface.
|
Move rfkill logic to standalone script to avoid escaping issues.
|
||||||
Now kill ALL dnsmasq instances before starting ours.
|
Also use quoted heredoc to prevent bash expansion in install.sh.
|
||||||
|
|||||||
25
install.sh
25
install.sh
@@ -67,10 +67,22 @@ for rf in /sys/class/rfkill/rfkill*; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# 持久化:创建 systemd 服务确保开机自动解锁 WiFi
|
# 持久化:独立脚本 + systemd 服务,确保开机自动解锁 WiFi
|
||||||
|
RFKILL_SCRIPT="/usr/local/bin/clawd-unblock-wifi.sh"
|
||||||
|
cat > "$RFKILL_SCRIPT" << 'SCRIPT'
|
||||||
|
#!/bin/sh
|
||||||
|
for rf in /sys/class/rfkill/rfkill*; do
|
||||||
|
[ -f "$rf/type" ] || continue
|
||||||
|
if [ "$(cat "$rf/type")" = "wlan" ] && [ "$(cat "$rf/soft")" = "1" ]; then
|
||||||
|
echo 0 > "$rf/soft"
|
||||||
|
echo "clawd-rfkill: unblocked $(basename "$rf")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
SCRIPT
|
||||||
|
chmod +x "$RFKILL_SCRIPT"
|
||||||
|
|
||||||
RFKILL_SERVICE="/etc/systemd/system/clawd-rfkill.service"
|
RFKILL_SERVICE="/etc/systemd/system/clawd-rfkill.service"
|
||||||
if [ ! -f "$RFKILL_SERVICE" ]; then
|
cat > "$RFKILL_SERVICE" << 'UNIT'
|
||||||
cat > "$RFKILL_SERVICE" <<EOF
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Unblock WiFi for clawd
|
Description=Unblock WiFi for clawd
|
||||||
Before=NetworkManager.service clawd.service
|
Before=NetworkManager.service clawd.service
|
||||||
@@ -78,16 +90,15 @@ After=sys-subsystem-net-devices-wlan0.device
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/bin/sh -c 'for rf in /sys/class/rfkill/rfkill*; do [ "\$(cat \$rf/type)" = "wlan" ] && echo 0 > \$rf/soft; done'
|
ExecStart=/usr/local/bin/clawd-unblock-wifi.sh
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
UNIT
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable clawd-rfkill
|
systemctl enable clawd-rfkill
|
||||||
info "WiFi rfkill 解锁服务已创建(开机自动执行)✓"
|
info "WiFi rfkill 解锁服务已创建 ✓"
|
||||||
fi
|
|
||||||
|
|
||||||
# ── 安装 clawd ───────────────────────────────────────────────────────────────
|
# ── 安装 clawd ───────────────────────────────────────────────────────────────
|
||||||
INSTALL_DIR="/opt/clawd"
|
INSTALL_DIR="/opt/clawd"
|
||||||
|
|||||||
Reference in New Issue
Block a user