1#!/bin/sh 2 3# 4# rundig 5# 6# $Id: rundig,v 1.9 2003/12/29 08:49:05 lha Exp $ 7# 8# This is a sample script to create a search database for ht://Dig. 9# 10DBDIR=@DATABASE_DIR@ 11COMMONDIR=@COMMON_DIR@ 12BINDIR=@BIN_DIR@ 13conffile=@DEFAULT_CONFIG_FILE@ 14 15# To help debug problems, try running rundig -vvv 16# This will add lots of debugging output to all of the programs 17stats= opts= alt= 18while [ "$#" -gt 0 ] 19do 20 case "$1" in 21 -a) alt="$1" ;; 22 -s) stats="$1" ;; 23 -c) shift 24 conffile="$1" 25 opts="$opts -c $conffile" 26 ;; 27 *) opts="$opts $1" ;; # e.g. -v 28 esac 29 shift 30done 31 32# If -a specified, note the database directory to move the temp files correctly 33# TODO: Should also check for files relative to COMMONDIR. 34if [ -f "$conffile" ] 35then 36 new_db_dir=`awk '/^[^#a-zA-Z]*database_dir/ { print $NF }' < $conffile` 37 if [ "$new_db_dir" != "" ] 38 then 39 DBDIR=$new_db_dir 40 fi 41else 42 echo "Config file $conffile cannot be found" 43 exit 1 44fi 45 46# 47# Set the TMPDIR variable if you want htdig and other programs to put 48# files in a location other than the default. This is important if 49# you are running this script as root, since /tmp is usually not 50# secure. Also, be aware that on some systems, /tmp is a memory 51# mapped filesystem that takes away from virtual memory. 52# 53TMPDIR=$DBDIR 54export TMPDIR 55 56$BINDIR/htdig -i $opts $stats $alt 57$BINDIR/htpurge $opts $alt 58case "$alt" in 59-a) 60 ( cd $DBDIR && test -f db.docdb.work && 61 for f in *.work 62 do 63 mv -f $f `basename $f .work` 64 done 65 test -f db.words.db.work_weakcmpr && 66 mv -f db.words.db.work_weakcmpr db.words.db_weakcmpr) ;; 67esac 68$BINDIR/htnotify $opts 69# If you want to use the soundex and (or) metaphone fuzzy matchings, 70# Uncomment the following line 71# $BINDIR/htfuzzy $opts soundex metaphone 72 73# 74# Create the endings and synonym databases if they don't exist 75# or if they're older than the files they're generated from. 76# These databases are semi-static, so even if pages change, 77# these databases will not need to be rebuilt. 78# 79if [ "`ls -t $COMMONDIR/english.0 $COMMONDIR/word2root.db 2>/dev/null | sed 1q`" = \ 80 "$COMMONDIR/english.0" ] 81then 82 $BINDIR/htfuzzy $opts endings 83fi 84 85if [ "`ls -t $COMMONDIR/synonyms $COMMONDIR/synonyms.db 2>/dev/null | sed 1q`" = \ 86 "$COMMONDIR/synonyms" ] 87then 88 $BINDIR/htfuzzy $opts synonyms 89fi 90