Debian Codegraph @

installdir/rundig

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