#!/sbin/sh

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

set -a
PATH="/bin:/usr/bin:/etc:."
FILESET=HPXT2-ISOFONTS
umask 022

# Get environment variables as setup earlier in prerequisite fileset    
#
ENVARDIRS="/opt/hpxt/enware2/lbin /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
  PATH=$PATH:/opt/hpxt/enware2/lbin

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

else
  PATH=$PATH:/opt/hpxt/enware2/lbin
fi

MKFONTDIR=/usr/bin/X11/mkfontdir
FONT75=/opt/hpxt/enware2/fonts/iso_8859.1/75dpi
FONT100=/opt/hpxt/enware2/fonts/iso_8859.1/100dpi

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

if [ -d "$FONT75" -a -d /bin ]
then
    if [ ! -f "$MKFONTDIR" ]
    then
        echo "ERROR:   Required font utility $MKFONTDIR not found." >&2
    else
          $MKFONTDIR $FONT75
          xtutil_add-file $FONT75/fonts.dir
    fi
    if [ -f "$FONT75/fonts.alias" ]
    then
      cmp -s $FONT75/fonts.alias $FONT75/fonts.newalias > /dev/null
      if [ $? -ne 0 ]
      then
	mv $FONT75/fonts.alias $FONT75/fonts.oldalias.$$ 2>/dev/null
      fi
    fi
    mv $FONT75/fonts.newalias $FONT75/fonts.alias 2>/dev/null
    xtutil_add-file $FONT75/fonts.alias
    xtutil_rm-file $FONT75/fonts.newalias
else
    echo "ERROR:   Could not find directory $FONT75." >&2
    exit 1
fi

if [ -d "$FONT100" -a -d /bin ]
then
    if [ ! -f "$MKFONTDIR" ]
    then
        echo "ERROR:   Required font utility $MKFONTDIR not found." >&2
    else
          $MKFONTDIR $FONT100
          xtutil_add-file $FONT100/fonts.dir
    fi
    if [ -f "$FONT100/fonts.alias" ]
    then
      cmp -s $FONT100/fonts.alias $FONT100/fonts.newalias > /dev/null
      if [ $? -ne 0 ]
      then
        mv $FONT100/fonts.alias $FONT100/fonts.oldalias.$$ 2>/dev/null
      fi
    fi
    mv $FONT100/fonts.newalias $FONT100/fonts.alias 2>/dev/null
    xtutil_add-file $FONT100/fonts.alias
    xtutil_rm-file $FONT100/fonts.newalias
else
    echo "ERROR:   Could not find directory $FONT100." >&2
    exit 1
fi

exit 0
