summaryrefslogtreecommitdiffstats
path: root/debian/htdig/htdig-3.2.0b6/installdir/rundig
blob: c3cba86ed53dd06e69ac1d9c2de58ae514313f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh

#
# rundig
#
# $Id: rundig,v 1.9 2003/12/29 08:49:05 lha Exp $
#
# This is a sample script to create a search database for ht://Dig.
#
DBDIR=@DATABASE_DIR@
COMMONDIR=@COMMON_DIR@
BINDIR=@BIN_DIR@
conffile=@DEFAULT_CONFIG_FILE@

# To help debug problems, try running rundig -vvv
# This will add lots of debugging output to all of the programs
stats= opts= alt=
while [ "$#" -gt 0 ]
do
    case "$1" in
    -a)  alt="$1" ;;
    -s)  stats="$1" ;;
    -c)  shift
         conffile="$1"
	 opts="$opts -c $conffile"
	;;
    *)   opts="$opts $1" ;;	# e.g. -v
    esac
    shift
done

# If -a specified, note the database directory to move the temp files correctly
# TODO: Should also check for files relative to COMMONDIR.
if [ -f "$conffile" ]
then
    new_db_dir=`awk '/^[^#a-zA-Z]*database_dir/ { print $NF }' < $conffile`
    if [ "$new_db_dir" != "" ]
    then
	DBDIR=$new_db_dir
    fi
else
    echo "Config file $conffile cannot be found"
    exit 1
fi

#
# Set the TMPDIR variable if you want htdig and other programs to put 
# files in a location other than the default.  This is important if
# you are running this script as root, since /tmp is usually not
# secure.  Also, be aware that on some systems, /tmp is a memory
# mapped filesystem that takes away from virtual memory.
#
TMPDIR=$DBDIR
export TMPDIR

$BINDIR/htdig -i $opts $stats $alt
$BINDIR/htpurge $opts $alt
case "$alt" in
-a)
  ( cd $DBDIR && test -f db.docdb.work &&
    for f in *.work
    do
        mv -f $f `basename $f .work`
    done
    test -f db.words.db.work_weakcmpr &&
	mv -f db.words.db.work_weakcmpr db.words.db_weakcmpr) ;;
esac
$BINDIR/htnotify $opts
# If you want to use the soundex and (or) metaphone fuzzy matchings,
# Uncomment the following line
# $BINDIR/htfuzzy $opts soundex metaphone

#
# Create the endings and synonym databases if they don't exist
# or if they're older than the files they're generated from.
# These databases are semi-static, so even if pages change,
# these databases will not need to be rebuilt.
#
if [ "`ls -t $COMMONDIR/english.0 $COMMONDIR/word2root.db 2>/dev/null | sed 1q`" = \
	"$COMMONDIR/english.0" ]
then
    $BINDIR/htfuzzy $opts endings
fi

if [ "`ls -t $COMMONDIR/synonyms $COMMONDIR/synonyms.db 2>/dev/null | sed 1q`" = \
	"$COMMONDIR/synonyms" ]
then
    $BINDIR/htfuzzy $opts synonyms
fi