1

我正在尝试在我的设备上设置站模式。如果我在启动后在命令行上给出 wpa_supplicant 命令,它工作正常。但是当我在脚本中给出这些命令然后创建一个 systemd 服务时会断开连接。断开连接后,wlan0 仍然有 ip 地址。我必须用ip addr flush dev wlan0. (另外,我的 wpa_supplicant 可执行文件位于 /home/root 中。)

这有效:以下是我在 cli 上手动给出的命令,我能够 ping。没有问题。

/home/root/wpa_supplicant -B -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
dhclient -i wlan0

./station_mode.sh或者可以改为运行脚本并且它不会给出错误。只有当我启动station.service下面给出的错误时,我才会收到错误消息。


这不起作用 -服务中给出的相同命令会引发错误。

我的脚本:station_mode.sh

#!/bin/sh

rfkill unblock all
/home/root/wpa_supplicant -B -Dnl80211 -iwlan0 -c/etc/wpa_supplicant.conf
dhclient -i wlan0

我的 systemd 服务:/etc/systemd/system/station.service

[Unit]
Description=station mode service.

[Service]
Type=simple
ExecStart=/bin/sh /home/root/station_mode.sh

[Install]
WantedBy=multi-user.target

我给的命令:

systemctl stop wpa_supplicant
systemctl disable --now wpa_supplicant
systemctl start station

输出:

[ 2303.299834] wlan0: authenticate with be:37:a5:d8:96:36
[ 2303.334731] wlan0: send auth to be:37:a5:d8:96:36 (try 1/3)
[ 2303.344189] wlan0: authenticated
[ 2303.348966] wlan0: associate with be:37:a5:d8:96:36 (try 1/3)
[ 2303.369211] wlan0: RX AssocResp from be:37:a5:d8:96:36 (capab=0x1431 status=0 aid=1)
[ 2303.384351] wlan0: associated
[ 2320.245795] wlan0: deauthenticating from be:37:a5:d8:96:36 by local choice (Reason: 3=DEAUTH_LEAVING)

4

1 回答 1

1

我做了journalctl -f,发现State 'stop-sigterm' timed out. Killing.dhclient 被杀了。然后我记得在我的脚本中wpa_supplicant进入了背景 。station_mode.sh

所以,Type应该forking代替simplein station.service

于 2020-09-09T13:23:01.983 回答