#!/bin/csh -f
# this script runs the TechInfo WAIS index program from cron

# this is where the pips.web file can be located
set PIPS_WEB = "/var/local/techinfo/pips.web"

# this is where the working index files are stored .inv and .dct
set WORKING = "/afs/net.mit.edu/project/wais/autumn/techinfo/search_engine"

# this is where the binaries are
set WAIS_INDEXER = "/afs/net.mit.edu/project/wais/autumn/techinfo/search_engine/@sys/waisindex"

# mailing list
set MAIL = "wade@mit.edu, autumn@mit.edu"

# local log file
set LOCAL_LOG = "/tmp/wais_index_log"

/bin/rm -f $LOCAL_LOG

setenv KRBTKFILE /tmp/wais_tkt

# this is where the krbtgp programs exists on marathon.mit.edu
/var/local/mitdir/krbtgp -s -keyfile /etc/srvtab rcmd.marathon

# get tokens
/bin/athena/aklog -c net.mit.edu

/bin/rm -f ${WORKING}/INDEXLOG
date > $LOCAL_LOG
date
/bin/echo "Starting the indexer...." >> $LOCAL_LOG
$WAIS_INDEXER -d ${WORKING}/temp -stdin -mem 1 < $PIPS_WEB >& ${WORKING}/INDEXLOG

/bin/echo "Finished build."
date

# check status and send mail if the program terminated early.
if ($status == 0) then
/bin/mv -f ${WORKING}/temp.inv ${WORKING}/techinfo.inv
/bin/mv -f ${WORKING}/temp.dct ${WORKING}/techinfo.dct
else
	/bin/echo "*** Problems with build. Check INDEXLOG." >> $LOCAL_LOG
	date >> $LOCAL_LOG
	/usr/ucb/mail -s "Wais index log" $MAIL < $LOCAL_LOG
endif
kdestroy

