wpj428/files/usr/sbin/wwan_reconnect

18 lines
665 B
Bash
Executable file

#!/bin/sh
MODEM_STATE=$(mmcli --modem 0 --output-keyvalue|grep "modem.generic.state"|grep -o "\w*$")
BEARER=$(mmcli --modem 0 --output-keyvalue|grep 'modem.generic.bearers.value\[1\]'|grep -o '\d*$')
BEARER_CONNECTED=$(mmcli -b $BEARER --output-keyvalue|grep bearer.status.connected|grep -o "\w*$")
echo "(modem state: $MODEM_STATE, bearer connected: $BEARER_CONNECTED, bearer id: $BEARER)"
if [[ $MODEM_STATE == 'registered' ]] ; then
echo "trigger simple-connect"
ifup broadband
sleep 600 # prevent loops
elif [[ $MODEM_STATE == 'disabled' ]] ; then
echo "trigger simple-connect"
ifup broadband
sleep 600 # prevent loops
else
echo "do nothing"
fi