#!/bin/sh
# Copyright (c) 1994 by Adobe Systems Incorporated.
# Script called immediately after a package is installed.
# This script is not supposed to be run by itself.
# $1=Install directory for package. $2=License data file
########################################################

LOOP_LIMIT=25
EB="-n "
EE=""
if [ -x /bin/uname ]
then
	osname=`/bin/uname -s`
	# 64 bit IRIX6 returns IRIX64 for uname -s
	firstfour=`echo "$osname" | sed -e 's/^\(....\).*$/\1/g'`
	if [ "$firstfour" = "IRIX" ] ; then
            osname="IRIX"
	fi
	osversion=`/bin/uname -r`
	check=`echo "$osversion" | egrep '^[0-9]\.[0-9]*'`
	if [ "$check" != "" ]; then
		osmajor=`echo "$osversion" | sed -e 's/^\([0-9][0-9]*\).*/\1/'`
	fi
fi
if [ $osname = "SunOS" ] ; then
	RETURNKEYNAME="Return"
	if [ $osmajor -ge 5 ] ; then
		# For echo without newline under Sys V, set EB and EE variables
		EB=""
		EE="\c"
		PATH=/usr/sbin:/usr/bin:/bin:/usr/bin/X11:/usr/openwin/bin:/sbin:/usr/sbin:/etc:/usr/etc
	else
		PATH=/usr/ucb:/usr/bin:/bin:/usr/bin/X11:/usr/openwin/bin:/sbin:/etc:/usr/etc
	fi
elif [ $osname = "IRIX" ] ; then
	RETURNKEYNAME="Enter"
	# For echo without newline under Sys V, set EB and EE variables
	EB=""
	EE="\c"
	PATH=/usr/sbin:/sbin:/usr/bin:/bin:/usr/bsd:/usr/bin/X11:/usr/openwin/bin:/etc:/usr/etc
fi

#
if [ $# -lt 1 ] ; then
	echo "This script should not be run by itself. It is run"
	echo "automatically as part of Illustrator installation."
	exit 1
fi

# First we move directory X to Illustrator.MacFiles
/usr/bin/mv $1/X $1/Illustrator.MacFiles

# Modify launch script with the information about install directory
/usr/bin/cat $1/bin/illustrator \
| sed 's%INSTALL_DIR=$%INSTALL_DIR="'$1'"%' \
> $1/bin/illustrator.new
/usr/bin/rm -f $1/bin/illustrator
/usr/bin/mv $1/bin/illustrator.new $1/bin/illustrator
chmod 555 $1/bin/illustrator

# Create Adobe Separator lanuch script
/usr/bin/cat $1/bin/illustrator \
| sed 's%^EXECNAME=.*%EXECNAME="Illustrator.MacFiles/Separator_and_Utilities/AdobeSeparator5.01"%' \
> $1/bin/separator.new
/usr/bin/rm -f $1/bin/separator
/usr/bin/mv $1/bin/separator.new $1/bin/separator
chmod 555 $1/bin/separator


if [ $osname = "IRIX" ] ; then
    makepsres_loop=0
    while : ; do
	makepsres_loop=`/usr/bin/expr $makepsres_loop + 1`
	if [ $makepsres_loop -ge $LOOP_LIMIT ] ; then
		echo ""
		echo "LOOP_LIMIT exceeded."
		echo "/usr/lib/DPS/DPSFonts.upr will not be changed."
		exit 1
	fi
	echo ""
	echo 'With both IRIX 5.2 and IRIX 5.3, it is possible that configuration'
	echo 'file /usr/lib/DPS/DPSFonts.upr can have incorrect entries, causing'
	echo 'Adobe Illustrator 5.5 to present an incorrect list of available fonts.'
	echo 'Do you want this installation script to run utility program '
	echo '"makepsres" to regenerate /usr/lib/DPS/DPSFonts.upr so that it will'
	echo 'correctly represent the current list of available fonts.'
	echo $EB'[YES/NO: Press Enter for YES]? '$EE
	read A
	if [ "$A" = "" ] ; then
		do_makepsres=1
		break
	elif [ "$A" = "YES" -o "$A" = "Y" -o "$A" = "yes" -o "$A" = "y" -o "$A" = "Yes" ] ; then
		do_makepsres=1
		break
	elif [ "$A" = "NO" -o "$A" = "N" -o "$A" = "no" -o "$A" = "n" -o "$A" = "No" ] ; then
		do_makepsres=0
		break
	else
		echo ""
		echo "You must specify YES or NO.  Try again."
	fi
    done
    echo ""
    if [ "$do_makepsres" = 1 ] ; then
	if [ -d /usr/lib/DPS ] ; then
	    if [ -x $1/bin/makepsres ] ; then
		if [ -f /usr/lib/DPS/DPSFonts.upr ] ; then
	            /usr/bin/mv /usr/lib/DPS/DPSFonts.upr /usr/lib/DPS/DPSFonts.upr.org
		fi
		$1/bin/makepsres -nb -o /usr/lib/DPS/DPSFonts.upr /usr/lib/DPS/AFM /usr/lib/DPS/outline
		chmod 644 /usr/lib/DPS/DPSFonts.upr
		echo "/usr/lib/DPS/DPSFonts.upr file updated. The original version"
		echo "is saved as /usr/lib/DPS/DPSFonts.upr.org"
	    else
		echo "$1/bin/makepsres does not exist or is not executable."
		echo "DPSFonts.upr file will not be modified. See the README"
		echo "for instructions on how to do this manually."
	    fi
	else
	    echo "/usr/lib/DPS directory does not exist. DPSFonts.upr file"
	    echo "will not be modified. Please install Display PostScript"
	    echo "subsystem using IRIX CD and then see the README for instructions"
	    echo "on how to update DPSFonts.upr file manually."
	fi
    else
	echo "DPSFonts.upr will not be modified. See the README for"
	echo "instructions on how to do this manually if you want"
	echo "to do this in the future."
    fi

fi 

exit 0
