我有一个简单的systemd.service
方法可以从 LTE 模块启动 qmi 连接。它工作正常,并且在我启动服务时建立了连接。我的问题是,状态并不通知服务已经activated
,但永久已经activating
。
这是状态:
● qmi_connect.service - QMI Auto Connection
Loaded: loaded (/etc/systemd/system/qmi_connect.service; disabled; vendor preset: enabled)
Active: activating (auto-restart) since Wed 2022-04-27 11:45:28 BST; 4s ago
Process: 8030 ExecStart=/bin/bash /home/pi/Ubiquo/LTE/qmi/qmi_connect.sh (code=exited, status=0/SUCCESS)
Main PID: 8030 (code=exited, status=0/SUCCESS)
CPU: 491ms
服务:
[Unit]
Description=QMI Auto Connection
After=network.target
[Service]
User=root
ExecStart=/bin/bash /home/pi/Ubiquo/LTE/qmi/qmi_connect.sh
WorkingDirectory=/home/pi/Ubiquo/LTE/qmi
StandardOutput=inherit
StandardError=inherit
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
以及启动 qmi 连接的 bash 脚本:
#!/bin/bash
APN="net2.vodafone.pt"
ip link set dev wwan0 down
echo Y > /sys/class/net/wwan0/qmi/raw_ip
ip link set dev wwan0 up
qmicli --device=/dev/cdc-wdm0 --device-open-proxy --wds-start-network="ip-type=4,apn=$APN" --client-no-release-cid
udhcpc -q -f -n -i wwan0