Start mobile data if not available

For some reason, mobile data drops and must be restarted manually. From
own experience, it seems to occur frequently during phone calls.
This commit is contained in:
Xavier Del Campo Romero 2023-03-06 00:17:32 +01:00
parent 1ed167f237
commit 925e01271b
Signed by: xavi
GPG Key ID: 84FF3612A9BF43F2
1 changed files with 13 additions and 0 deletions

View File

@ -9,6 +9,15 @@ is_modem_available()
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
@ -19,6 +28,10 @@ while :; do
elif [ $TRY -ne 0 ]; then
echo $(date): Modem restarted successfully
TRY=0
elif ! is_data_available; then
echo $(date): Restarting mobile data
nmcli c up internet
systemd-inhibit --what=sleep --why="Restart mobile data" sleep 5
fi
sleep 30