End-Of-Day script


ww4m@...
 

FYI here's a script I patched together that runs as a cron job so at
the time of your choosing it will terminate any active connection,
preceeded by a 5-minute advance warning message. You can also use it
to disable your node overnight.

I've tried running it from the console and it works FB. I'm sure
someone can polish it up and improve it (and tell me where I messed
up).

73, Jim WW4M
Raleigh, NC

------------------

# THIS FILE DE WW4M 9/23/01 TO RUN AS CRON JOB
# TO APPEAR IN CRON AS:
#
# nohup /home/irlp/custom/name_of_file > /dev/null &
#
# IT WILL WAIT FOR NO LOCAL ACTIVITY, PLAY A WAV FILE ANNOUNCING
# SOMETHING LIKE 'IRLP CONNECTION WILL BE CLOSED IN FIVE MINUTES',
# THEN COUNTS DOWN AND ENDS CONNECTION, FOLLOWED BY ANOTHER WAV FILE
# WITH THE MESSAGE "YOU HAVE BEEN LISTENING TO IRLP ON THE _____
# REPEATER. FOR MORE INFORMATION CHECK OUT [url].


# define wav files, locted at /home/irlp/audio/custom dir
WARNING=custom/EODwarning
EODFile=custom/kd4raaEOD

# Time after warning until connection is ended, in seconds
EODTIME=300

declare -i EODTIMER

. /home/irlp/custom/environment

# Make sure we are user repeater!!!
if [ `/usr/bin/whoami` != "repeater" ] ; then
echo This program must be run as user REPEATER!
exit 1
fi

# Wait for no COS [local activity], then play warning

echo -en "\nWaiting to send warning message"

sleep 1
echo -en "\nYour node is connected"
while ! $BIN/cosstate; do
sleep 1
done
killall ispeaker >&/dev/null 2>&1
killall ispeaker_PCI >&/dev/null 2>&1
killall sfswrapper >&/dev/null 2>&1
"$SCRIPT"/wavplay $WARNING
"$SCRIPT"/sfswrapper

# count down towards end of connection

echo -en "\n\n"`date ` "EODTimer\n"

# Wait for EOD Timer
EODTIMER=$EODTIME
while [ TRUE ]
do
echo -en "\rWaiting for end of EOD timer: $EODTIMER "
EODTIMER=$EODTIMER-1

# When EOA Timer expires, terminate connection
if [ $EODTIMER = 0 ]
then
break
fi

sleep 1
done

# terminating connection
echo -en "\nEnding any active connection"
$SCRIPT/end
echo -en "\nPlaying end-of-day message"
"$SCRIPT"/wavplay $EODFile
"$SCRIPT"/sfswrapper


# Next line would disable IRLP node until the local/enable file is
# put back in place by another cron job

# /bin/rm -f /home/irlp/local/enable