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