# CUAdig
#
# script to update the search database for the CUA websites.
#
# Created by Benjamin Smedberg (41smedberg@cua.edu)
# May 17, 1999

verbose= isinitial=0

for arg
do
	case "$arg" in

	-v) verbose=-v ;;
	-i) isinitial=1 ;;

	esac
done

INSTALLDIR=/htdig
DBDIR=$INSTALLDIR/db
COMMONDIR=$INSTALLDIR/common
BINDIR=$INSTALLDIR/bin
CONFDIR=$INSTALLDIR/conf


TMPDIR=$DBDIR/work
export TMPDIR

echo Deleting working files...
if rm $verbose -f ${DBDIR}/work/*
then
	echo Delete complete successfully.
else	
	echo Delete not successful. Script aborting.
	exit 1
fi


if test $isinitial -eq 1
then
	initial=-i
	echo Using new databases.
else
	initial=
	echo Copying files...
	if cp $verbose -f ${DBDIR}/db.wordlist ${DBDIR}/db.docdb ${DBDIR}/work
	then
		echo Copy completed successfully.
	else
        	echo Copy not successful. Script aborting.
        	exit 1
	fi
fi

echo Starting Dig...
if $BINDIR/htdig $verbose $initial -s -c ${CONFDIR}/CUAdig.conf
then
	echo htdig successful.
else
        echo htdig not successful. Script aborting.
        exit 1
fi


echo Starting word merge...
if $BINDIR/htmerge $verbose -s -c ${CONFDIR}/CUAdig.conf
then
	echo htmerge successful.
else
        echo htmerge not successful. Script aborting.
        exit 1
fi


echo Starting fuzzy merge...
if $BINDIR/htfuzzy $verbose -c ${CONFDIR}/CUAdig.conf endings synonyms soundex metaphone
then
	echo htfuzzy completed successfully.
else
        echo htfuzzy not successful. Script aborting.
        exit 1
fi


echo Re-copying files...
if cp $verbose -f ${DBDIR}/work/* ${DBDIR}
then
	echo Copying completed successfully.
else
        echo re-copy not successful. Script aborting.
        exit 1
fi


echo Notifying page owners...
$BINDIR/htnotify $verbose