I have determined that my /etc/init.d/wanwatchdogstart script runs if another script I have is stopped. This script, which I call usbmodemstart, automatically starts and manages the aircard using wvdial.
Let me start from the beginning. I have a script at /etc/init.d/usbmodemstart
Code:
#! /bin/sh
APP_PATH=/usr/sbin/monusbmodem
# script name
NAME=usbmodemstart
# app name
DESC=usb modem startup script
#exit automatically if some variable isn't set
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
/usr/sbin/monusbmodem
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --name sh monusbmodem
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --name sh monusmodem
sleep 5
/usr/sbin/monusbmodem
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
I put this script as a startup item by running:
Code:
sudo update-rc.d usbmodemstart defaults
That script calls the program /usr/sbin/monusbmodem
Code:
while [ 1 ]
sleep 5
do
running=`ps -C wvdial | grep wvdial`
if [ -z $running ]; then
echo "wvdial NOT working"
sleep 30
running2=`ps -C wvdial | grep wvdial`
if [ -z $running2 ]; then
echo "starting wvdial now"
killall wvdial
/usr/sbin/usbmodem
fi
else
echo "wvdial working"
fi
done
Which monitors for the wvdial process. If it is running then it waits 5 seconds and runs again. If it is not, it waits another 30 seconds and if it's still not running it kills any instances of wvdial just to be sure, and then starts the usbmodem script
Code:
eject /dev/sr0
wvdial &
sleep 10
route del default
route add default dev ppp0
shorewall start
This script ejects the aircards mountable disk if applicable, runs wvdial, and sets up the firewall so that everyone can access the internet through this machine. These scripts have been doing their job for months without any real problems. That is, until our aircards suddenly started getting into a state where they think they're connected, but no real WAN connectivity exists.
When I stop the usbmodemstart, my wanwatchdog scripts starts. I do notice that the monusbmodem and usbmodem scripts are still active in the processes. Something is wrong, I'm just not sure what.
Bookmarks