#!/bin/sh logentry() { #SEND A STRING TO THIS FUNCTION TO APPEND IT TO THE LOG FILE echo -e "$1" >> /home/user/MyDocs/tmp/autoDCscriptLOG.txt } osnotify() { #SEND A STRING TO THIS FUNCTION TO GENERATE A SYSTEM POPUP run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"$1" } #PREPARE INITIAL VARIABLES FOR TEMPORAL MONITORING OF NETWORK INTERFACES getcell=`ifconfig phonet0 | grep RX.p | cut -d: -f2` getwifi=`ifconfig wlan0 | grep RX.p | cut -d: -f2` bakcell=$getcell bakwifi=$getwifi getcellup=`ifconfig | grep gprs0 | cut -d: -f0` getwifiup=`ifconfig wlan0 | grep inet.addr | cut -d: -f2` #LOG MONITOR STARTUP TO FILE & NOTIFY USER VIA POPUP logentry "\nIdle Monitor Startup $(date)\nEVENTS:\n" osnotify "Automatic internet disconnection monitor has started" #PERFORM MAIN MONITORING LOOPS while true ; do #CHANGE THE NUMBER AFTER SLEEP TO SET THE NUMBER OF SECONDS BEFORE #THE INTERNET IS DISCONNECTED IF NO INTERNET ACTIVITY IS DETECTED sleep 300 getcell=`ifconfig phonet0 | grep RX.p | cut -d: -f2` getwifi=`ifconfig wlan0 | grep RX.p | cut -d: -f2` getcellup=`ifconfig | grep gprs0 | cut -d: -f0` getwifiup=`ifconfig wlan0 | grep inet.addr | cut -d: -f1` if [ -n "$getcellup" -o -n "$getwifiup" ]; then #IF EITHER NETWORK INTERFACE HAS AN IP PROCEED WITH INACTIVITY TEST if [ "$getcell" == "$bakcell" -a "$getwifi" == "$bakwifi" ]; then #IF NO PACKETS WERE RECEIVED SINCE LAST RECORDING THEN SHUTDOWN INTERFACES dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true if [ -n "$getcellup" ]; then osnotify "The 2G/3G internet connection has been closed due to inactivity" logentry " - 2G/3G DISCONNECTED @ $(date)" elif [ -n "$getwifiup" ]; then osnotify "The WI-FI internet connection has been closed due to inactivity" logentry " - WI-FI DISCONNECTED @ $(date)" else osnotify "The internet connection has been closed due to inactivity" logentry " - ????? DISCONNECTED @ $(date)" fi fi bakcell=$getcell bakwifi=$getwifi fi done exit