#!/bin/sh
########################################################
#
# Shell script: load-tape
#
# 1998, Michael Doran, doran@uta.edu
# University of Texas at Arlington
#
# Reminds tape operator which tape to load for backup.
#
# This cron script should run in the morning.
#
########################################################
# Variables
tape_dev=bullwinkle # machine to load tape on
day=`date +%w` # Day of week [0-6, Sunday=0]
dom=`date +%e` # Day of month [1-31]
operator=taper # see /etc/mail/aliases
# Function to email reminder
remind ()
{
echo "Load $1 tape in ${tape_dev}." | \
mailx -s "Load tape reminder" ${operator}
}
if [ $day -eq 5 ] # Friday
then
if [ $dom -ge 29 -o $dom -le 4 ]
then
remind "the appropriate month's \"1st Monday\""
elif [ $dom -le 11 ]
then
remind "\"2nd Monday\""
elif [ $dom -le 18 ]
then
remind "\"3rd Monday\""
elif [ $dom -le 25 ]
then
remind "\"4th Monday\""
elif [ $dom -ge 26 -a $dom -le 28 ]
then
remind "\"1st Monday\" tape if Monday is the \
beginning of a new month, otherwise load \"5th Monday\""
fi
elif [ $day -eq 1 ] # Monday
then
if [ $dom -ge 31 -o $dom -le 6 ]
then
remind "this month's \"1st Tuesday\""
elif [ $dom -ge 28 -a $dom -le 30 ]
then
remind "\"1st Tuesday\" tape if tomorrow is the \
1st of the month, otherwise load \"Tuesday\""
else
remind \"Tuesday\"
fi
elif [ $day -eq 2 ] # Tuesday
then
remind \"Wednesday\"
elif [ $day -eq 3 ] # Wednesday
then
remind \"Thursday\"
elif [ $day -eq 4 ] # Thursday
then
remind \"Friday\"
fi
exit 0
|