#!/bin/sh
#
#  file: index-edgar
#  auth: Brad Burdick
#  desc: Create a WAIS index of the SEC EDGAR filings (hdr.sgml only)
#
##########################################################################
#  Copyright (c) 1994, 1995 Internet Multicasting Service
#
#  The SEC EDGAR Level 1 Dissemination processing software ("software")
#  was developed by the Internet Multicasting Service and may 
#  be used for academic, research, government, and internal business
#  purposes without charge.  You may not resell this code or include it
#  in a product that you are selling without prior permission of the
#  Internet Multicasting Service.
#
#  This software is provided ``as is'', without express or implied
#  warranty, and with no support nor obligation to assist in its
#  use, correction, modification or enhancement.  We assume no liability
#  with respect to the infringement of copyrights, trade secrets, or any
#  patents, and are not responsible for consequential damages.  Proper
#  use of the software is entirely the responsibility of the user.
##########################################################################

# who to notify about index problems
notify='edgar-ops'

indexdir='/usr/local/wais/indexes'
index="$indexdir/edgar1"

waisindex='/usr/local/bin/waisindex'
indexflags="-d ${index} -nocat -nosrc -mem 128"

waisparse='/usr/local/bin/waisparse'
parseflags='-parse edgar -'

/bin/find /ftp/edgar/data -depth -type f -name '*.sgml' -print | \
  ${waisparse} ${parseflags} | ${waisindex} ${indexflags}

# was WAIS index successful
if [ ! -f ${index}/index.inv0 ] ; then
	/bin/mv $indexdir/edgar $indexdir/edgar-
	/bin/mv $indexdir/edgar1 $indexdir/edgar
	/bin/cp -p /ftp/edgar/data/.tmp/index.* /ftp/edgar/data/.index/
	/bin/mv $indexdir/edgar $indexdir/edgar1
	/bin/mv $indexdir/edgar- $indexdir/edgar
	/bin/chmod g+w /ftp/edgar/data/.index/index.*
	/bin/rm -f /ftp/edgar/data/.tmp/index.*

	/usr/ucb/mail -s 'EDGAR index finished' ${notify} < /dev/null >/dev/null 2>&1
else
	/usr/ucb/mail -s 'EDGAR index error' ${notify} < /dev/null >/dev/null 2>&1
fi

/bin/rm -f /tmp/edgar.out

exit 0

