summaryrefslogtreecommitdiff
path: root/localrundig
blob: f8cb8d37c13bb41557319cf69775718028cd9daf (plain)
  1. #!/bin/sh
  2. #
  3. # rundig
  4. #
  5. # $Id: localrundig,v 1.3 2002-01-27 22:33:48 jonas Exp $
  6. #
  7. # This is a sample script to create a search database for ht://Dig.
  8. #
  9. DBDIR=/var/lib/htdig
  10. COMMONDIR=/etc/htdig
  11. BINDIR=/usr/bin
  12. # To help debug problems, try running rundig -vvv
  13. # This will add lots of debugging output to all of the programs
  14. stats= opts= alt= init=
  15. for arg
  16. do
  17. case "$arg" in
  18. -a) alt="$arg" ;;
  19. -s) stats="$arg" ;;
  20. -i) init="$arg" ;;
  21. *) opts="$opts $arg" ;; # e.g. -v or -c config
  22. esac
  23. done
  24. config=`echo "$opts"|sed 's/^.*-c[[:space:]]\+\([[:alnum:]/._-]\+\).*$/\1/'`
  25. test -n "$config" || config=/etc/htdig/htdig.conf
  26. locale=`grep '^locale:' $config | sed -e 's/.*:[[:space:]]*\([[:alnum:]_-]\+\).*/\1/'`
  27. test -n "$locale" || locale=en_US
  28. search_object=`grep '^search_object:' $config | sed -e 's/.*:[[:space:]]*\([[:alnum:]_-]\+\).*/\1/'`
  29. LOCALDBDIR=/var/local/lib/htdig/db/$search_object
  30. LOCALLANGSTATICDIR=/usr/local/lib/htdig/lang/$locale
  31. LOCALLANGDIR=/var/local/lib/htdig/lang/$locale
  32. test -d $LOCALDBDIR || mkdir $LOCALDBDIR
  33. #
  34. # Set the TMPDIR variable if you want htmerge to put files in a location
  35. # other than the default. This is important if you do not have enough
  36. # disk space for the big sort that htmerge runs. Also, be aware that
  37. # on some systems, /tmp is a memory mapped filesystem that takes away
  38. # from virtual memory.
  39. #
  40. TMPDIR=${TMPDIR:-$LOCALDBDIR}
  41. export TMPDIR
  42. $BINDIR/htdig $init $opts $stats $alt
  43. LC_COLLATE=C $BINDIR/htmerge $opts $stats $alt
  44. case "$alt" in
  45. -a)
  46. ( cd $LOCALDBDIR && test -f db.docdb.work &&
  47. for f in *.work
  48. do
  49. mv -f $f `basename $f .work`
  50. done ) ;;
  51. esac
  52. # If you're low on disk space and you don't mind completely reindexing
  53. # every time you run this script, you can always
  54. # rm $DBDIR/db.wordlist
  55. # OR
  56. # If you'd rather run update digs all the time with the minimal databases
  57. # Keep only the following files (and don't call htdig with -i):
  58. # db.docdb, db.docdb.work, db.docs.index, db.wordlist.work, db.words.db
  59. $BINDIR/htnotify $opts
  60. #
  61. # Create the endings and synonym databases if they don't exist
  62. # or if they're older than the files they're generated from.
  63. # These databases are semi-static, so even if pages change,
  64. # these databases will not need to be rebuilt.
  65. case "$locale" in
  66. en_*)
  67. $BINDIR/htfuzzy $opts metaphone ;;
  68. *)
  69. $BINDIR/htfuzzy $opts soundex ;;
  70. esac
  71. if [ "`ls -t $LOCALLANGSTATICDIR/dict.0 $LOCALLANGDIR/word2root.db 2>/dev/null | sed 1q`" = \
  72. "$LOCALLANGSTATICDIR/dict.0" ]
  73. then
  74. $BINDIR/htfuzzy $opts endings
  75. fi
  76. if [ "`ls -t $LOCALLANGSTATICDIR/synonyms $LOCALLANGDIR/synonyms.db 2>/dev/null | sed 1q`" = \
  77. "$LOCALLANGSTATICDIR/synonyms" ]
  78. then
  79. $BINDIR/htfuzzy $opts synonyms
  80. fi