#!/bin/sh
#Tag 0x006d
# Copyright (c) 1993 by Adobe Systems Incorporated.
#
# Shell script for launching Illustrator.
#
# This script accepts command line parameters in the form:
#    -e xxx=yyy
# where "xxx" is a shell variable name and "yyy" is the value.
# For each parameter that follows -e, this script does an eval on the parameter.
# The following shell variables are reasonable candidates for setting on the 
# command line (see comments below for a description of these variables):
#    LM_LICENSE_FILE
#    ILLUSTRATOR_ROOT
#    ILLUSTRATOR_VERSION
#    ILLUSTRATOR_BUILD
#    ILLUSTRATOR_DFT_FS
#    ILLUSTRATOR_AD_START_DATE
#    DIRECTXLIB
# Example: illustrator -e LM_LICENSE_FILE=/usr/local/flexlm/licenses/license.dat
###################################################################

# Make sure Berkeley stuff and X stuff is on user's path so hostname can be found.
PATH=$PATH:/usr/ucb:/usr/bsd:/usr/bin/X11
export PATH

MKDIR="/usr/bin/mkdir -p"
LN="/usr/bin/ln -s"
LS=/usr/bin/ls
RM="/usr/bin/rm -f"
CP="/usr/bin/cp"
AWK="/usr/bin/awk"
MV="/usr/bin/mv"

USEDIRECTXLIB=0
EXECNAME=Illustrator.MacFiles/AdobeIllustrator5.5

OPTIONALS=":ArtworkViewSpeedup:CustomToProcess:OverPrint:RevertTextPath:Riders:"
OptExtDir="Illustrator.MacFiles/Plug-ins/Optional_Extensions"

ORIG_LICENSE_FILE="$LM_LICENSE_FILE"
LM_LICENSE_FILE=""

# <INSTALL_DIR> holds the directory into which the product
# was installed (e.g., /usr/adobe/Illustrator_5.5).
# This script computes the value of INSTALL_DIR as follows:
#	1) If environment variable ILLUSTRATOR_HOME has a value, then that is used.
#	2) Otherwise, try to determine it automatically by determining the
#		location of this launch script and using its parent directory.
#		If file <parent directory>/exec/acroexch_exec exists, then assume
#		we have determined the parent directory correctly.
#	3) Otherwise, use the value hardcoded into this script.
export INSTALL_DIR
INSTALL_DIR=
if [ "$ILLUSTRATOR_HOME" != "" ] ; then
	INSTALL_DIR="$ILLUSTRATOR_HOME"
else
	# Try to determine automatically the parent directory to this launch script.
	thisscriptname=$0

	# Follow any symbolic links in thisscriptname.
	while : ; do
		lsresult=`$LS -l $thisscriptname`
		symlink=`expr "$lsresult" : '.*>'.*`

		if [ "$symlink" -gt 0 ] ; then
			oldscriptname="$thisscriptname"
			thisscriptname=`echo $lsresult | sed -e 's/^.*-> *\(.*\) *$/\1/g'`
			abspath_new=`expr "$thisscriptname" : '^/'`
			if [ $abspath_new != 1 ] ; then
				abspath_old=`expr "$oldscriptname" : '^/'`
				if [ $abspath_old != 1 ] ; then
					olddir=`pwd`
				else
					olddir=`expr "$oldscriptname" : '\(.*\)/'`
				fi
				thisscriptname="$olddir/$thisscriptname"
			fi
		else
			break
		fi
	done

	# Determine directory containing this shell script.
	scriptdir=`expr $thisscriptname : '\(.*\)/'` 
	if [ "$scriptdir" = "" -o "$scriptdir" = "." ] ; then
		scriptdir=`pwd`
	fi

	# Determine root directory for installation ($scriptdir/..).
	parentdir=`expr $scriptdir : '\(.*\)/'` 

	if [ -x "$parentdir/$EXECNAME" -o -x "$parentdir/$EXECNAME"_v8 -o -x "$parentdir/$EXECNAME"_v7 ]; then
		INSTALL_DIR="$parentdir"
	fi
fi

