#!/bin/sh # visibleSMSwatchdog.sh [optional initial delay in seconds] # v 0.2 # based on auto_check_SMS_Visible.sh provided by GL support # if IMS status is good do nothing and recheck later # if IMS status is bad then toggle the modem and recheck later # FOR REFERENCE ONLY # I am clueless and you definitely should not run this clunky script # I hope it gives better scripters some ideas ### pull in some shell functions already present on router . /lib/functions/modem.sh ### defines # log LOG=/root/modemReset.log # from modem.sh BUS=$(get_modem_bus) # where to ping to assure connectivity PINGTARGET=8.8.8.8 # how often to run the loop (in seconds). CHECK_INTERVAL=600 ### functions resetModem() { echo $(uptime) RESETTING MODEM | tee -a $LOG # off gl_modem -B $BUS AT AT+CFUN=0 | tee -a $LOG sleep 10 # back on gl_modem -B $BUS AT AT+CFUN=1 | tee -a $LOG } ############################################################# ### action starts here ###################################### ############################################################# # sleep N seconds if passed on command line # could be useful for calling at boot time if [ -n "$1" ] then echo waiting $1 seconds for first run -- $(UPTIME) | tee -a $LOG sleep $1 fi while true do # ensure we are online, then proceed until ping -c 1 $PINGTARGET; do sleep 30; done # check IMS status # WORKING: +QIMSCFG: "ims_status",0,0,2,2,0,0 # NOT working: +QIMSCFG: "ims_status",0,0,0,0,0,0 echo $(date) checking IMS... | tee -a $LOG IMSSTATUS=$(gl_modem -B 0001:01:00.0 SAT sp AT+QIMSCFG=\"ims_status\" | awk -F , '{print $5}') if [[ $IMSSTATUS -ne 2 ]] then echo "$(uptime) IMS failed" | tee -a $LOG # fix it resetModem fi # and sleep until the next check sleep $CHECK_INTERVAL done