#!/bin/sh

#################################################
#
# Process vt320 package
#
#################################################

###################################################
# pull in environment variables common to
# postinstall/postremove/request/and.. scripts
###################################################
umask 022

ADMINDIR=/opt/hpxt/enware2/lbin
. $ADMINDIR/env.vars


########################
# Install man page 
########################

if [ "$OS" = "sco" ]
then
  SMANDIR=$TOPDIR/usr/share/man/man1
  DMANDIR=/usr/man/cat.LOCAL
  MANPAGES="hpxt.vt320.LOCAL"
else
  SMANDIR=$SYMLINK/share/man
  DMANDIR=/usr/share/man
  MANPAGES="man1/hpxt.vt320.1"
fi
       
if [ "$COPYMAN" = "yes" ]
then
  REPLY="yes"
else
  REPLY="no"
fi

case $REPLY in
  y*|Y*)
    # MAN PAGES
    #################################################

    for i in $MANPAGES
    do
      cp $SMANDIR/$i $DMANDIR/$i > /dev/null
      if [ $? -ne 0 ]
      then
        echo ""
        echo "Copy of man page failed."
        echo "$DMANDIR is probably nfs mounted or mounted read-only."
	echo "you can do this copy manually after installation" 
	echo ".. continuing"
        echo ""
        break
      fi
      chmod 444  $DMANDIR/${i}
      chown root $DMANDIR/${i}
      chgrp bin  $DMANDIR/${i}
    done
  ;;
esac


#--------------------------------------------------------
# update directives with info for this package
#--------------------------------------------------------
#
PARTS="vt320"

for PART in $PARTS
do
  THISDIRECTIVE=$NEWDIR/bin/directives.$PART
  cat $NEWDIR/bin/directives | egrep -i directive | egrep -i "$PART" > /dev/null
  if [ $? -ne 0 ]
  then
    if [ -f $THISDIRECTIVE ]
    then
      cat $THISDIRECTIVE >> $NEWDIR/bin/directives
    else
      echo "WARNING: could not find $THISDIRECTIVE"
    fi
  fi
  rm  -f $THISDIRECTIVE
done


exit 0
