#!/sbin/sh

#########################################################################
# 									
#   File:	 customize
#   @(#) customize $Revision: 1.4 $ $Date: 93/02/17 14:52:39 $
#   Description: /etc/update customization script for HPXT-HP8FONTS fileset
# 
#########################################################################
#

umask 022
set -a
PATH="/bin:/usr/bin:/etc:/usr/bin/X11/700X/admin"

FILESET=HPXT-HP8FONTS


# Get environment variables as setup earlier in prerequisite fileset    
#
ENVARDIRS="/opt/hpxt/enware/lbin /usr/bin/X11/700X/admin /tmp /usr/tmp last"
for ENVARDIR in $ENVARDIRS
do
  if [ $ENVARDIR = "last" ]
  then
    echo "WARNING: cannot find suitable env.vars file"
    exit 0
  fi

  if [ -f $ENVARDIR/env.vars ]
  then
    . $ENVARDIR/env.vars
    break
  fi
done


if [ "$OS" = "hp10" ]
then
  PATH=$SW_PATH:/opt/hpxt/enware/lbin

  if [ -f /usr/bin/dcnodes -o -f /usr/sbin/dcnodes ]
  then
    dcnodes -q
    if [ $? -eq 2 ]
    then
        exit 0
    fi
  fi

fi



case $OS in
  hp)
    TOOL=/usr/bin/X11/700X
    FONT=$XTHOME/fonts/hp_roman8/75dpi
    MKFONTDIR=$TOOL/xtmkfontdir
    ;;
  hp10)
    TOOL=${INSTALLDIR}/bin
    FONT=$XTHOME/fonts/hp_roman8/75dpi
    MKFONTDIR=$TOOL/xtmkfontdir
    ;;
esac

if [ "$OS" = "hp" ]
then
  ARCH=$1
  ARCHEXT=""
  case $ARCH in
    HP-MC68*)
	if [ ! hp9000s300 ]
	then
	    ARCHEXT="+/$ARCH"
	fi
	;;
  esac
fi

if [ -d "$FONT" ]
then
    if [ ! -f "$MKFONTDIR" ]
    then
        echo "ERROR:   Required font utility not found in $TOOL." >&2
        echo "         Install fileset HPXT-UTILS first." >&2
    else
           # 
           # Only do the mkfontdir if transition links are installed
           # as it seems that mkfontdir depends on them
           #
           if [ -d /bin ]
           then
             $MKFONTDIR $FONT
             xtutil_add-file $FONT/fonts.dir
           fi
    fi
    if [ -f "$FONT/fonts.alias" ]
    then
      cmp -s $FONT/fonts.alias $FONT/fonts.newalias > /dev/null
      if [ $? -ne 0 ]
      then
        mv $FONT/fonts.alias $FONT/fonts.oldalias.$$ 2>/dev/null
      fi
      mv $FONT/fonts.alias $FONT/fonts.oldalias 2>/dev/null
    fi
    mv $FONT/fonts.newalias $FONT/fonts.alias 2>/dev/null
    xtutil_add-file $FONT/fonts.alias
    xtutil_rm-file $FONT/fonts.newalias
else
    echo "ERROR:   Could not find directory $FONT." >&2
    exit 1
fi

if [ "$OS" = "hp" ]
then
  # remove old 700X fileset
  /bin/rm -rf /system$ARCHEXT/C2300A-FNTHP 2>/dev/null
  /bin/rm -f /etc/filesets$ARCHEXT/C2300A-FNTHP 2>/dev/null

  # remove old 700X fileset
  /bin/rm -rf /system$ARCHEXT/700RX-HP8FONTS 2>/dev/null
  /bin/rm -f /etc/filesets$ARCHEXT/700RX-HP8FONTS 2>/dev/null
fi

exit 0
