#!/bin/sh # # this script causes the ghosting server # to drift on and off the internet # # # see if we may need to restart diald # if ! `ps -ax | grep diald >>/dev/null` ; then # if so bring it up /etc/ppp/diald-up # wait for diald to come up sleep 5 fi # # see if we are already connected to the net # if ! `ifconfig | grep "^ppp" >/dev/null` ; then # if not, bring link up ping -c 1 myisp.net >/dev/null # wait for link to come up sleep 60 fi # # see if we want to come back up # # normally I only want to be ghosting Monday # through Friday from 7a to 6p # day=`date +%w` hour=`date +%H` if `expr match $day "[123456]" "&" $hour ">" \ 6 "&" $hour "<" 18 >/dev/null` ; then # calculate delay for next up time between 15 and # 60 minutes nxt=`expr $$ % 45 + 15` # append info to file echo `date` "Back: $nxt" >> /var/run/ppp.info # send info to desired destination mail -S ghostship me@myisp me@work\ < /var/run/ppp.info # create an at job to force return at now + $nxt minutes <EOF >/dev/null 2>&1 /etc/ppp/appear EOF fi