#!/bin/sh
TempIndex="/users/brewery/public_html/gambmug/index/gm_temp" # index files to write chunks to
IndexFile="/users/brewery/public_html/gambmug/index/gm"      # master index files to merge to
Index="gm"
URLPrefix="http://brewery.org/brewery/gambmug/recs"     #URL prefix for this index
Exclude="/home/users/brewery/public_html/gambmug/index/gm_exclude"                 #words not to index
touch $Exclude                                  #make it exist if absent

Dir="/users/brewery/public_html/gambmug/recs"		# base directory to index
cd $Dir

find . -name "*.html" -print > /users/brewery/public_html/gambmug/index/html_lst  #gather all *.html files
find . -name "*.htm" -print >> /users/brewery/public_html/gambmug/index/html_lst  #gather all *.html files
find . -name "*.shtml" -print >> /users/brewery/public_html/gambmug/index/html_lst  #gather all *.shtml files
cd /users/brewery/public_html/gambmug/index/
sort -u html_lst > tmp
mv tmp gm_html_lst
split -500 gm_html_lst gm_html		# split up files into manageable chunks
rm gm_html_lst

Parms1="-c -f -l 2 -u 25 -n -a -w$Exclude $IndexFile $URLPrefix"  
Parms2="-c -f -l 2 -u 25 -n -a -w$Exclude $TempIndex $URLPrefix"

File="index.html" 	#a starting point to make first index file
cd $Dir
touch $File
/users/brewery/public_html/cgi-bin/ffwindex $Parms1 $File

for file in /home/users/brewery/public_html/gambmug/index/gm_html*		#index all documents
do
	echo $file
	/users/brewery/public_html/cgi-bin/ffwindex -i $file $Parms2  
	cd /users/brewery/public_html/gambmug/index
	/users/brewery/public_html/cgi-bin/ffwmerge temp  $IndexFile $TempIndex
	mv temp.dix $Index.dix
	mv temp.ind $Index.ind
	mv temp.ptr $Index.ptr
	mv temp.url $Index.url
	cd $Dir
done
cd /users/brewery/public_html/gambmug/index
rm gm_html*
rm $TempIndex.*
