#!/bin/sh

#
# rundig
#
# This is a sample script to create a search database for ht://Dig.
#
if [ "$1" = "-v" ]; then
    verbose=-v
fi
if [ "$2" = "-s" ]; then
    stats=-s
fi

#
# Set the TMPDIR variable if you want htmerge to put files in a location
# other than the default.  This is important if you do not have enough
# disk space for the big sort that htmerge runs.  Also, be aware that
# on some systems, /tmp is a memory mapped filesystem that takes away
# from virtual memory.
#
TMPDIR=/var/lib/htdig/db
export TMPDIR

/usr/sbin/htdig -i $verbose $stats
/usr/sbin/htmerge $verbose $stats
/usr/sbin/htnotify $verbose

#
# Only create the endings database if it doesn't already exist.
# This database is static, so even if pages change, this database will not
# need to be rebuilt.
#
FUZZYALGS="soundex metaphone"
if [ ! -f /var/lib/htdig/common/word2root.db ]
then
    FUZZYALGS="$FUZZYALGS endings"
fi

if [ ! -f /var/lib/htdig/common/synonyms.db ]
then
    FUZZYALGS="$FUZZYALGS synonyms"
fi
/usr/sbin/htfuzzy $verbose $FUZZYALGS
