End-of-Day script, v2


ww4m@...
 

The first version I posted had a bug or two. This one definitely
works when listed in my crontab as

55 23 * * * (/home/irlp/custom/end_cron > /dev/null 2>&1)

73, Jim WW4M

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


# THIS FILE DE WW4M 9/23/01 TO RUN AS CRON JOB
# TO APPEAR IN CRON AS:
#
# (/home/irlp/custom/end_cron > /dev/null 2>&1)
#
# 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
WARNING=custom/EODwarning
EODFile=custom/kd4raaEOD

# Time until connection is ended
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


# When no COS, 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
"$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"
sleep 1
"$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