# <LM_LICENSE_FILE> is the file containing the license keys for this app.
# If this front-end shell script does not properly set the value of this
# environment variable or the license file does not contain appropriate license
# keys, the product will print an error message at start-up and will not run.
# This launch script gives first priority to the LM_LICENSE_FILE value
# the is passed on the command line via "-e LM_LICENSE_FILE=xxx".
# Second priority goes to the inherited vale of LM_LICENSE_FILE
# environment variable. Thirdly, this launch script first looks for the file of the name
# $INSTALL_DIR/custom/LM_LICENSE_FILE and looks for a line in this file
# of the form "LM_LICENSE_FILE=xxx" (must start in column 1)
# and sets environment variable LM_LICENSE_FILE to xxx.
# If licensing is not working properly, it may because this file is missing
# or has an incorrect value. If so, edit this file with a text editor.
# Alternatively, you can override the value of LM_LICENSE_FILE by launching
# this script with '-e LM_LICENSE_FILE=xxx' command line arguments.
export LM_LICENSE_FILE
if [ -f "$INSTALL_DIR/custom/LM_LICENSE_FILE" ] ; then
        CUSTOM_LICENSE_FILE=`grep '^LM_LICENSE_FILE' "$INSTALL_DIR/custom/LM_LICENSE_FILE"  | sed -e 's/^LM_LICENSE_FILE= *\([^ ]\)/\1/'`
fi

# <SITE_PSRESOURCEPATH> is a list of directories containing
# site-specific PostScript resources (such as fonts) that might
# be useful to this application.
# This launch script first looks for a file of the name
# $INSTALL_DIR/custom/SITE_PSRESOURCEPATH and looks for a line in this file
# of the form "SITE_PSRESOURCEPATH=xxx" (must start in column 1)
# and sets environment variable SITE_PSRESOURCEPATH to xxx.
# If this application does not find it PostScript resources properly, it could
# be that this file is missing or has an incorrect value.
# If so, edit this file with a text editor.
# Alternatively, you can override the value of SITE_PSRESOURCEPATH by launching
# this script with '-e SITE_PSRESOURCEPATH=xxx' command line arguments.
# Finally, if $INSTALL_DIR/custom/SITE_PSRESOURCEPATH does not have a valid
# entry and if no '-e SITE_PSRESOURCEPATH=xxx' option is given, then this
# script will use the value of SITE_PSRESOURCEPATH that was inherited from the
# user's current environment.
if [ -f "$INSTALL_DIR/custom/SITE_PSRESOURCEPATH" ] ; then
	site_path=`grep '^SITE_PSRESOURCEPATH' "$INSTALL_DIR/custom/SITE_PSRESOURCEPATH"  | sed -e 's/^SITE_PSRESOURCEPATH= *\([^ ]\)/\1/'`
	if [ "$site_path" != "" ] ; then
		eval SITE_PSRESOURCEPATH="$site_path"
	fi
fi

# Make sure that the directories listed in SITE_PSRESOURCEPATH
# are included within the user's PSRESOURCEPATH environment variable.
# Insert these directories into where :: appears in PSRESOURCEPATH.
if [ "$SITE_PSRESOURCEPATH" != "" ] ; then
    export PSRESOURCEPATH
    if [ "$PSRESOURCEPATH" = "" ] ; then
        PSRESOURCEPATH="$SITE_PSRESOURCEPATH::"
    else
        PSRESOURCEPATH=`echo $PSRESOURCEPATH | /usr/bin/sed "s^::^:$SITE_PSRESOURCEPATH::^"`
    fi
    # Replace triple colons with double colons.
    PSRESOURCEPATH=`echo $PSRESOURCEPATH | /usr/bin/sed "s/:::/::/g"`
fi

# Make sure DISPLAY variable has a value
export DISPLAY
if [ "$DISPLAY" = "" ] ; then
    DISPLAY=":0"
else
    # If DISPLAY environment variable is of form <hostname>:0 and <hostname>
    # matches the name of this host, then strip off <hostname> to prevent
    # network accesses. 
    displayhost=`echo $DISPLAY | sed 's/:.*//'`
    if [ "$displayhost" = `hostname` ] ; then
	DISPLAY=`echo $DISPLAY | sed 's/.*:/:/'`
    fi
fi

# Set which version of Illustrator we should run.
DEFAULT_VERSION="5.5"
if [ "$ILLUSTRATOR_VERSION" = "" ] ; then
	ILLUSTRATOR_VERSION="$DEFAULT_VERSION"
fi
DEFAULT_BUILD="rc4"
if [ "$ILLUSTRATOR_BUILD" = "" ] ; then
	ILLUSTRATOR_BUILD="$DEFAULT_BUILD"
fi

