Add modem-restart
This commit is contained in:
parent
4911e89749
commit
2fa7dd2eb1
|
@ -0,0 +1,38 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
is_modem_available()
|
||||||
|
{
|
||||||
|
if [ -z "$(lsusb | grep "2c7c:0125")" ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
is_data_available()
|
||||||
|
{
|
||||||
|
if ! nmcli c show --active | grep -e internet -e gsm > /dev/null; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
TRY=0
|
||||||
|
while :; do
|
||||||
|
if ! is_modem_available ; then
|
||||||
|
TRY=$((TRY + 1))
|
||||||
|
echo $(date) Restarting modem, $TRY try
|
||||||
|
systemctl restart eg25-manager
|
||||||
|
systemd-inhibit --what=sleep --why="Modem reset" sleep 60
|
||||||
|
elif [ $TRY -ne 0 ]; then
|
||||||
|
echo $(date): Modem restarted successfully
|
||||||
|
TRY=0
|
||||||
|
elif ! is_data_available; then
|
||||||
|
echo $(date): Restarting mobile data
|
||||||
|
systemd-inhibit --what=sleep --why="Restart mobile data" sleep 5
|
||||||
|
nmcli c up internet
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
done
|
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Restarts eg25-manager if USB connection to the Quectel EG25 modem is lost
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=root
|
||||||
|
WorkingDirectory=/
|
||||||
|
ExecStart=modem-restart
|
||||||
|
Restart=always
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue