#!/bin/sh
if [ "$PRODUCTS" != "" ]
then
. /usr/local/etc/setups.sh
setup juke
fi
# Defaults
# JUKELIST is a list of jukebox:low:high:tape entries
# MAILTO is a mail address to send the output to
#
JUKELIST="nojuke:0:9:/dev/null other:0:9:/dev/null"
MAILTO=mengel@dcdmwm.fnal.gov
#
# Allow command line overrides like NAME=value by eval-ing them
#
for i in $*
do
eval $i
done
export TAPE MAILTO
trap "" 1 2
for entry in $JUKELIST
do
#split jukelist entry into items by colons
SEPARATOR=":"; SAVEIFS="$IFS"; IFS="$SEPARATOR$IFS"
set x $entry; jname=$2; low=$3; high=$4; TAPE=$5;
IFS="$SAVEIFS"
# Redirect output to mail program
(
echo "Subject: createmap for jukebox $jname"
echo "Putting $jname online"
juke online -j $jname
i=$low
while [ $i -le $high ]
do
echo "Doing slot $i"
if juke list -j $jname -s $i | grep '(empty)' > /dev/null 2>&1
then
echo "Empty..."
else
juke load -j $jname -s $i -d $TAPE
dd if=$TAPE of=/tmp/cmap$$ bs=2k
read line < /tmp/cmap$$
mt unload
juke unload -j $jname -d $TAPE
if [ "$line" != "" ]
then
juke rename -j $jname -s $i $line
fi
juke list -j $jname -s $i
fi
i=`expr $i + 1`
done
) 2>&1 | /bin/mail $MAILTO &
done