# Determine the OS/productversion/GUI
# appropriate for the current user based on the computer
# he is currently logged into.
MACHINE="UNKNOWN"
OS="UNKNOWN"
osname="UNKNOWN"
osversion="UNKNOWN"
osmajorminor="UNKNOWN"
osmajor="UNKNOWN"
osminor="UNKNOWN"
if [ -r /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
        # osmajorminor will be like "4.2". osmajor: "4". osminor:"2".
        osmajorminor=`echo "$osversion" | sed -e 's/^\([0-9]\.[0-9]\).*/\1/'`
        osmajor=`echo "$osversion" | sed -e 's/^\([0-9][0-9]*\).*/\1/'`
        osminor=`echo "$osversion" | sed -e 's/^[0-9]\.\([0-9][0-9]*\).*/\1/'`
    else
        osversion="UNKNOWN"
    fi
fi
error=0

if [ "$osname" = "SunOS" ]
then
    # Sun machines: we only support Sparc under SunOS5.3
    if [ -r /usr/bin/sparc ] && /usr/bin/sparc
    then
        MACHINE="sparc"
        if [ "$osmajor" = "5" ] && [ "$osminor" -ge 3 ]
        then
            OS="sunos5.3"
            if [ -x /usr/sbin/prtconf ] ; then
		# sort -u is for MP Sparc
                sparcversion=`/usr/sbin/prtconf -vp | fgrep 'sparc-version:' | sort -u | sed 's/.*sparc-version:[ 	0]*//'`
                if [ "$sparcversion" = "" ] ; then
                    sparcversion=7
                fi
            else
                sparcversion=7
            fi

            # Launch different binaries depending on type of Sparc processor.
            if [ $sparcversion -gt 7 ] ; then
                CHIPVERSION="v8"
            else
                CHIPVERSION="v7"
            fi
        else
            echo Invalid operating system version returned from 'uname -r': $osversion$bell.
            error=1
        fi
    else
        echo $productname is not available for your type of Sun machine$bell.
        error=1
    fi

elif [ "$osname" = "IRIX" ]
then
    # SGI machines: we only support IRIX 5.2 and above
    if [ -r /bin/mips ] && /bin/mips
    then
        MACHINE="mips"
        if [ "$osmajor" -gt "5" ] ; then 
                echo Warning. This product has not been tested under operating system version: $osversion$bell.
        elif [ "$osmajor" = "5" ] && [ "$osminor" -ge 2 ] ; then
            OS="irix5.2"
        else
            echo Invalid operating system version returned from 'uname -r': $osversion$bell.
            error=1
        fi
    else
        echo $productname is not available for your type of SGI machine$bell.
        error=1
    fi
fi
if [ $error = 1 ] ; then
    exit 1
fi

# <DFT_ILLUSTRATOR_ROOT> is the directory relative to $HOME which mirrors
# directory structure of <INSTALL_DIR>. Not used for local installations.
if [ "$DFT_ILLUSTRATOR_ROOT" = "" ] ; then
    DFT_ILLUSTRATOR_ROOT="$HOME/AdobeIllustrator5.5"
fi

# Set up system dependent variable values.
if [ "$osname" = "IRIX" ] ; then
    DIRECTXLIB=""
else
    if [ "$OPENWINHOME" = "" ] ; then
        export OPENWINHOME
        OPENWINHOME=/usr/openwin
    fi
    PATH=$PATH:$OPENWINHOME/bin

    export LD_LIBRARY_PATH
    if [ "$USEDIRECTXLIB" = 1 ] ; then
        XILHOME=/opt/SUNWits/Graphics-sw/xil
        export XILHOME

        # We need to get direct XLIB stuff correctly, so insert
        # $OPENWINHOME/lib before user's LD_LIBRARY_PATH
        LD_LIBRARY_PATH="$XILHOME/lib:$OPENWINHOME/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"

        # Location of direct XLIB directory.
        DIRECTXLIB=/opt/SUNWdxlib/bin/dxlib
    else
        LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$OPENWINHOME/lib"
    fi
fi

# Process command line parameters.
while [ $# -gt 0 ] ; do
    # "-e" allows particular values from this script
    # to be overwritten from the command line.
    # For example, -e LM_LICENSE_FILE=/usr/local/licenses
    if [ "$1" = "-e" ] ; then
        shift
        eval "$1"
        shift
    else
        break
    fi
done

# At this stage, if LM_LICENSE_FILE has a value, it came from "-e LM_LICENSE_FILE".
# ORIG_LICENSE_FILE holds value of LM_LICENSE_FILE when launch script was invoked.
# CUSTOM_LICENSE_FILE holds contents from <installdir>/custom/LM_LICENSE_FILE.
#
# Set LM_LICENSE_FILE to be the union of these three settings.
if [ "$LM_LICENSE_FILE" != "" ] ; then
        if [ "$ORIG_LICENSE_FILE" != "" ] ; then
                LM_LICENSE_FILE="$LM_LICENSE_FILE:$ORIG_LICENSE_FILE"
        fi
else
        LM_LICENSE_FILE="$ORIG_LICENSE_FILE"
fi
if [ "$LM_LICENSE_FILE" != "" ] ; then
        if [ "$CUSTOM_LICENSE_FILE" != "" ] ; then
                LM_LICENSE_FILE="$LM_LICENSE_FILE:$CUSTOM_LICENSE_FILE"
        fi
else
        LM_LICENSE_FILE="$CUSTOM_LICENSE_FILE"
fi


# Set ILLUSTRATOR_ROOT if not provided already by user.
# For shared installations, use DFT_ILLUSTRATOR_ROOT to set ILLUSTRATOR_ROOT.
# Otherwise, set ILLUSTRATOR_ROOT to INSTALL_DIR.
if [ "$ILLUSTRATOR_ROOT" = "" ] ; then
	ILLUSTRATOR_ROOT="$DFT_ILLUSTRATOR_ROOT"
fi

# If things are installed properly, ILLUSTRATOR_ROOT should be different
# from INSTALL_DIR.
if [ "$ILLUSTRATOR_ROOT" = "$INSTALL_DIR" ] ; then
    echo ""
    echo "Incorrect settings for ILLUSTRATOR_ROOT and INSTALL_DIR."
    echo "They are both set to: $ILLUSTRATOR_ROOT."
    echo "Unable to launch $0."
    echo ""
    exit 1

else

    # Ensure that user has appropriate directories and symbolic
    # links in $HOME/AdobeIllustrator to real Illustrator install.
    if [ ! -d "$ILLUSTRATOR_ROOT" ] ; then
        ${MKDIR} "$ILLUSTRATOR_ROOT"
    fi

    # Check file which indicates last version user has run.
    if [ -f "$ILLUSTRATOR_ROOT/.illustrator_version" ] ; then
        version=`cat $ILLUSTRATOR_ROOT/.illustrator_version`
    else
        version=""
    fi
    targetversion="Illustrator_"$ILLUSTRATOR_VERSION$ILLUSTRATOR_BUILD"_"$OS"_"$MACHINE"_$INSTALL_DIR"

    # Create new links only if previous installation does not match the new one
    if [ "$version" != "$targetversion" ]; then
 
        ${RM} "$ILLUSTRATOR_ROOT/.illustrator_version"
        echo "$targetversion" > "$ILLUSTRATOR_ROOT/.illustrator_version"

	# Create directories for Fonts, Prefs, Scratch
        for dir in 'Illustrator.MacFiles/System/Fonts' \
               'Illustrator.MacFiles/System/Preferences' \
               'Illustrator.MacFiles/System/Temporary Items' ; do
            dir="$ILLUSTRATOR_ROOT/$dir"
            if [ ! -d "$dir" ] ; then
                ${MKDIR} "$dir"
            fi
        done

	# Create a QuorumApps file so that we don't ask for Application Folder
	${RM} "$ILLUSTRATOR_ROOT/Illustrator.MacFiles/System/Preferences/QuorumApps"
	echo 'ART5 Illustrator.MacFiles:AdobeIllustrator5.5' > "$ILLUSTRATOR_ROOT/Illustrator.MacFiles/System/Preferences/QuorumApps"
	echo 'ASEP Illustrator.MacFiles:Separator_and_Utilities:AdobeSeparator5.01' >> "$ILLUSTRATOR_ROOT/Illustrator.MacFiles/System/Preferences/QuorumApps"

	# Link Keyboard preferences files
	file="Illustrator.MacFiles/System/Preferences/Keyboards"
	# First create all the keyboard directories
	for dir in 'Sparc' 'SGI' 'SGI-PS2' 'HP' 'Other' ; do
	    dir="$ILLUSTRATOR_ROOT/$file/$dir"
            if [ ! -d "$dir" ] ; then
                ${MKDIR} "$dir"
            fi
	done
	# We should make links based on Display types but right now just create
	# links for SGI and Sparc. 
        subpath="Illustrator.MacFiles/System/Preferences/Keyboards"
        dirlist="Sparc SGI SGI-PS2"
        dft="Default Keyboard"
        for d in $dirlist ; do
            ${RM} "$ILLUSTRATOR_ROOT"/$subpath/$d/*eyboard
            if [ "_`${LS} ${ILLUSTRATOR_DIR}/${subpath}/${d}/*eyboard 2>/dev/null`" = '_' ] ; then
                ${LN} "$INSTALL_DIR"/$subpath/$d/*eyboard "$ILLUSTRATOR_ROOT"/$subpath/$d
                ${RM} "$ILLUSTRATOR_ROOT/$subpath/$d/%$dft"
                ${RM} "$ILLUSTRATOR_ROOT/$subpath/$d/$dft"
                ${CP} "$INSTALL_DIR/$subpath/$d/%UNIX-PC Keyboard" "$ILLUSTRATOR_ROOT/$subpath/$d/%$dft"               
                ${CP} "$INSTALL_DIR/$subpath/$d/UNIX-PC Keyboard" "$ILLUSTRATOR_ROOT/$subpath/$d/$dft"
		chmod u+w "$ILLUSTRATOR_ROOT/$subpath/$d/%$dft"
		chmod u+w "$ILLUSTRATOR_ROOT/$subpath/$d/$dft"
            fi
        done

	# Link Illustrator executable (See end for v7 or v8 version for Sparc)
	file="Illustrator.MacFiles/AdobeIllustrator5.5"
	${RM} "$ILLUSTRATOR_ROOT/$file"
	if [ "$osname" = "IRIX" ] ; then
   	    ${LN} "$INSTALL_DIR/$file" "$ILLUSTRATOR_ROOT/$file"
	fi

        #Create Separator_and_Utilities directory.
        file="Illustrator.MacFiles/Separator_and_Utilities"
        if [ ! -d "$ILLUSTRATOR_ROOT/$file" ] ; then
            ${MKDIR} "$ILLUSTRATOR_ROOT/$file"
        fi
        #Link everything except the exec. We will link v7 or v8 exec later on.
        ${RM} $ILLUSTRATOR_ROOT/$file/*
        ${LN} $INSTALL_DIR/$file/* "$ILLUSTRATOR_ROOT/$file/"
        if [ "$osname" = "SunOS" ] ; then
            ${RM} $ILLUSTRATOR_ROOT/$file/AdobeSeparator5.01*
        fi

	# Create a Plug-ins directory and remove links to Standard plug-ins (Do not
	# remove other directories)
        file="Illustrator.MacFiles/Plug-ins"
        if [ ! -d "$ILLUSTRATOR_ROOT/$file" ] ; then
            ${MKDIR} "$ILLUSTRATOR_ROOT/$file"
	fi
	# This was just temporary
	#${RM} $ILLUSTRATOR_ROOT/$file/*
	# Link Hyphenation files
	${RM} $ILLUSTRATOR_ROOT/$file/*Hyphenation 
	${LN} $INSTALL_DIR/$file/*Hyphenation "$ILLUSTRATOR_ROOT/$file/"
	# Link Dictionaries
	${RM} $ILLUSTRATOR_ROOT/$file/*7.5* 
	${LN} $INSTALL_DIR/$file/*7.5* "$ILLUSTRATOR_ROOT/$file/"
	# Copy User Dictionary file
	if [ ! -f $ILLUSTRATOR_ROOT/$file/AI*Dictionary ] ; then 
	   ${CP} $INSTALL_DIR/$file/*AI*Dictionary* "$ILLUSTRATOR_ROOT/$file/"
	   chmod u+w $ILLUSTRATOR_ROOT/$file/*AI*Dictionary*
	fi
	# Copy Startup file
	if [ ! -f $ILLUSTRATOR_ROOT/$file/Adobe*Startup ] ; then
	   ${CP} $INSTALL_DIR/$file/*Adobe*Startup "$ILLUSTRATOR_ROOT/$file/"
	   chmod u+w $ILLUSTRATOR_ROOT/$file/*Adobe*Startup
	fi
	# Link AdobeStandard plug-ins
	${RM} $ILLUSTRATOR_ROOT/$file/AdobeStandard 
	${LN} $INSTALL_DIR/$file/AdobeStandard "$ILLUSTRATOR_ROOT/$file/"

        # Create empty Optional_Extensions directories
        file="$OptExtDir"
        if [ ! -d "$ILLUSTRATOR_ROOT/$file" ] ; then
            ${MKDIR} "$ILLUSTRATOR_ROOT/$file"
        fi
 
	# link custom brushes, palettes, curves, tutorials, textconv, fonts (2 MM fonts)
        for dir in 'Color_Systems' \
		   'fonts' \
		   'Gradients_and_Patterns' \
		   'Sample_Files' \
		   'Tutorial' \
		   'TextConv'; do
            dir="Illustrator.MacFiles/$dir"
            ${RM} -r "$ILLUSTRATOR_ROOT/$dir"
            ${LN} "$INSTALL_DIR/$dir" "$ILLUSTRATOR_ROOT/$dir"
        done
        
	# Clean up the Fonts directory.
        ${RM} $ILLUSTRATOR_ROOT/Illustrator.MacFiles/System/Fonts/*

	# link Illustrator and System resource files
        for file in 'Illustrator.MacFiles/System/%System' \
                'Illustrator.MacFiles/%AdobeIllustrator5.5' ; do
            ${RM} "$ILLUSTRATOR_ROOT/$file"
            ${LN} "$INSTALL_DIR/$file" "$ILLUSTRATOR_ROOT/$file"
        done

	# link readme file to ILLUSTRATOR_ROOT
	file="readme"
	${RM} "$ILLUSTRATOR_ROOT/$file"
        ${LN} "$INSTALL_DIR/$file" "$ILLUSTRATOR_ROOT/$file"
    fi
fi

# Make sure that Xinet files are not present in the Illustrator.MacFiles area.
file="$ILLUSTRATOR_ROOT/Illustrator.MacFiles/.HSancillary"
if [ -f "$file" -o -d "$file" ] ; then
    echo ""
    echo '*** Startup Error ***'
    echo ""
    echo Directory $ILLUSTRATOR_ROOT/Illustrator.MacFiles
    echo contains a file/directory named .HSancillary. Illustrator
    echo will not launch with this file/directory present. Please
    echo remove this file/directory and relaunch Illustrator.
    exit 1
fi

# Quorum toolkit needs to be oriented with environment variable QUORUM_ROOT
export QUORUM_ROOT
QUORUM_ROOT="$ILLUSTRATOR_ROOT"

# If ILLUSTRATOR_DFT_FS is set, set QUORUM_DEFAULT_FS to the value of
# ILLUSTRATOR_DFT_FS.
export QUORUM_DEFAULT_FS
case "$ILLUSTRATOR_DFT_FS" in
AD|ad|APPLEDOUBLE|appledouble|AppleDouble|NFSShare|NFSshare|NFSSHARE|nfsshare)
    QUORUM_DEFAULT_FS="AD"
    ;;
ETHERSHARE|EtherShare|Ethershare|ethershare|Helios|HELIOS|helios)
    QUORUM_DEFAULT_FS="ETHERSHARE"
    ;;
K-ASHARE|K-AShare|KASHARE|KAShare|kashare|Xinet|XINET|xinet)
    QUORUM_DEFAULT_FS="K-ASHARE"
    ;;
PARTNER|Partner|partner|IPT|ipt)
    QUORUM_DEFAULT_FS="PARTNER"
    ;;
*)
    if [ "$ILLUSTRATOR_DFT_FS" != "" ] ; then
        echo ""
        echo "ILLUSTRATOR_DFT_FS has an invalid value: $ILLUSTRATOR_DFT_FS."
        echo "Valid default file system types are AD, ETHERSHARE, K-ASHARE and PARTNER."
        echo "Will set ILLUSTRATOR_DFT_FS to AD (Apple Double)."
    fi
    QUORUM_DEFAULT_FS="AD"
    ;;
esac

# Set QUORUM_AD_START_DATE variable based on ILLUSTRATOR_AD_START_DATE. This is
# to give users a choice to work around a bug in Intercon's NFS/Share. AppleDouble
# standard published by Apple says that the date info resource should be an offset
# from Jan 1, 2000, but Intercon writes it in format based on Jan 1, 1904. User's
# can set this variable to 2000 or 1904, the default value is 2000. This will write
# date info resource based on user's choice so transferring them to Mac using
# NFS/Share will yield correct date.
if [ "$ILLUSTRATOR_AD_START_DATE" != "" ]; then
    if [ "$ILLUSTRATOR_AD_START_DATE" != "2000" -a "$ILLUSTRATOR_AD_START_DATE" != "1904" ]; then
        echo ""
        echo "ILLUSTRATOR_AD_START_DATE has an invalid value: $ILLUSTRATOR_AD_START_DATE."
        echo "Valid default appledouble start dates are 2000 and 1904."
        echo "Will use default value of ILLUSTRATOR_AD_START_DATE = 2000."
    else
	export QUORUM_AD_START_DATE
	QUORUM_AD_START_DATE="$ILLUSTRATOR_AD_START_DATE"
    fi
fi

# IRISShare support (disabled by default for performace reasons). IRISshare
# renames files with spaces to files with spaces converted to underscores.
# This is not in the K-AShare specs so we have to do extra house keeping.
# This slows down some file operations. This option is turned off by default.
if [ "$ILLUSTRATOR_IRISHARE_SUPPORT" != "" ] ; then
    export QUORUM_IRISHARE_SUPPORT
    QUORUM_IRISHARE_SUPPORT="$ILLUSTRATOR_IRISHARE_SUPPORT"
fi

# Set the LD_LIBRARY_PATH so that we can use the latest Motif shared libs on
# Solaris 2.3 but let user's choice and /usr/lib/dt take precedence on
# Solaris2.4 and above.
if [ "$osname" = "SunOS" ] ; then
    export LD_LIBRARY_PATH
    if [ "$osmajor" -eq 5 -a "$osminor" -le 3 ] ; then
        LD_LIBRARY_PATH="$INSTALL_DIR/Motiflib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
    else
        LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}/usr/lib/dt:$INSTALL_DIR/Motiflib"
    fi
fi

# Set the XFILESEARCHPATH so that Illustrator can find the Quorum resource file.
export XFILESEARCHPATH
if [ "$XFILESEARCHPATH" = "" ] ; then
    XFILESEARCHPATH="$INSTALL_DIR/%T/%N%S"
else
    XFILESEARCHPATH="$INSTALL_DIR/%T/%N%S:$XFILESEARCHPATH"
fi

# Set the QUORUM_SERVER_FONTS to none so that we don't spend time creating cache.
export QUORUM_SERVER_FONTS
if [ "$QUORUM_SERVER_FONTS" = "" ] ; then
    QUORUM_SERVER_FONTS='none'
fi

# Use environment variable ILLUSTRATOR_OPT_EXT to control
# which optional extensions to use for this invocation of Illustrator.

# Verify that all entries in ILLUSTRATOR_OPT_EXT are recognizable.
IFS=:
for optional in $ILLUSTRATOR_OPT_EXT ; do
    if [ "$optional" != "" ]; then
        if (echo "$OPTIONALS" | egrep ":$optional:" > /dev/null) ; then
            # Space holder statement
            ok=1
        else
            # When here, the user has specified an unrecognized optional extension.
            echo ""
            echo Warning: environment variable ILLUSTRATOR_OPT_EXT specifies $optional,
            echo which is not a recognized optional extension and will be ignored.
        fi
    fi
done
IFS=' '

# Loop through all possible optional extensions.
# Remove old links and add new ones as appropriate.
OptExtDir_Install="$INSTALL_DIR/$OptExtDir"
OptExtDir_User="$ILLUSTRATOR_ROOT/$OptExtDir"
IFS=:
for optional in `echo "$OPTIONALS" | awk -F: '{ for (i = 1; i <= NF; ++i) print $i }'`; do
    IFS=' '
    if [ "$optional" != "" ]; then
        if [ -h "$OptExtDir_User/$optional" ] ; then
            # If extension is present and is a link, remove the link
            ${RM} "$OptExtDir_User/$optional"
            ${RM} "$OptExtDir_User/%$optional"
        elif [ -f "$OptExtDir_User/$optional" ] ; then
            # If extension is present and is a file, print warning.
            echo ""
            echo "Warning: optional extension $optional exists as file:"
            if [ -f "$OptExtDir_User/$optional" ] ; then
                echo "$OptExtDir_User/$optional"
            fi
            echo "You should remove this file and specify $optional"
            echo "using environment variable ILLUSTRATOR_OPT_EXT instead."
            continue
        fi
        if (echo ":$ILLUSTRATOR_OPT_EXT:" | egrep ":$optional:" > /dev/null) ; then
            # When here, this optional extension has been requested by the user.
            # Create a symbolic link.
            ${LN} "$OptExtDir_Install/$optional" "$OptExtDir_User/$optional"
            ${LN} "$OptExtDir_Install/%$optional" "$OptExtDir_User/%$optional"
        fi
    fi
done

# Check for DPS freeze patch (101362-08) and Sparc5 hang patch (101318-68)
if [ "$osname" = SunOS -a "$osmajor" -eq 5 -a "$osminor" -le 3 ] ; then
    # Patches will end up with '<patchnum> <rev> <patchnum> <rev>...'
    patches=`/usr/bin/showrev -p | /usr/bin/awk '{ print $2; }' | /usr/bin/sed 's/-/ /g' | /usr/bin/tr '\012' ' '`
    patch_101318_68=0
    patch_101362_08=0
    patchnum=0
    for value in $patches; do
        if [ $patchnum = 0 ] ; then
        patchnum=$value
        else
        rev=$value
        if [ "$patchnum" -eq 101318 -a "$rev" -ge 68 ] ; then
            patch_101318_68=1
        fi
        if [ "$patchnum" -eq 101362 -a "$rev" -ge 08 ] ; then
            patch_101362_08=1
        fi
        patchnum=0
        fi
    done
    if [ $patch_101362_08 = 0 ] ; then
        echo ""
        echo 'Warning: patch 101362-08 (or greater) is not installed on this system'
        echo 'and is necessary for certain functions (e.g., Place EPS, Text)'
        echo 'to work properly. Illustrator may hang Without this patch.'
        echo 'Refer to Getting Started Guide and README for more details.'
	echo ""
    fi
    if [ $patch_101318_68 = 0 ] ; then
	result=`/usr/sbin/prtconf -vp | grep 'banner-name:.*SPARCstation.*5'\'`
	if [ "$result" != "" ] ; then
	    echo ""
	    echo 'Warning: patch 101318-68 (or greater) is not installed on this system.'
	    echo 'This patch fixes a chip freeze on Sparc 5. You may run into this while'
	    echo 'running Illustrator (or other applications) on a Sparc 5 machine.'
            echo 'Refer to Getting Started Guide and README for more details.'
	    echo ""
	fi
    fi
fi

# Check for bad F3 upr file
if [ "$osname" = "SunOS" -a "$osmajor" -eq 5 -a "$osminor" -le 3 ] ; then
    # Local and remote display
    if [ "$displayhost" = "" ] ; then
        cmp -s /usr/openwin/lib/X11/DPSF3Fonts.upr "$INSTALL_DIR/fixedF3upr/DPSF3Fonts.upr.bad"
        if [ "$?" = "0" ] ; then
            echo ""
            echo "Warning: the version of /usr/openwin/lib/X11/DPSF3Fonts.upr that is"
            echo "on your system has a known problem which causes applications such"
            echo "as Illustrator to hang on start-up. Please do the following:"
            echo "       <become superuser>"
            echo "       cd /usr/openwin/lib/X11"
            echo "       mv -i DPSF3Fonts.upr DPSF3Fonts.upr.orig"
            echo "       cp -p $INSTALL_DIR/fixedF3upr/DPSF3Fonts.upr.good DPSF3Fonts.upr"
            echo "Then, restart your X server. See Getting Started Guide and README"
            echo "for details."
            echo ""
        fi
    fi
fi

# SUN v7 or v8 binary and plug-in linking.
if [ "$osname" = "SunOS" ] ; then
    # Link the Illustrator/Separator execuatble for SUN with every launch
    file="$EXECNAME"
    ${RM} "$ILLUSTRATOR_ROOT/$file"
    ${LN} "$INSTALL_DIR/$file"_"$CHIPVERSION" "$ILLUSTRATOR_ROOT/$file"

    echo "Running $CHIPVERSION version of executable."
fi

# Check if user has recommended amount of swap and give warning if vswap is
# on
if [ "$osname" = "IRIX" ] ; then
    if /sbin/chkconfig vswap ; then
	echo ""
	echo "Warning: You have the virtual swap mechanism turned on. This can"
	echo "cause memory intensive applications such as Illustrator to crash"
	echo "randomly under low memory situations. We recommend that you"
	echo "turn off this feature and add more physical swap if needed."
	echo ""
	echo "For more information about risks with virtual swap, see the"
	echo "LOGICAL SWAP SPACE section in swap(1M) man pages."
	echo ""
	echo "To turn off virtual swap, first quit Illustrator and then"
	echo "do the following:"
	echo "       su root"
	echo "       /etc/chkconfig vswap off"
	echo "       /etc/reboot"
	echo ""
    fi
    # Now compute the total physical swap space allocated by user in 512 byte blocks
    swaptot=`/etc/swap -nlb | grep -v "# path" | awk '{ s += $4} END {print s}'`
    # Recommend a minimum of 80Meg (163840 blocks) swap
    if [ $swaptot -le 163839 ] ; then 
	echo ""
	echo "Warning: You do not have sufficient physical swap space. This"
	echo "can cause Illustrator to run out of memory when trying to do"
	echo "memory intensive operations. To assure that Illustrator has"
	echo "enough memory, we recommend that you have at least 80 megabytes"
	echo "of physical swap space allocated."
	echo ""
	echo "For more information on how to add physical swap space, see"
	echo "the swap(1M) man pages or refer to the System Administration"
	echo "section of the Adobe Illustrator Getting Started Guide."
	echo ""
    fi
fi

# Execute the binary for the application.
# The incantation ${1+"$@"} is black-magic to pass args correctly,
# even if some args contain embedded spaces

if [ "$USEDIRECTXLIB" = 1 -a -x "$DIRECTXLIB" ] ; then
    # Use direct XLIB for this application if it is available.
    echo $DIRECTXLIB $ILLUSTRATOR_ROOT/$EXECNAME \
	${1+"$@"}
    $DIRECTXLIB $ILLUSTRATOR_ROOT/$EXECNAME \
        -xrm "*dpsnxAgentExec: dpsnx.agent" \
        ${1+"$@"} 
else
    echo $ILLUSTRATOR_ROOT/$EXECNAME \
        ${1+"$@"} 
    $ILLUSTRATOR_ROOT/$EXECNAME \
        -xrm "*dpsnxAgentExec: dpsnx.agent" \
        ${1+"$@"} 
fi
