#!/bin/sh
# @(#) bldindex  -  rebuild one index
# Taken from docindex 12/21/00 to be able to rebuild a single filePro file.
# Modified 10/31/00 by Jerry Rains to be used in Installation Utilities Menu.
#     1) Set REPORT2 explicitly to $instutil/report2
#     2) Set MENU2 explicitly to $instdir/oneindex.  Hardcoding to oneindex
#        allowed me to use this reindex.script with the new install.
#     3) Eliminated top.menu, which was hard coded to /etc/default/fppath
#     and set header from environment.

instutil=/appl/fp/util
instdir=/appl/fp/util/bin
tmpdir=/appl/fp/util/tmp
REPORT2=$instutil/report2
MENU2=$instdir/oneindex
$ECHO "PFPROG=$PFPROG
PFDIR=$PFDIR
PFDATA=$PFDATA
PFDSK=$PFDSK
export PFPROG PFDIR PFDATA PFDSK
" >$MENU2
while read version filename index args qualifier
do
  [ "$tmpvar" = "$filename" ] || {
    printf "%-16.16s" $filename
    tmpvar=$filename
    }
done <$REPORT2
$ECHO
$ECHO "This will rebuild all indexes in the chosen file."
$ECHO -n "Enter filename "
read filen
while read version filename index args qualifier
do 
   [ "$filen" = "$filename" -a "$qualifier" = "trans" ] && {
     [ $index = 0 -o $index -gt 0 ] && ALL="-a" || ALL=""
     [ $version = 4.5 ] && DXMAINT=dxmaint.4.5 || DXMAINT=dxmaint.4.1
     [ -n $qualifier ] && QUAL="-m $qualifier" || QUAL=""
     $ECHO \$PFPROG/fp/dxmaint $filename -e -o$index $ALL $QUAL -rf $args -h $filename  >>$MENU2
   }
done <$REPORT2
chown filepro $MENU2
chmod 755 $MENU2
$MENU2

# EOF 'docindex'
