misc/debian/bullseye/configs/etc/systemd/system/qmicli@.service

41 lines
1.3 KiB
Desktop File

# Enable using systemctl enable --now qmicli@0 (where 0 = wwan0, 1 = wwan1 etc).
[Install]
WantedBy=multi-user.target
[Unit]
Description=Configure wwan%i device cdc-wdm using qmicli
Before=freepbx.service asterisk.service
After=sys-subsystem-net-devices-wwan%i.device
Wants=sys-subsystem-net-devices-wwan%i.device
[Service]
Restart=always
RestartSec=120s
TimeoutSec=240s
# Qmicli default args.
Environment=qmi="-d /dev/cdc-wdm%i"
# Name of the network device (as shown by networkctl) for the above.
Environment=dev_name="wwan%i"
# Stop the wwan device so we can reconfigure it correctly.
ExecStartPre=networkctl down $dev_name
# Set the correct data format.
ExecStartPre=sh -c "echo 'Y' | tee /sys/class/net/$dev_name/qmi/raw_ip"
# Enable auto-connect.
ExecStartPre=sh -c "qmicli $qmi --wds-set-autoconnect-settings=enabled,roaming-allowed || true"
# Get settings (starting the network).
ExecStartPre=sh -c "qmicli $qmi --wds-follow-network --wds-get-autoconnect-settings --client-no-release-cid || true"
# Bring up the network.
ExecStartPre=networkctl up $dev_name
ExecStartPre=ping -w 120 -c 10 -I $dev_name one.one.one.one
# Main "process" to keep an eye on the network.
ExecStart=bash -e -c "while true; do ping -w 120 -I $dev_name -c 5 one.one.one.one || exit 1; sleep 300; done;"