#!/bin/sh 
# Installation script for Sun Catalyst CDs
#
# Copyright 1997, SunSoft, Inc.
#
# Author: marc.sacoolas@sun.com 
# Date: October 10, 1997
# Last Modified 12-17-98

# initialize variables
DISC_NAME=Sun_Solutions_CD-July98
ISSUE_NAME="Sun Solutions CD"
ISSUE_DATE=""

export ISSUE_NAME ISSUE_DATE CD_MOUNT os_ver
export LD_LIBRARY_PATH CLASSPATH PATH JAVA_HOME

echo ""
echo "          $ISSUE_NAME $ISSUE_DATE initializing ..."

# set CDMOUNT to path from the command line arguements
CDMOUNT=`expr \
        $0'/' : '\(/\)[^/]*//*$' \
        \| $0'/' : '\(.*[^/]\)//*[^/][^/]*//*$' \
        \| .`

# if command line path is current directory then set CDMOUNT to pwd
# CDMOUNT cannot be set to . because other programs/scripts
# need the absolute path in CD_MOUNT
if [ "$CDMOUNT" = "." ]; then
        CDMOUNT=`pwd`
fi
# FIX THIS FOR PRODUCTION
CD_MOUNT=$CDMOUNT

#
# os type and arch
#
check_os()
{
        os_ver="`/bin/uname -r | /bin/grep 5\[.]`"


        if [ -n "$os_ver" ]; then
# must be running Solaris 2.x
                machine_type="`/bin/uname -m`"
                os_type="`/bin/uname -r`"
                if [ "$machine_type" = "i86pc" ]; then
                        OS_TYPE=""
                        CDWARE_ENV=Solaris_x86
                else
# must be on a SPARCarchitecture-based machine
                        bcp="`/bin/pkginfo | /bin/grep SUNWbcp`"
# check for bcp and set CDWARE_ENV accordingly???
                        CDWARE_ENV=Solaris_2
                fi
        else
# must be running Solaris 1.x
                GUI=products/bin/Solaris_1/cdmanager
                GUI_BIN=cdmgr
                CDWARE_ENV=Solaris_1
		test_sunos="`/bin/uname -r | /bin/grep 4.1.4`"
		if [ -n "$test_sunos" ]; then
			SUNOS_VER=4.1.4
		else
			SUNOS_VER=""
		fi

        fi

}

check_os


LD_LIBRARY_PATH=$CD_MOUNT/products/bin/gui/$CDWARE_ENV/lib:/usr/openwin/lib:/usr/lib:$LD_LIBRARY_PATH
CLASSPATH=$CD_MOUNT/products/bin/gui/code/jars/sunsol.jar:$CD_MOUNT/products/bin/java/$CDWARE_ENV/lib/rt.jar:.:$CD_MOUNT/products/bin/gui/code:$CD_MOUNT/products/bin/gui/code/jars/hjb2.jar:$CD_MOUNT/products/bin/gui/code/jars/jmf.jar:$CD_MOUNT/products/bin/gui/code/jars/swing111b2.jar:$CD_MOUNT/products/bin/gui/code/jars/js.jar
#CLASSPATH=$CD_MOUNT/products/bin/java/$CDWARE_ENV/lib/rt.jar:.:$CD_MOUNT/products/bin/gui/code:$CD_MOUNT/products/bin/gui/code/jars/hotjavabean.jar:$CD_MOUNT/products/bin/gui/code/jars/swing.jar:$CD_MOUNT/products/bin/gui/code/jars/jmf.jar

# don't run if SunOS on DevCD 12-5-97
#        if [ $CDWARE_ENV = "Solaris_1" ]; then
#                echo ""
#                echo "This CD does not run on SunOS 4.x"
#                echo ""
#                exit 0
#	fi
# 	version 116 of jre needs 2.6 or higher
	if [ "$OS_REV" = "6" -o "$OS_REV" = "7" ]; then
		JAVA_HOME=$CD_MOUNT/products/bin/java/$CDWARE_ENV
	else
		JAVA_HOME=$CD_MOUNT/products/bin/java/$CDWARE_ENV
	fi


if [ "$OPENWINHOME" = "" ]; then
	OPENWINHOME="/usr/openwin"; export OPENWINHOME	
fi
if [ "$HOME" = "" ]; then
	
        HOME="/"; export HOME
fi

# set the dir where all the companies live
PRODUCT_DIR=$CD_MOUNT/products
export PRODUCT_DIR 

# get nodename
NODENAME=`/bin/hostname`

if [ "$NODENAME" = "" ];then 
	NODENAME = "localhost"
fi
export NODENAME

if [ "$CDWARE_ENV" = "Solaris_1" ]; then
	export XNLSPATH XKEYSYMDB
	PATH=$DISC_DIR/.cgi-bin:/usr/ucb:$OPENWINHOME/bin:/usr/bin:/usr/sbin:$PATH
	XNLSPATH=$CD_MOUNT/products/bin/gui/$CDWARE_ENV/nls
	XKEYSYMDB=$CD_MOUNT/products/bin/gui/$CDWARE_ENV/XKeysymDB
else
	OS_REV=`/bin/uname -r | sed 's/[0-9]\.\([0-9]\).*/\1/'`
fi

export CDWARE_ENV OS_REV

	echo ""
	echo "Launching $ISSUE_NAME..."
	echo " "
	CWD=`pwd`
	cd $CD_MOUNT/products/bin/gui/code
	#$JAVA_HOME/bin/jre -cp .:jars/hotjavabean.jar:jars/swing.jar:jars/jmf.jar SunSolutions -u file://$CD_MOUNT/products/ $CD_MOUNT/products/
	#$JAVA_HOME/bin/jre SunSolutions -u file://$CD_MOUNT/products/ $CD_MOUNT/products/
	$JAVA_HOME/bin/jre -ms16m -mx24m FrameScript -u file://$CD_MOUNT/products/ $CD_MOUNT/products/ 2> /dev/null 
	#$JAVA_HOME/bin/jre SunSolutions -u file://$CD_MOUNT/products/ $CD_MOUNT/products/ 

