#!/bin/sh

#### THE SPOOL DIR IS "SPOOLDIR" IN THE LINE BELOW ####

wwwoffle_spool=SPOOLDIR

####

# Set the path to include the htdig executables

PATH=$PATH:/usr/local/bin
export PATH

# Set the temporary directory used for merging

#TMPDIR=/tmp
#export TMPDIR

# Set up a log file.

echo > $wwwoffle_spool/html/htdig/wwwoffle-htdig.log

# Create the fuzzy database (only if needed)

if [ ! -f $wwwoffle_spool/html/htdig/common/word2root.db ]; then
    htfuzzy -v endings -c $wwwoffle_spool/html/htdig/conf/htfuzzy.conf >> $wwwoffle_spool/html/htdig/wwwoffle-htdig.log 2>&1
fi

if [ ! -f $wwwoffle_spool/html/htdig/common/synonyms.db ]; then
    htfuzzy -v synonyms -c $wwwoffle_spool/html/htdig/conf/htfuzzy.conf >> $wwwoffle_spool/html/htdig/wwwoffle-htdig.log 2>&1
fi

# Do the digging and merging

htdig -v -s -c $wwwoffle_spool/html/htdig/conf/htdig-incr.conf >> $wwwoffle_spool/html/htdig/wwwoffle-htdig.log 2>&1
htmerge -v -s -c $wwwoffle_spool/html/htdig/conf/htmerge.conf >> $wwwoffle_spool/html/htdig/wwwoffle-htdig.log 2>&1
