#!/bin/sh


quiet=""
if [ "$1" = "-q" ] ; then
  quiet="-q"
fi

# create a file to insure that no one searches during an index
touch /home/httpd/html/linux/2000/indexing-in-progress

# CRONFILE FOR ARCHIVE IN DIRECTORY /home/httpd/html/linux/2000

# delete the search boxes in all current files (filelist may change
/usr/local/bin/addsearch /home/httpd/html/linux/2000 -r $quiet

# Do the retrieving
/usr/local/bin/makenh /home/httpd/html/linux/2000 $quiet

# put the search box in the html files -- will check config file
#  and will not do anything if not wanted
/usr/local/bin/addsearch /home/httpd/html/linux/2000

# Do the indexing
if [ "$quiet" = "-q" ] ; then
   /bin/cat /home/httpd/html/linux/2000/.wg_toindex | /usr/local/bin/glimpseindex -H /home/httpd/html/linux/2000 -o -t -h -X -U -f -C -F > /dev/null
else
   /bin/cat /home/httpd/html/linux/2000/.wg_toindex | /usr/local/bin/glimpseindex -H /home/httpd/html/linux/2000 -o -t -h -X -U -f -C -F

fi

# Compress neighbourhood files
if [ "$quiet" = "-q" ] ; then
  /bin/cat /home/httpd/html/linux/2000/.wg_madenh | /usr/local/bin/wgconvert -H /home/httpd/html/linux/2000 -U -P .nh. -F -ni | grep -v "^hash_misses=0"
else
  /bin/cat /home/httpd/html/linux/2000/.wg_madenh | /usr/local/bin/wgconvert -H /home/httpd/html/linux/2000 -U -P .nh. -F -ni
fi

# now change the directory and set the permissions
cd /home/httpd/html/linux/2000
chmod a+r .glimpse_*

# remove the locking file
/bin/rm -f /home/httpd/html/linux/2000/indexing-in-progress

