#!/bin/ksh
# File:         install-cde
# SCCS:		@(#)install-cde 1.3 95/03/14 SMI;
# Author:       Eric Nielsen,  SunSoft Inc, Mountain View, CA.
# Created:      02/01/95
# Modified by:
#                                                          
# Language:     ksh
# Package:      N/A
# Status:       SunSoft CDE distributed
#
# (c) Copyright 1995, SunSoft Inc, all rights reserved.
#
# Description:	This script installs SunSoft CDE 1.0                      
#
# ********************************************************************


# ********************************************************************
#
#	install-cde, Table of Contents
#
# ********************************************************************
#
#       Section 1.0,  Function Declaration 
#         Section 1.1,  HELP:  
#     Section 1.1.1,  License:
#         Section 1.2,  clear: 
#         Section 1.3,  CheckDisk: 
#         Section 1.4,  RunDtconfig:
#         Section 1.5,  InstallMin:
#         Section 1.6,  InstallEnd:
#         Section 1.6,  InstallDev:
#         Section 1.7,  RemoveCDE:
#         Section 1.8,  AddPkgs:
#         Section 1.9,  SetOptions:
#         Section 1.10, CreatetheLink:
#         Section 1.11, CheckRoot:
#         Section 1.12, MinPatch:
#         Section 1.13, EndPatch:
#         Section 1.14, DevPatch:
#         Section 1.15, Exit:
#         Section 1.15, LinkFunc:
#         Section 1.16, Tooltalk_min:
#         Section 1.17, Tooltalk_dev:
#         Section 1.18, LoadStrings:
#	  Section 1.19, LoadLocale:
#       Section 2.0, Main Body
#         Section 2.1,  Check to be sure user is root
#         Section 2.2,  Variable Initialization
#         Section 2.3,  Argument Processing
#         Section 2.4,  Main Menu                     
#
# ********************************************************************



# ********************************************************************
# ********************************************************************
#
#	Section 1.0,  Function Declaration 
#
# ********************************************************************
# ********************************************************************

# ********************************************************************
#
# 	Section 1.1,  HELP:  
#
#	Function HELP which gives you general usage for install-cde
#
# ********************************************************************
 
function HELP
{
    cat<<eof

        Usage:install-cde [flags]
	     []			(No flags invokes menu)
             [ -loc <dir>]     	(Install location for /usr/dt )
	     [ -link  ]		( Link to the current CDE install )
             [ -ver ]      	(Install packages in interactive mode )
	     [ -locale "<loc>"]	(Install additional locale packages, locale "FR JA SV") 
	     [ -noclean ]	(Do not remove old packages before installation)
	     [ -nospace ] 	(Do not check available disk space)
	     [ -nocheck ]       (Do not check for /usr/dt directory)
	     [ -nopatches ]	(Do not install patches)
	     [ -nologin ]	(Do not configure desktop login)
	     [ -uinstall ]      (Unintall all CDE packages)
             [ -min ]  	    	(Install minimum CDE configuration)
             [ -end ]     	(Install min and end-usr CDE configuration)
             [ -dev ]      	(Install min, end-usr and developer configuration)
	     [ -debug ]         (Sets Ksh mode to -xv for debugging/logging)
	     [ -help ]		(Displays this help message)
	     [ ? ] 		(Displays this help message)

	Example: install-cde -loc /home/ericni/cde -ver -dev -nospace -locale "FR JA"

	Note: 	Flags can be in any order

eof
exit
}

# ********************************************************************
#
#   Section 1.1.1,  License Agreement for FTP'd Version:
#
#   Function License which displays the license agreement if this
#   version of CDE is a downloaded FTP version.
#
# ********************************************************************

function License
{
	more CDE_License
	echo " "
	echo " "
	print -n  "\tDo you accept these terms [Y]\b\b"

		read response

		if [[ $response = `` ]] then response="Y";  fi

		if [[ $response = "Y" || $response = "y" ]]
		then
			echo
		else
			DONE=NO
			MENU_SELECT=NO
			EXIT_STATUS=1
			Exit
		fi
}

# ********************************************************************
#
# 	Section 1.2,  clear: 
#
#
#       Function to clear the screen 
# 	     
# ********************************************************************

CLEARSTRING=$(tput clear)
function clear {
	print -n "$CLEARSTRING"
}

 
# ********************************************************************
#
# 	Section 1.3,  CheckDisk: 
#
#
#       Function which checks the install location.... 
#
#		1. Existing Motif for Solaris 2.5
#
#		2. Root permission on installation file system
# 	    
#		3. Cleans up existing CDE packages before 
#		   checking for space.
#
#		4. Check for required disk space
#
# ********************************************************************

function CheckDisk
{

$DEBUG

#
# CheckDisk_1
#

case "X$(uname -r)" in
                X5.@([5-9]|[1-9]+([0-9]))*)
 
	if [ ! -f /usr/dt/lib/libXm.so ]
	then
		
cat <<XYZZY
$LINE
 
 Warning: Could not find the library /usr/dt/lib/libXm.so on your
	system. This library is normally installed in the /usr/dt/lib
	directory during installation of Solaris 2.5.  In order to
	run CDE you must have this library. 

	We will continue installing CDE, however, we will not configure
	the Solaris desktop login to start at system boot. You must 
	do the following steps before running CDE.

		1. Load the SUNWmfrun package from your Solaris 2.5
		   installation cdrom. 
		
		2. If you want the Solaris desktop login to start
		   at boot, you should run the following command 
		   after you have installed SUNWmfrun:

			/usr/dt/bin/dtconfig -e 

 
 
                Press <Enter> to continue...
$LINE
XYZZY
 
                        read

                        echo "Error: $DATE: Could not find /usr/dt/lib/libXm.so on a Solaris 2.5 machine." >> $ADMIN_LOG

			DTLOGIN="NO"	

                fi

	;;

esac

#
# CheckDisk_2
#

	if [ ! -d ${SDTHOME}/bin ]
	then
		mkdir -p ${SDTHOME}/bin
		if [ $? -ne 0 ]
then
clear
cat <<XYZZY
$LINE
 
 Error: Could not create $SDTHOME directory. Please verify that
        you have root permission on the file system located
	at $SDTHOME

 Hint:  You most likely have an existing /usr/dt link which points to
	a remote server. If you don't have root permission on
	this server, you need to manually remove the this link 
	before running install-cde again.
	  
 
                Press <Enter> to exit..
$LINE
XYZZY
 
			read
			echo "Error: $DATE: The mkdir -p on  $SDTHOME command returned a none zero exit, the directory creation failed" >> $ADMIN_LOG
			Exit
		fi

		CDE_CHECK="NO"

	fi


#
# CheckDisk: 	3. Cleans up existing CDE packages before 
#		   checking for space.
#

if [ $VERT != "YES" ]; then
	echo "CDE packages will now be automatically installed..."
	echo "The average install time on a Sparc 2 is 30 minutes..."
fi

	if [ $CLEAN == "YES" ] 
	then 
		echo "Cleaning up any existing CDE packages..."

			pkg_del_list="${MIN_RM_PKGS} ${END_RM_PKGS} ${DEV_RM_PKGS} ${LOC_RM_PKGS}" 

			REMOVE_TT_ONLY="YES"
			Tooltalk_min
			Tooltalk_dev
			REMOVE_TT_ONLY="NO"

		for pkg in $pkg_del_list
       		do
               		/bin/pkginfo -q ${pkg}.*
               		FOUNDPKG=$?
               		if [ $FOUNDPKG -eq 0 ]; then
                       		if [ $VERT == "YES" ]; then
                               		/usr/sbin/pkgrm $VERBOSE ${pkg}.* 2>&1 | tee -a $PKG_RM_LOG
                       		else
                               		/usr/sbin/pkgrm $VERBOSE ${pkg}.* 2>&1 | tee -a $PKG_RM_LOG | grep $pkg
                       		fi
               		fi
 
       		done
		CLEAN=NO
	fi	

#
#	Calculate size of packages, for speed, we hard code these
#	sizes into the script.
#


	if [ ! -d ${SDTHOME}/bin ]
	then
		mkdir -p ${SDTHOME}/bin
        fi

        if [ $MIN_INSTALL = "YES" ]
        then
		SIZE=`expr 15400 +  $MIN_LOC_SIZE`
        fi

        if [ $END_INSTALL = "YES" ]
        then
		SIZE=`expr 28400 +  $END_LOC_SIZE`
        fi

        if [ $DEV_INSTALL = "YES" ]
        then
		SIZE=`expr 52400 +  $DEV_LOC_SIZE`
        fi

	if [ "$ANSWER" == "YES" ]
	then
		SIZE=`expr $SIZE + $ANSWER_SIZE`
	fi


#
# CheckDisk	4. Check for required disk space
#

	  diskfree=`df -k ${SDTHOME}/bin | awk '{print $4}' | sed '/avail/d'`
          if [ $diskfree -lt $SIZE ]
          then

        	DONE=NO
        	MENU_SELECT=NO
        	clear
 
        	cat <<XYZZY
$LINE
 
 Error: $SDTHOME has only `expr $diskfree / 1000` Megabytes of space left,
        you need `expr $SIZE / 1000` Megabytes for this cde cluster
 
        Choose an alternate install location for /usr/dt, or free up
	`expr $SIZE / 1000`  Megabytes in $SDTHOME.
 
 
                Press <Enter> to Exit...
$LINE
XYZZY
 
        	read
        	echo "Error: $DATE: Not enough space in file system to install cde. " >> $ADMIN_LOG

		EXIT_STATUS=1
		Exit

	else
		DONE=YES
		MENU_SELECT=YES
	fi


}	

# ********************************************************************
#
# 	Section 1.4,  RunDtconfig:
#
#       Function which configures login                
#
#		1. Run /usr/dt/bin/dtconfig -e to enable login 
#
# ********************************************************************

function RunDtconfig
{

	DONE=YES
        MENU_SELECT=YES

#
# RunDtconfig	1. Run /usr/dt/bin/dtconfig -e to enable login
#

	if [ -f /usr/dt/bin/dtconfig ]
	then
               if [ $VERT == "YES" ]; then

				/usr/dt/bin/dtconfig -e 
				DTCONFIG_RESULT=$?
                       else
				/usr/dt/bin/dtconfig -e 2>&1 > /dev/null
				DTCONFIG_RESULT=$?
                       fi
		if [ $DTCONFIG_RESULT -ne 0 ]
		then
			clear
			cat <<XYZZY
$LINE
 
 Error: Could not run /usr/dt/bin/dtconfig successfully. The install-cde
        was unable to setup the Solaris desktop login.
 
                Press <Enter> to exit..
$LINE
XYZZY
 
			read
			echo "Error: $DATE: The install-cde script could not run dtconfig -e correctly" >> $ADMIN_LOG
			EXIT_STATUS=1
			Exit
		fi

	fi
}


# ********************************************************************
#
# 	Section 1.5,  InstallMin:
#
#       Function which installs minimum CDE packages.... 
#
#		1. Check for existing CDE and warn user
#
#		3. Install minimium packages	
#
# ********************************************************************

function  InstallMin
{
$DEBUG
	DONE=YES
        MENU_SELECT=YES

#
# InstallMin	1. Check for existing CDE and warn user
#	

if [ $CDE_CHECK == "YES" ]
then
	if [ -f /usr/dt/bin/dtlogin ]
	then
 
		cat <<XYZZY
$LINE
 
 Warning: This install program has detected a CDE dtlogin binary, located 
	  at "/usr/dt/bin/dtlogin". If you choose to continue you will destroy
	  any current version of CDE that might be present. 

$LINE

XYZZY
		print -n "\tDo you wish to continue [Y]"

		read response

		if [[ $response = `` ]] then response="Y";  fi

		if [[ $response = "Y" || $response = "y" ]] 
		then
			echo
		else
			DONE=NO
			MENU_SELECT=NO
			EXIT_STATUS=1
			Exit
		fi
 
	fi

fi


touch /usr/dt/tmp.install.file.$$
if [ `ls -l /usr/dt/tmp.install.file.$$ | grep root | wc -l` -eq 0 ]
then
        rm /usr/dt/tmp.install.file.$$
        clear
        cat <<XYZZY
$LINE

 Error: This machine does not appear to have root permission for
        the file system located at: $SDTHOME
 
 
 Hint:  You most likely have an existing /usr/dt link which points to
        a remote server. If you don't have root permission on
        this server, you need to manually remove the this link
        before running install-cde again.
 
 
                Press <Enter> to exit..
$LINE
XYZZY
 
        read
        echo "Error: $DATE: Can not create root permission files in $SDTHOME" >> $ADMIN_LOG
        EXIT_STATUS=1
        Exit
fi


if [ -d cde-min ]
then
 	cd cde-min


	pkglist="${LOC_COPYRIGHT_PKGS} ${MIN_PKGS} ${JA_MIN_PKGS} ${KO_MIN_PKGS} ${ES_MIN_PKGS} ${ZH_MIN_PKGS} ${SV_MIN_PKGS} ${IT_MIN_PKGS} ${DE_MIN_PKGS} ${ZH_TW_MIN_PKGS} ${FR_MIN_PKGS}"
	COPYRIGHT_FIRST_TIME="YES"

#
# InstallMin	3. Install minimium packages	
#

	AddPkgs
	Tooltalk_min
	cd $TOP
	INSTALL_GOOD="YES"

else
	DONE=NO
	MENU_SELECT=NO
	clear
 
	cat <<XYZZY
$LINE
 
 Error: Can't find the cde-min package directory located on 
	the CDE cdrom. Be sure you execute this script
	in the top directory of your CDE cdrom, where the
	directories: cde-min, cde-end-user, cde-developer and
	patches should be available.
 
        Exit this install script and restart it from the correct
        location.
 
 
                Press <Enter> to exit..
$LINE
XYZZY

	read
	echo "Error: $DATE: Can not find the cde-min directory, to load min packages" >> $ADMIN_LOG 
	EXIT_STATUS=1
	Exit
fi

} 

# ********************************************************************
#
# 	Section 1.6,  InstallEnd:
#
#
#       Function which installs end CDE packages.... 
#
#		1. Install end user packages	
#
# ********************************************************************


function InstallEnd
{
$DEBUG

#
# InstallEnd	1. Install end user packages
#

if [ -d cde-end-user ]
then
	pkglist=" ${END_PKGS} ${JA_END_PKGS} ${KO_END_PKGS} ${ES_END_PKGS} ${ZH_END_PKGS} ${SV_END_PKGS} ${IT_END_PKGS} ${DE_END_PKGS} ${ZH_TW_END_PKGS} ${FR_END_PKGS}"


        cd cde-end-user
	AddPkgs 
        cd $TOP

else
	DONE=NO
	MENU_SELECT=NO
	clear
 
cat <<XYZZY
$LINE
 
 Error: Can't find the cde-end-user package directory located on
        the CDE cdrom. Be sure you execute this script
        in the top directory of your CDE cdrom, where the
        directories: cde-min, cde-end-user, cde-developer and
        patches should be available.
 
        Exit this install script and restart it from the correct
        location.
 
 
                Press <Enter> to exit..
$LINE
XYZZY
 
	read
	echo "Error: $DATE: Can not find the cde-end-user directory, to load end-usr packages" >> $ADMIN_LOG
	EXIT_STATUS=1
	Exit
fi
 
 
}

# ********************************************************************
#
# 	Section 1.6,  InstallDev:
#
#       Function which installs Developer CDE packages.... 
#
#		1. Add SUNWmfman and SUNWmfdm if not found
#
#		2. Install developer packages 
# 
# ********************************************************************

function InstallDev
{
$DEBUG
if [ -d cde-developer ]
then

#
# InstallDev	1. Add SUNWmfman and SUNWmfdm if not found
#

# If we are in 2.5, replace the SUNWmfman & SUNWmfdm if we have previously 
# removed it in the create link function

	SUNWmfman=
	SUNWmfdm=

        case "X$(uname -r)" in
                X5.@([5-9]|[1-9]+([0-9]))*)

                	if [ ! -f /usr/dt/share/man/man3/XmActivateProtocol.3x  ]; then  
 
                        	SUNWmfman=SUNWmfman

			fi

                	if [ ! -f /usr/dt/share/examples/motif/dogs/Dog.c  ]; then  
  
                        	SUNWmfdm=SUNWmfdm 
 
			fi
		;;
	esac

#
# InstallDev		2. Install developer packages 
#

	pkglist="${DEV_PKGS} ${SUNWmfman} ${SUNWmfdm} ${JA_DEV_PKGS} ${KO_DEV_PKGS} ${ES_DEV_PKGS} ${ZH_DEV_PKGS} ${SV_DEV_PKGS} ${IT_DEV_PKGS} ${DE_DEV_PKGS} ${ZH_TW_DEV_PKGS} ${FR_DEV_PKGS}"
        cd cde-developer
	AddPkgs 
	Tooltalk_dev
        cd $TOP
 
else
	DONE=NO
	MENU_SELECT=NO
	clear
	cat <<XYZZY
$LINE
 
 Error: Can't find the cde-developer package directory located on
        the CDE cdrom. Be sure you execute this script
        in the top directory of your CDE cdrom, where the
        directories: cde-min, cde-end-user, cde-developer and
        patches should be available.
 
        Exit this install script and restart it from the correct
        location.
 
 
                Press <Enter> to exit..
$LINE
XYZZY
 
	read
	echo "Error: $DATE: Can not find the cde-developer directory, to load end-usr packages" >> $ADMIN_LOG
	EXIT_STATUS=1
	Exit
fi
 

}

# ********************************************************************
#
#
# 	Section 1.7,  RemoveCDE:
#
#       Function which removes all the CDE packages....
#
#		1. Disables Autostart 
#
#		2. Removes packages 
#
# ********************************************************************
 

function RemoveCDE
{
$DEBUG
REMOVE_TT_ONLY="YES"
clear
cat <<XYZZY
$LINE
 
 Warning: This remove program will remove all the CDE packages from 
	  your system.  
 
$LINE
 
XYZZY
print -n "\tDo you wish to continue [Y]"
 
read response
 
if [[ $response = `` ]] then response="Y";  fi
 
if [[ $response = "Y" || $response = "y" ]] then
	echo
else
         Exit
fi
 

NEW_LOCALE="JA KO ES ZH SV IT DE ZH_TW FR"
LoadLocale

pkglist="${MIN_RM_PKGS} ${END_RM_PKGS} ${DEV_RM_PKGS} ${LOC_RM_PKGS}"
clear

#
# RemoveCDE	1. Disables Autostart
#

if [ -f /usr/dt/bin/dtconfig ]
then
	/usr/dt/bin/dtconfig -d 2>&1 > /dev/null
fi

echo "Starting to Remove Packages..."

#
# RemoveCDE 	2. Removes packages
#

Tooltalk_min
Tooltalk_dev

for pkg in $pkglist
        do
                /bin/pkginfo -q ${pkg}.*
                FOUNDPKG=$?
                if [ $FOUNDPKG -eq 0 ]; then
                       if [ $VERT == "YES" ]; then
                               /usr/sbin/pkgrm $VERBOSE ${pkg}.* 2>&1 | tee -a $PKG_RM_LOG
                       else
                               /usr/sbin/pkgrm $VERBOSE ${pkg}.* 2>&1 | tee -a $PKG_RM_LOG | grep $pkg
                       fi
                fi

	done
Exit
}

# ********************************************************************
#
# 	Section 1.8,  AddPkgs:
#
#       Function which adds packages
#
#		1. Add Packages 
#
# ********************************************************************

function AddPkgs
{
$DEBUG	

	if [ $COPYRIGHT_FIRST_TIME == "YES" ]; then
		echo "Starting Install ....."
	fi


#
# AddPkgs	1. Add Packages
#


        for pkg in $pkglist
        do
                if [ $COPYRIGHT_FIRST_TIME == "YES" ]; then
                        /usr/sbin/pkgadd $VERBOSE -d `pwd` $pkg 2>&1 | tee -a $PKG_LOG
                        if [ $? -ne 0 ] ; then
                                echo $ERROR_LINE
                                echo $ERROR_LINE >> $ADMIN_LOG
                        fi
                        COPYRIGHT_FIRST_TIME="NO"
 
                else if [ "$COPYRIGHT_FIRST_TIME" == "NO" ] ; then
                        if [ $VERT == "YES" ] ; then
                                /usr/sbin/pkgadd $VERBOSE -d `pwd` $pkg 2>&1 | tee -a $PKG_LOG
                        else
                                /usr/sbin/pkgadd $VERBOSE -d `pwd` $pkg 2>&1 | tee -a $PKG_LOG | grep $pkg
                        fi
                     fi
                fi
	done

}


# ********************************************************************
#
# 	Section 1.9,  SetOptions:
#
#       Function which sets install options
#
#		1. Allows user to set any of the install
#		   options before installation begins. User
#		   can set:
#
#			- CDE install location
#			- End User Cluster install
#			- Developer Cluster install
#			- Answerbook package installatino
#			- Remove old CDE packages
#			- Install Verbose or Quite
#			- Enable/Disable Dtlogin Startup
#			- Reset all install options to defaults
#
# ********************************************************************


function SetOptions
{
while [ $CONFIG_MENU_SELECT == "YES" ]
do

cat <<XYZZY
                Solaris Common Desktop Environment
                          Installation Script
                          Configuration Menu
$LINE
 
        $CURRENT CONFIGURATION SETTINGS
 
	1.${MENU_VAR[1]}		[ $SDTHOME ]
	2.${MENU_VAR[2]}	[ $END_INSTALL 	]
	3.${MENU_VAR[3]}	[ $DEV_INSTALL 	]
	4.${MENU_VAR[4]}	[ $ANSWER	]   
	5.${MENU_VAR[6]}	[ $VERT	]   
	6.${MENU_VAR[7]}		[ $DTLOGIN	]   
	7.${MENU_VAR[8]}		[ $LOCALE	]   
	8. 	Reset to Defaults

	0. 	Return to Main Menu
 
$LINE
 
XYZZY

print -n "\tSELECT A NUMBER [0] "
read response
 
CONFIG_MENU_SELECT=YES
 
if [[ $response = `` ]] then response="0";  fi
 
 

case $response in

 
        "1" )
	print  " "
	print  "	Choose an alternate install location for CDE. An alternate "
	print  "	install location can be located anywhere on the network as long as "
	print  "	your workstation has root access to that files system. "
	print  " "
	print    "                                        [ Current ]	[ New ]"
	print  " "
	print -n "              Install Location:         [ $SDTHOME ]	[ ]\b\b"
	read NEW_SDTHOME
	if [ "${NEW_SDTHOME}" == "" ]
	then
        	NEW_SDTHOME=${SDTHOME}
	fi
	firstchar=`echo $NEW_SDTHOME | cut -c1`
	if [ "$firstchar" != "/" ]
	then
		CONFIG_MENU_SELECT="YES"	
                echo ""
                echo ""
                echo "\tError: \t $NEW_SDTHOME is not an absolute path, please try again "
                echo ""
                echo ""
                echo "\t\tPress <Enter> to continue...."
                read
	else
		SDTHOME=$NEW_SDTHOME
	fi
        ;;

	"2" )
        print  " "
        print  "        The install-cde script will install the End User CDE packages that "
        print  "        support the CDE desktop. If you select NO, only the minimum CDE "
	print	"	packages that support CDE Motif applications will be installed."
        print  " "
        print    "                                     	[ Current ]	[ New ]"
        print  " "
        print -n "            End User CDE Packages:  	[ $END_INSTALL ]		[ ]\b\b"
        read NEW_END_INSTALL
 
        case $NEW_END_INSTALL in
 
                "YES" | "yes" | "y" | "Y" ) 
			END_INSTALL=YES 
		;;
                "NO" | "no" | "n" | "N" ) END_INSTALL=NO 
					  DEV_INSTALL=NO ;;

                 "" ) 
		;;



                *)
                        CONFIG_MENU_SELECT="YES"
                        print ""
                        print ""
                        print "\tError: \t You must answer YES, yes, Y, y or NO, no, N, n "
                        print ""
                        print ""
                        print "\t\tPress <Enter> to continue...."
                        read
                ;;
                esac
        ;;


	"3" )
        print  " "
        print  "        The install-cde script will install the developer CDE packages that "
        print  "        support application development for the  CDE desktop. This "
        print  "        includes manual pages, CDE headers, help volumes, and demos. The "
	print  "	install-cde script will also install the end user packages if you " 
	print  "	choose developer packages. "
        print  " "
        print    "                                     	[ Current ]	[ New ]"
        print  " "
        print -n "            Developer CDE Packages:  	[ $DEV_INSTALL ]		[ ]\b\b"
        read NEW_DEV_INSTALL
 
        case $NEW_DEV_INSTALL in
 
                "YES" | "yes" | "y" | "Y" ) 
			END_INSTALL=YES 
			DEV_INSTALL=YES 
		;;
                "NO" | "no" | "n" | "N" ) DEV_INSTALL=NO ;;
                 "" ) 
		;;
                *)
                        CONFIG_MENU_SELECT="YES"
                        print ""
                        print ""
                        print "\tError: \t You must answer YES, yes, Y, y, or NO, no, N, n "
                        print ""
                        print ""
                        print "\t\tPress <Enter> to continue...."
                        read
                ;;
        esac
	;;

	"4" )
        print  " "
        print  "        The install-cde script will install the CDE answerbook package. The "
        print  "        CDE answerbook package contains user, programmer, and other manuals."
        print  " " 
        print    "                                     	[ Current ]	[ New ]"
        print  " "
        print -n "            Answerbook CDE Package:  	[ $ANSWER ]		[ ]\b\b"
        read NEW_ANSWER
 
        case $NEW_ANSWER in
 
                "YES" | "yes" | "y" | "Y" ) ANSWER=YES ;;
                "NO" | "no" | "n" | "N" ) ANSWER=NO ;;
                 "" ) 
		;;
                *)
                        CONFIG_MENU_SELECT="YES"
                        print ""
                        print ""
                        print "\tError: \t You must answer YES, yes, Y, y or NO, no, N, n  "
                        print ""
                        print ""
                        print "\t\tPress <Enter> to continue...."
                        read
                ;;
                esac
	;;

	"5" ) 
	print  " "
        print  "        The interactive installation allows you to view errors that  "
        print  "        might occur during installation. It also allows you to verify those "
        print  "        packages that will install applications with suid permissions."
        print  " "
	print    "					[ Current ]	[ New ]"
        print  " "
	print -n "            Interactive Installation	[ $VERT ]		[ ]\b\b"
	read NEW_VERT

	case $NEW_VERT in

        	"YES" | "yes" | "y" | "Y" ) VERT=YES 
					    VERBOSE="" 
		;;

        	"NO" | "no" | "N" | "n" ) VERT=NO ;;
                 "" ) 
		;;
		*)
			CONFIG_MENU_SELECT="YES"	
       	 		print ""
        		print ""
        		print "\tError: \t You must answer YES, yes, Y, y, or NO, no, N, n "
        		print ""
        		print ""
        		print "\t\tPress <Enter> to continue...."
        		read
		;;	
		esac

        ;;

	"6" ) 
	print  " "
        print  "        By default the Solaris CDE login window appears at system boot. If "
        print  "        you do not want it to appear at system boot type NO."
        print  " "
        print  " "
	print    "					[ Current ]	[ New ]"
        print  " "
	print -n "            Solaris Desktop Login	[ $DTLOGIN ]		[ ]\b\b"
	read NEW_DTLOGIN

	case $NEW_DTLOGIN in

        	"YES" | "yes" | "y" | "Y" ) DTLOGIN=YES ;;
        	"NO" | "no" | "N" | "n" ) DTLOGIN=NO ;;
                 "" ) 

		;;

		*)
			CONFIG_MENU_SELECT="YES"	
       	 		print ""
        		print ""
        		print "\tError: \t You must answer YES, yes, Y, y, or NO, no, N, n "
        		print ""
        		print ""
        		print "\t\tPress <Enter> to continue...."
        		read
		;;	
	esac
	;;
 
	"7" ) 
	print  " "
        print  "        CDE supports multiple locales. The default locale is English. You can"
        print  "        install different locales by selecting one or more of the following: "
        print  "          JA - Japanese: 8MB,  FR - French: 720KB, EN - US English 0KB "
        print  "          KO - Korean: 1MB, ZH - Chinese: 1MB (simplified), DE - German: 730KB" 
	print  "	  ZH_TW - Taiwan Chinese: 600KB (Traditional), SV - Swedish: 200KB " 
	print  "	  IT - Italian: 720KB, ES - Spanish: 700KB"
	print  " 	Example: Installation Locale(s)	[  EN ]		[ JA FR SV  "
	print  " "
	print    "					[ Current ]	[ New ]"
        print  " "
	print -n "            Installation Locale(s)  	[ $LOCALE ]		[ ]\b\b"
	read NEW_LOCALE

	LoadLocale

	;;
 
	"8" )
	CURRENT="DEFAULT"
	current="Default"
	SDTHOME="/usr/dt"	
	END_INSTALL="YES"	
	DEV_INSTALL="NO"
	ANSWER="NO"
	CLEAN="YES"
	VERT="NO"
	DTLOGIN="YES"
	LOCALE="EN"
        LOC_COPYRIGHT_PKGS=""
	ANSWER_PACKAGES="SUNWdta"
    	MIN_LOC_SIZE=0
    	END_LOC_SIZE=0
    	DEV_LOC_SIZE=0
	;;

        "0" )
        CONFIG_MENU_SELECT=NO
        ;;
 
        *)
        print ""
        print ""
        print "\t\tI don't recognize..\"$response\" Sorry.. "
        sleep 1
        ;;
 
esac

clear

done

CONFIG_MENU_SELECT=YES

if [ "$ANSWER" == "YES" ]
then
	SUNWdta=${ANSWER_PACKAGES}
 fi

}

# ********************************************************************
#
# 	Section 1.10,  CreatetheLink:
#
# ********************************************************************
#       Function which creates the new install location link
#
#	       Warning, this is a messy function that needs cleaned up.
#
#		1.	Cleans up /usr/dt area for Solaris 2.5 so
#			a link can be made.
#		
#		2. 	Warns that there is still files in the /usr/dt
#			area and allows you to move them.
#
#		3. 	Creates the link to the new install location
#
# ********************************************************************
 
 
function CreateTheLink 
{
$DEBUG 
clear

#
# CreatetheLink		1. Cleans up /usr/dt area for Solaris 2.5 so
#			   a link can be made.
#

if [ -d /usr/dt ]
then

        case "X$(uname -r)" in
                X5.@([5-9]|[1-9]+([0-9]))*)
		    if [ -d /usr/dt ]
       			then

			echo "moving <SUNWmfrun> to ${SDTHOME} ..."
			cd /usr/dt
			find . -depth -print | cpio -pmd $SDTHOME	
			cd $TOP
			/bin/rm -rf /usr/dt
       		fi
		;;


	esac

	if [ -d /usr/dt ]
	then

		echo "Attempting to clean up an existing /usr/dt directory ..."
		find /usr/dt -depth -exec /bin/rmdir {}  2>&1 > /dev/null \; 2>&1 > /dev/null
	fi

fi

/usr/bin/rm /usr/dt 2>&1 > /dev/null

#
# CreatetheLink      2. Warns that there is still files in the /usr/dt
#                       area and allows you to move them.



if [ -d /usr/dt ]
then


	clear

	cat <<XYZZY
$LINE

Warning:  A "/usr/dt" directory still exists on this machine, this 
	   prohibits a needed link from being setup from 

	   	/usr/dt to $SDTHOME  

	   This installation can move the current /usr/dt to 

	  	 /usr/dt.pre.CDE.${DATE} 

	   and proceed with the installation.


	   Do you want to move your current /usr/dt  


$LINE


XYZZY

               print -n "\tMove existing /usr/dt directory [Y]"

		read response

		if [[ $response = `` ]] then response="Y";  fi

		if [[ $response = "Y" || $response = "y" ]] 
		then
			mv /usr/dt /usr/dt.pre.CDE.${DATE}
			mkdir -p  ${SDTHOME}
			if [ $? -ne 0 ]
			then
			clear
cat <<XYZZY
$LINE
 

Error: Could not create $SDTHOME directory. Please verify that
you have root permission on the file system located
at $SDTHOME
 
Hint:  You most likely have an existing /usr/dt link which points to
a remote server. If you don't have root permission on
this server, you need to manually remove the this link
before running install-cde again.
 
 
Press <Enter> to exit..

$LINE
XYZZY
EXIT_STATUS=1
Exit

			fi

#
# CreatetheLink		3. Creates the link to the new install location for Solaris 2.5
#



			ln -s ..${SDTHOME} /usr/dt
			if [ $? -ne 0 ]
			then 
			clear
			cat <<XYZZY
			$LINE
			 
			Error:  Could not create alternate link from /usr/dt to $SDTHOME , 
       			please verify you have root permission on the file systems
				in question.
			 
			 Hint:  You most likely have an existing /usr/dt link which points to
      				a remote server. If you don't have root permission on
       			this server, you need to manually remove the this link
       			before running install-cde again.

		 
               			Press <Enter> to exit..
			$LINE
XYZZY

			 
			read
			echo "Error: $DATE: The ln -s $SDTHOME command returned a none zero exit, the link failed" >> $ADMIN_LOG
			EXIT_STATUS=1
			Exit
			fi

		else
			DONE=NO
			MENU_SELECT=NO
			EXIT_STATUS=1
			Exit
		fi
 
 
fi

if [ -f /usr/dt ]
then
 
 
       clear

       cat <<XYZZY
$LINE

Warning:  A "/usr/dt" file still exists on this machine, this
           prohibits a needed link from being setup from
 
                /usr/dt to $SDTHOME
 
          This installation can move the current /usr/dt to

                 /usr/dt.pre.CDE.${DATE}
 
           and proceed with the installation.
 
           Do you want to move your current /usr/dt 
 
 
$LINE
 

XYZZY
 
                print -n "\tMove existing /usr/dt file [Y]"
 
                read response
 
                if [[ $response = `` ]] then response="Y";  fi
 
                if [[ $response = "Y" || $response = "y" ]]
                then
			mv /usr/dt /usr/dt.pre.CDE.${DATE}
                        mkdir -p  ${SDTHOME}
			if [ $? -ne 0 ]
                        then
                        clear
cat <<XYZZY
$LINE
 
 Error: Could not create $SDTHOME directory. Please verify you have
        you have root permission on the file systems in question.
 

 Hint:  You most likely have an existing /usr/dt link which points to
        a remote server. If you don't have root permission on
        this server, you need to manually remove the this link
        before running install-cde again.
 
 
                Press <Enter> to exit..
$LINE
XYZZY
                        EXIT_STATUS=1
                        Exit
                        fi
#
# CreatetheLink		3. Creates the link to the new install location for Solaris 2.4
#			   after moving old CDE
#

                        ln -s ..${SDTHOME} /usr/dt
                        if [ $? -ne 0 ]
                        then
                        clear
                        cat <<XYZZY
                        $LINE
 
                        Error: Could not create alternate link from /usr/dt to $SDTHOME ,
                                please verify you have root permission on the file systems
                                in question.
 
			Hint:   You most likely have an existing /usr/dt link which points to
        			a remote server. If you don't have root permission on
        			this server, you need to manually remove the this link
        			before running install-cde again.
 
 
                                        Press <Enter> to exit..
                        $LINE
XYZZY
 
 
                        read
                        echo "Error: $DATE: The ln -s $SDTHOME command returned a none zero exit, the link failed" >> $ADMIN_LOG
			EXIT_STATUS=1
                        Exit
                        fi
 
                else
                        DONE=NO
                        MENU_SELECT=NO
                        EXIT_STATUS=1
                        Exit
                fi
 
 
fi

#
# CreatetheLink		3. Creates the link to the new install location 
#

mkdir -p  ${SDTHOME}
ln -s ..${SDTHOME} /usr/dt
if [ $? -ne 0 ]
then 
clear
cat <<XYZZY
$LINE
 
 Error: Could not create alternate link from /usr/dt to $SDTHOME , 
        please verify you have root permission on the file systems
	in question.
 


 Hint:  You most likely have an existing /usr/dt link which points to
        a remote server. If you don't have root permission on
        this server, you need to manually remove the this link
        before running install-cde again.
 
 
                Press <Enter> to exit..
$LINE
XYZZY
 
read
echo "Error: $DATE: The ln -s $SDTHOME command returned a none zero exit, the link failed" >> $ADMIN_LOG
Exit
fi

touch /usr/dt/tmp.install.file.$$
if [ `ls -l /usr/dt/tmp.install.file.$$ | grep root | wc -l` -eq 0 ]
then
	rm /usr/dt/tmp.install.file.$$
	rm /usr/dt
	clear
	cat <<XYZZY
$LINE
 
 Error: This machine does not appear to have root permission for
	the file system located at: $SDTHOME
 
 Hint:  You most likely have an existing /usr/dt link which points to
       	a remote server. If you don't have root permission on
        this server, you need to manually remove the this link
        before running install-cde again.
 
	 
                Press <Enter> to exit..
$LINE
XYZZY
 
	read
	echo "Error: $DATE: The ln -s $SDTHOME command returned a none zero exit, the link failed" >> $ADMIN_LOG
	EXIT_STATUS=1
	Exit
fi

rm /usr/dt/tmp.install.file.$$
MENU_SELECT=NO




}
 
# ********************************************************************
#
# 	Section 1.11,  CheckRoot:
#
# ********************************************************************
#
#	CheckRoot:	Checks Root permission in /usr/dt file system
#	
#			  o  Right now this functin is never called
#
# ********************************************************************


function CheckRoot

{

touch /usr/dt/tmp.install.file.$$
if [ `ls -l /usr/dt/tmp.install.file.$$ | grep root | wc -l` -eq 0 ]
then
        rm /usr/dt/tmp.install.file.$$
        clear
        cat <<XYZZY
$LINE
 
 Error: This machine does not appear to have root permission for
        the file system located at: $SDTHOME
 
 Hint:  You most likely have an existing /usr/dt link which points to
        a remote server. If you don't have root permission on
        this server, you need to manually remove the this link
        before running install-cde again.
 
	 
 
                Press <Enter> to exit..
$LINE
XYZZY
 
        read
        echo "Error: $DATE: Can not create root permission files in $SDTHOME" >> $ADMIN_LOG
        EXIT_STATUS=1
        Exit
fi
 
rm /usr/dt/tmp.install.file.$$
MENU_SELECT=NO

}


# ********************************************************************
#
# 	Section 1.12,  MinPatch:
#
# ********************************************************************
#
#	Function which installs Min Cluster Patches     
#
# ********************************************************************

function MinPatch
{

case "X$(uname -r)" in
                X5.4)

			MIN_PATCHES_sparc=""
			MIN_PATCHES_x86=""
			MIN_PATCHES_ppc=""

			PATCHES=MIN_PATCHES_${PLATFORM}

                ;;
                *)
                ;;
esac


}


# ********************************************************************
#
# 	Section 1.13,  EndPatch:
#
# ********************************************************************
#
#	Function which installs End Cluster Patches     
#
# ********************************************************************

function EndPatch
{


        case "X$(uname -r)" in
                X5.4)
                END_PATCHES_sparc="${LOC_PATCHES_sparc} 102450-02 101925-02"
                END_PATCHES_x86="${LOC_PATCHES_x86} 102350-01 101926-03"
                END_PATCHES_ppc=""
                ;;
                X5.@([5-9]|[1-9]+([0-9]))*)
                END_PATCHES_sparc="${LOC_PATCHES_sparc}"
                END_PATCHES_x86="${LOC_PATCHES_x86}"
                END_PATCHES_ppc="${LOC_PATCHES_ppc}"
                ;;
                *)
                ;;
        esac
 
        if [ $PLATFORM == "sparc" ]
        then
                PATCHES=$END_PATCHES_sparc
        elif [ $PLATFORM == "x86" ]
        then
                PATCHES=$END_PATCHES_x86
        else
                PATCHES=$END_PATCHES_ppc
        fi
 


		cd $TOP
		 

		for i in $PATCHES
		do
		 
			if [ -d Patches/${PLATFORM}/${i} ]
			then

				if [ `showrev -p | /usr/bin/cut -d" " -f1,2 | grep $i | wc -l` -eq 0 ]
				then  
					Patches/${PLATFORM}/${i}/installpatch `pwd`/Patches/${PLATFORM}/${i} 2>&1 >> $PKG_LOG
					if [ $? -ne 0 ] ; then
                                	     echo "FAILED TO INSTALL PATCH ${i}, "
					     echo "check $PKG_LOG for details"
                                	     echo "FAILED TO INSTALL PATCH ${i} " >> $ADMIN_LOG
                        		else	
					     echo "INSTALLED PATCH ${i} "
					fi
				fi
			else
                        	echo "Warning: FAILED TO INSTALL PATCH ${i}, could not find ${i} patch directory "
                                echo "Warning: FAILED TO INSTALL PATCH ${i}, could not find ${i} patch directory " >> $ADMIN_LOG

			fi
		done 

}

# ********************************************************************
#
# 	Section 1.14,  DevPatch:
#
# ********************************************************************
#
#	Function which installs Developer Cluster Patches     
#
# ********************************************************************

function DevPatch
{
case "X$(uname -r)" in
                X5.4)
 
                        DEV_PATCHES_sparc=""
                        DEV_PATCHES_x86=""
			DEV_PATCHES_ppc=""
 
                        PATCHES=DEV_PATCHES_${PLATFORM}

                ;;
                *)
                ;;
esac

}

# ********************************************************************
#
# 	Section 1.15,  Exit:
#
# ********************************************************************
#
#	Function which exits install-cde     
#
# ********************************************************************

function Exit
{

	cat <<XYZZY

$LINE


XYZZY

if [ -f $ADMIN_LOG ]
then

        cat <<XYZZY

 
Note:   A install-cde log which has error messages
        from the install-cde script can be found at:

             install-cde log: $ADMIN_LOG
XYZZY
fi
if [ -f  $PKG_LOG ]
then

	cat <<XYZZY

 
Note:	A pkgadd log which contains a complete log of all the output
	from the "pkgadd" utility can be found at:

             pkgadd log: $PKG_LOG
XYZZY
fi
if [ -f $PKG_RM_LOG ]
then

	cat <<XYZZY


Note:	A pkgrm log which contains a complete log of all the output
	from the "pkgrm" utility can be found at:

             pkgrm log: $PKG_RM_LOG 
XYZZY
fi
if [ $INSTALL_GOOD == "YES" ]
then


cat <<XYZZY


Note:	CDE has been installed on this system, please reboot this 
	machine before starting CDE

XYZZY
fi

	cat <<XYZZY

The install-cde script has completed.
$LINE


XYZZY


exit $EXIT_STATUS
}

# ********************************************************************
#
# 	Section 1.15,  LinkFunc:
#
# ********************************************************************
#
#	Function to link to packages.
#
# ********************************************************************

function LinkFunc
{

if [ -d dt ]
then 
  	if [ -d /usr/dt ]
	then
	   /bin/mv /usr/dt /usr/dt.pre-install-cde.${DATE}
	fi
	ln -s `pwd`/dt /usr/dt

	if [ -f /usr/dt/bin/dtconfig ]
	then
		/usr/dt/bin/dtconfig -inetd
	fi
else

         clear
         cat <<XYZZY
$LINE
 
 Error: We could not find the dt directory, are you sure you
	are running install-cde from the correct directory. 

 
                Press <Enter> to exit..
 
$LINE
 
XYZZY
          read
          echo "Error: $DATE: Could not find a dt directory to link to."  >> $ADMIN_LOG
          EXIT_STATUS=1
          Exit

fi

}

# ****************************************************************************
#
# 	Section 1.16,  Tooltalk_min:
#
# ***************************************************************************
#  
#       Function to determine if it is ok to remove SUNWtltk on 2.4
#  
# ***************************************************************************

function Tooltalk_min
{


case "X$(uname -r)" in
                X5.4)
			
			if [ $CLEAN == "YES" ]; then

				TTPKG_LIST=`pkginfo | grep SUNWtltk | grep -v SUNWtltkd | grep -v SUNWtltkm | awk '{print $2 }'`
				for i in $TTPKG_LIST
				do
					FOUNDPKG=`/bin/pkginfo -l $i | grep "VERSION" | grep "3.5" | wc -l`
                			if [ $FOUNDPKG -ne 0 ]; then
                       				if [ $VERT == "YES" ]; then
                               				/usr/sbin/pkgrm $VERBOSE $i 2>&1 | tee -a $PKG_RM_LOG
                       				else
                               				/usr/sbin/pkgrm $VERBOSE $i 2>&1 | tee -a $PKG_RM_LOG | grep $i
                       				fi
						
					fi
				done

			fi

			if [ $REMOVE_TT_ONLY == "NO" ] ; then

                        	if [ $VERT == "YES" ] ; then
                                	/usr/sbin/pkgadd $VERBOSE -d `pwd` SUNWtltk 2>&1 | tee -a $PKG_LOG
                        	else
                                	/usr/sbin/pkgadd $VERBOSE -d `pwd` SUNWtltk 2>&1 | tee -a $PKG_LOG | grep SUNWtltk
                        	fi
			fi


		;;
 
                *)
                ;;
esac
 

}

# ***************************************************************************
#
# 	Section 1.17,  Tooltalk_dev:
#
# ***************************************************************************
#  
#       Determine if it is ok to remove SUNWtltkm, SUNWtltkd on 2.4
#  
# ***************************************************************************

function Tooltalk_dev
{


case "X$(uname -r)" in
                X5.4)


			if [ $CLEAN == "YES" ]; then

                        	TTPKG_LIST=`pkginfo | grep SUNWtltkd | awk '{print $2 }'`
                        	for i in $TTPKG_LIST
                        	do
                                	FOUNDPKG=`/bin/pkginfo -l $i | grep "VERSION" | grep "3.5" | wc -l`
                                	if [ $FOUNDPKG -ne 0 ]; then
                       				if [ $VERT == "YES" ]; then
                               				/usr/sbin/pkgrm $VERBOSE $i 2>&1 | tee -a $PKG_RM_LOG
                       				else
                               				/usr/sbin/pkgrm $VERBOSE $i 2>&1 | tee -a $PKG_RM_LOG | grep $i
                       				fi
                                	fi
                        	done

			fi

			if [ $REMOVE_TT_ONLY == "NO" ] ; then

	                        if [ $VERT == "YES" ] ; then
                                	/usr/sbin/pkgadd $VERBOSE -d `pwd` SUNWtltkd 2>&1 | tee -a $PKG_LOG
                        	else
                                	/usr/sbin/pkgadd $VERBOSE -d `pwd` SUNWtltkd 2>&1 | tee -a $PKG_LOG | grep SUNWtltkd
                        	fi
			fi

			if [ $CLEAN == "YES" ]; then

                        	TTPKG_LIST=`pkginfo | grep SUNWtltkm | awk '{print $2 }'`
                        	for i in $TTPKG_LIST
                        	do
                                	FOUNDPKG=`/bin/pkginfo -l $i | grep "VERSION" | grep "3.5" | wc -l`
                                	if [ $FOUNDPKG -ne 0 ]; then
                       				if [ $VERT == "YES" ]; then
                               				/usr/sbin/pkgrm $VERBOSE $i 2>&1 | tee -a $PKG_RM_LOG
                       				else
                               				/usr/sbin/pkgrm $VERBOSE $i 2>&1 | tee -a $PKG_RM_LOG | grep $i
                       				fi
                                	fi
                        	done
			fi

			if [ $REMOVE_TT_ONLY == "NO" ] ; then

					
                        	if [ $VERT == "YES" ] ; then
                                	/usr/sbin/pkgadd $VERBOSE -d `pwd` SUNWtltkm 2>&1 | tee -a $PKG_LOG
                        	else
                                	/usr/sbin/pkgadd $VERBOSE -d `pwd` SUNWtltkm 2>&1 | tee -a $PKG_LOG | grep SUNWtltkm
                        	fi
			fi
		;;
 
                *)
                ;;
esac
 

}


# ********************************************************************
#
# 	Section 1.18,  LoadStrings:
#
# ********************************************************************
#
#	LoadStrings:	Load Package Strings function.
#
# ********************************************************************

function LoadStrings
{
$DEBUG
case "X$(uname -r)" in
                X5.4)

		DEV_PKGS="SUNWdtinc SUNWdtma SUNWdtmad SUNWmfdm SUNWdthed SUNWdtab SUNWdtdem SUNWmfman SUNWmfdev ${SUNWdtdev}"
		END_PKGS="SUNWdtwm SUNWdthe SUNWdthev SUNWdtdst SUNWdtim SUNWdtrme" 
		MIN_PKGS="SUNWdtft SUNWdtdmn SUNWdtbas SUNWdticn SUNWdtdte SUNWmfrun ${SUNWdta}"

		DEV_RM_PKGS="SUNWdtinc SUNWdtma SUNWdtmad SUNWmfdm SUNWmfdem SUNWdthed SUNWdtab SUNWdtdem SUNWmfman SUNWmfdev SUNWdtdev"
		END_RM_PKGS="SUNWdtwm SUNWdthe SUNWdthev SUNWdtdst SUNWdtim SUNWdtrme" 
		MIN_RM_PKGS="SUNWdtft SUNWdtdmn SUNWdtbas SUNWdticn SUNWdtdte SUNWmfrun ${SUNWdta}"

                ;;

                X5.@([5-9]|[1-9]+([0-9]))*)


		DEV_PKGS="SUNWdtinc SUNWdtma SUNWdtmad SUNWdthed  SUNWdtab SUNWdtdem SUNWmfdev ${SUNWdtdev}"
		END_PKGS="SUNWdtwm SUNWdthe SUNWdthev SUNWdtdst SUNWdtim SUNWdtrme" 
		MIN_PKGS="SUNWdtft SUNWdtdmn SUNWdtbas SUNWdticn SUNWdtdte  ${SUNWdta}"

		DEV_RM_PKGS="SUNWdtinc SUNWdtma SUNWdtmad SUNWdthed  SUNWdtab SUNWdtdem SUNWmfdev SUNWdtdev"
		END_RM_PKGS="SUNWdtwm SUNWdthe SUNWdthev SUNWdtdst SUNWdtim SUNWdtrme"
		MIN_RM_PKGS="SUNWdtft SUNWdtdmn SUNWdtbas SUNWdticn  SUNWdtdte ${SUNWdta}"
                ;;
                *)
                clear
                cat <<XYZZY
$LINE
 
 Error: CDE 1.0 is only supported on SunOS 5.4 and 5.5
 
 
                Press <Enter> to exit..
 
$LINE
 
XYZZY
                read
                echo "Error: $DATE: Wrong OS version, uname -r did not return 5.4 or 5.5" >> $ADMIN_LOG
		EXIT_STATUS=1
                Exit
                ;;
esac
}

# ********************************************************************
#
# 	Section 1.19,  LoadLocale:
#
# ********************************************************************
#
#	LoadLocale:	Load Localization Package Strings
#
# ********************************************************************

function LoadLocale
{
$DEBUG

    SAVE_MIN_LOC_SIZE=0
    SAVE_END_LOC_SIZE=0
    SAVE_DEV_LOC_SIZE=0
    SAVE_ANSWER_SIZE=0
    SAVE_LOC_RM_PKGS=""
    SAVE_LOCALE=""
    SAVE_LOC_PATCHES_sparc=""
    SAVE_LOC_PATCHES_x86=""
    SAVE_LOC_PATCHES_ppc=""
    SAVE_LOC_COPYRIGHT_PKGS="" 
    SAVE_ANSWER_PACKAGES=""

    for locale in $NEW_LOCALE
      do
	case $locale in

        	"JA" | "Ja" | "ja" | "jA" ) 
		
			if [ -d ${TOP}/cde-min/SUNWjdbas ]
			then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
    				SAVE_ANSWER_PACKAGES="${SAVE_ANSWER_PACKAGES} SUNWjda"
				ANSWER_PACKAGES="${SAVE_ANSWER_PACKAGES}"
				JA_DEV_PKGS="SUNWjdab SUNWjdhed SUNWjdma"
        			JA_END_PKGS="SUNWjdwm SUNWjdhev SUNWjddst SUNWjdhe SUNWjdim SUNWjdrme"
				JA_RM_PKGS="${JA_MIN_PKGS} ${JA_END_PKGS} ${JA_DEV_PKGS}"

				case "X$(uname -r)" in
                		        X5.4)
		                        SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWjdbas"
                                        LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
					JA_MIN_PKGS="SUNWjddte SUNWjmfrn SUNWjtltk"
                                        SAVE_LOC_PATCHES_sparc="${SAVE_LOC_PATCHES} 102499-01"
                                        SAVE_LOC_PATCHES_x86="${SAVE_LOC_PATCHES} 102500-01"
					;;

                			X5.@([5-9]|[1-9]+([0-9]))*)
		                        SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWjdbas"
                                        LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
					JA_MIN_PKGS="SUNWjddte"
                                        SAVE_LOC_PATCHES_sparc="${SAVE_LOC_PATCHES} 102497-01"
                                        SAVE_LOC_PATCHES_x86="${SAVE_LOC_PATCHES} 102498-01"
					SAVE_LOC_PATCHES_ppc="${SAVE_LOC_PATCHES} 102797-01"
                                        ;;

				esac

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 800`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 7700`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 7850`
				SAVE_ANSWER_SIZE=`expr $SAVE_ANSWER_SIZE + 115000`
				ANSWER_SIZE=${SAVE_ANSWER_SIZE}
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

				LOC_PATCHES_sparc="${SAVE_LOC_PATCHES_sparc}"
				LOC_PATCHES_x86="${SAVE_LOC_PATCHES_x86}"
				LOC_PATCHES_ppc="${SAVE_LOC_PATCHES_ppc}"
				
				JA_RM_PKGS="${JA_MIN_PKGS} ${JA_END_PKGS} ${JA_DEV_PKGS}"
				SAVE_LOC_RM_PKGS="${SAVE_LOC_RM_PKGS} ${JA_RM_PKGS}"
				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"
			else
				CONFIG_MENU_SELECT="YES"	
       	 			print ""
        			print ""
        			print "\tSorry, the JA packages are not available on this  cdrom "
        			print ""
        			print ""
        			sleep 2
			fi
			;; 

        	"KO" | "Ko" | "ko" | "kO" ) 
		
			if [ -d ${TOP}/cde-min/SUNWkdbas ]
			then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWkdbas"
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
        			KO_MIN_PKGS="SUNWkddte SUNWkdicn SUNWkdft"
				KO_END_PKGS="SUNWkdwm SUNWkdhe SUNWkddst SUNWkdhev SUNWkdim"
				KO_DEV_PKGS="SUNWkdab"
				KO_RM_PKGS="${KO_MIN_PKGS} ${KO_END_PKGS} ${KO_DEV_PKGS}"

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 600`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 850`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 975`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

				SAVE_LOC_RM_PKGS="${SAVE_LOC_RM_PKGS} ${KO_RM_PKGS}"
				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"
			else
				CONFIG_MENU_SELECT="YES"	
       	 			print ""
        			print ""
        			print "\tSorry, the KO packages are not available on this  cdrom "
        			print ""
        			print ""
        			sleep 2
			fi
			;; 

        	"ES" | "Es" | "es" | "eS" ) 
		
			if [ -d ${TOP}/cde-min/SUNWesbas ]
			then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWesbas"
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
        			ES_MIN_PKGS="SUNWesdte SUNWesdta"
				ES_END_PKGS="SUNWeshe SUNWesdst SUNWesim SUNWeswm SUNWeshev SUNWesrme"
				ES_DEV_PKGS="SUNWeshed SUNWesab"
				ES_RM_PKGS="${ES_MIN_PKGS} ${ES_END_PKGS} ${ES_DEV_PKGS}"
				SAVE_LOC_RM_PKGS="${SAVE_LOC_RM_PKGS} ${ES_RM_PKGS}"

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 525`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 670`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 700`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"
			else
				CONFIG_MENU_SELECT="YES"	
       	 			print ""
        			print ""
        			print "\tSorry, the ES packages are not available on this  cdrom "
        			print ""
        			print ""
        			sleep 2
			fi
			;; 


        	"ZH" | "Zh" | "zh" | "zH" ) 
		
			if [ -d ${TOP}/cde-min/SUNWcdbas ]
			then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWcdbas"
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
        			ZH_MIN_PKGS="SUNWcddte SUNWcdft SUNWcdicn"
				ZH_END_PKGS="SUNWcdwm SUNWcdhe SUNWcdhev SUNWcddst SUNWcdim"
				ZH_DEV_PKGS="SUNWcdab"
				ZH_RM_PKGS="${ZH_MIN_PKGS} ${ZH_END_PKGS} ${ZH_DEV_PKGS}"
				SAVE_LOC_RM_PKGS="${SAVE_LOC_RM_PKGS} ${ZH_RM_PKGS}"
				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 650`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 900`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 925`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

			else
				CONFIG_MENU_SELECT="YES"	
       	 			print ""
        			print ""
        			print "\tSorry, the ZH packages are not available on this  cdrom "
        			print ""
        			print ""
        			sleep 2
			fi
			;; 

        	"SV" | "Sv" | "sv" | "sV" ) 
		
			if [ -d ${TOP}/cde-min/SUNWsvbas ]
			then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWsvbas"
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
        			SV_MIN_PKGS="SUNWsvdte SUNWsvdta"
				SV_END_PKGS="SUNWsvhe SUNWsvdst SUNWsvim SUNWsvwm SUNWsvhev SUNWsvrme"
				SV_DEV_PKGS="SUNWsvab SUNWsvhed"
				SV_RM_PKGS="${SV_MIN_PKGS} ${SV_END_PKGS} ${SV_DEV_PKGS}"

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 10`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 160`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 190`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

				SAVE_LOC_RM_PKGS="${SAVE_LOC_RM_PKGS} ${SV_RM_PKGS}"
				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"
			else
				CONFIG_MENU_SELECT="YES"	
       	 			print ""
        			print ""
        			print "\tSorry, the SV packages are not available on this  cdrom "
        			print ""
        			print ""
        			sleep 2
			fi
			;; 

        	"IT" | "It" | "it" | "iT" ) 
		
			if [ -d ${TOP}/cde-min/SUNWitbas ]
			then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWitbas"
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
        			IT_MIN_PKGS="SUNWitdte SUNWitdta"
				IT_END_PKGS="SUNWithe SUNWitdst SUNWitim SUNWitwm SUNWithev SUNWitrme"
				IT_DEV_PKGS="SUNWitab SUNWithed"
				IT_RM_PKGS="${IT_MIN_PKGS} ${IT_END_PKGS} ${IT_DEV_PKGS}"

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 550`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 690`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 720`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

				SAVE_LOC_RM_PKGS=
				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"
			else
				CONFIG_MENU_SELECT="YES"
       	 			print ""
        			print ""
        			print "\tSorry, the IT packages are not available on this  cdrom "
        			print ""
        			print ""
        			sleep 2
			fi
			;; 

        	"DE" | "De" | "de" | "dE" ) 
		
			if [ -d ${TOP}/cde-min/SUNWdebas ]
			then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWdebas"
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
        			DE_MIN_PKGS="SUNWdedte SUNWdedta SUNWdedta"
				DE_END_PKGS="SUNWdehe SUNWdedst SUNWdeim SUNWdewm SUNWdehev SUNWderme"
				DE_DEV_PKGS="SUNWdeab SUNWdehed"
				DE_RM_PKGS="${DE_MIN_PKGS} ${DE_END_PKGS} ${DE_DEV_PKGS}"

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 550`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 700`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 730`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

				SAVE_LOC_RM_PKGS="${SAVE_LOC_RM_PKGS} ${DE_RM_PKGS}"
				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"
			else
				CONFIG_MENU_SELECT="YES"	
       	 			print ""
        			print ""
        			print "\tSorry, the DE packages are not available on this  cdrom "
        			print ""
        			print ""
        			sleep 2
			fi
			;; 

        	"ZH_TW" | "Zh_TW" | "zh_TW" | "zH_TW" | "ZH_tW" | "ZH_Tw" | "ZH_tw" | "zh_tw" | "zH_tW" | "zH_Tw" | "Zh_tW" | "Zh_Tw" ) 
		
			if [ -d ${TOP}/cde-min/SUNWhdbas ]
			then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWhdbas"
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
        			ZH_TW_MIN_PKGS="SUNWhddte SUNWhdicn"
				ZH_TW_END_PKGS="SUNWhdwm SUNWhdhe SUNWhddst SUNWhdhev SUNWhdim"
				ZH_TW_DEV_PKGS="SUNWhdab"
				ZH_TW_RM_PKGS="${ZH_TW_MIN_PKGS} ${ZH_TW_END_PKGS} ${ZH_TW_DEV_PKGS}"

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 360`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 560`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 600`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

				SAVE_LOC_RM_PKGS="${SAVE_LOC_RM_PKGS} ${ZH_TW_RM_PKGS}"
				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"
			else
				CONFIG_MENU_SELECT="YES"	
       	 			print ""
        			print ""
        			print "\tSorry, the ZH_TW packages are not available on this  cdrom "
        			print ""
        			print ""
        			sleep 2
			fi
			;; 


        	"FR" | "Fr" | "fr" | "fR" ) 

			if [ -d $TOP/cde-min/SUNWfrbas ]
                        then
				SAVE_LOCALE="$SAVE_LOCALE $locale"
				LOCALE="$SAVE_LOCALE"
		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS} SUNWfrbas"
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
				FR_DEV_PKGS="SUNWfrab SUNWfrhed"
        			FR_END_PKGS="SUNWfrhe SUNWfrdst SUNWfrim SUNWfrwm SUNWfrrme SUNWfrhev"
        			FR_MIN_PKGS="SUNWfrdte SUNWfrdta"
				FR_RM_PKGS="${FR_MIN_PKGS} ${FR_END_PKGS} ${FR_DEV_PKGS}"

				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 500`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 675`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 720`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}

				SAVE_LOC_RM_PKGS="${SAVE_LOC_RM_PKGS} ${FR_RM_PKGS}"
				LOC_RM_PKGS="${SAVE_LOC_RM_PKGS}"
			else
                                CONFIG_MENU_SELECT="YES"
                                print ""
                                print ""
                                print "\tSorry, the FR packages are not available on this  cdrom "
                                print ""
                                print ""
        			sleep 2
			fi
                 ;;  

		"EN" | "En" | "en" | "eN" )
				SAVE_LOCALE="$SAVE_LOCALE $locale"

				if [ -d ${TOP}/cde-min/SUNWdta ]
                        	then
					SAVE_ANSWER_SIZE=`expr $SAVE_ANSWER_SIZE + 120000`
					ANSWER_SIZE=${SAVE_ANSWER_SIZE}
    					SAVE_ANSWER_PACKAGES="${SAVE_ANSWER_PACKAGES} SUNWdta"
					ANSWER_PACKAGES="${SAVE_ANSWER_PACKAGES}"
				fi

				LOCALE="$SAVE_LOCALE"

		                SAVE_LOC_COPYRIGHT_PKGS="${SAVE_LOC_COPYRIGHT_PKGS}" 
                                LOC_COPYRIGHT_PKGS=${SAVE_LOC_COPYRIGHT_PKGS}
				SAVE_MIN_LOC_SIZE=`expr $SAVE_MIN_LOC_SIZE + 0`
				SAVE_END_LOC_SIZE=`expr $SAVE_END_LOC_SIZE + 0`
				SAVE_DEV_LOC_SIZE=`expr $SAVE_DEV_LOC_SIZE + 0`
				MIN_LOC_SIZE=${SAVE_MIN_LOC_SIZE}
				END_LOC_SIZE=${SAVE_END_LOC_SIZE}
				DEV_LOC_SIZE=${SAVE_DEV_LOC_SIZE}
		;;

		*)
			CONFIG_MENU_SELECT="YES"	
       	 		print ""
        		print ""
        		print "\tError: \t You must enter  JA, FR, EN, KO, ZH, ZH_TW, SV, IT, DE, ES "
        		print ""
        		sleep 2
		;;	
	esac
      done
}




# ********************************************************************
# ********************************************************************
#
#	Section 2.0, Main Body
#
# ********************************************************************
# ********************************************************************



# ********************************************************************
#
#	Section 2.1, Check to be sure user is root
#
# ********************************************************************

	USER=`/bin/id | grep root | wc -l`
	if [ $USER -eq 0 ]
	then

		echo ""
		echo "You must be root to run this script"
        	echo ""
        	exit 1
	fi

# ********************************************************************
#
#	Section 2.2, Variable Initialization
#
# ********************************************************************
	trap 'rm -f /tmp/admin.$$; rm -f tmp.whatami.$$;  rm -f /usr/dt/tmp.install.file.$$;  exit' INT QUIT TERM EXIT
	SUNWdtdev=
	if [ -d cde-developer/SUNWdtdev ]
	then 
		SUNWdtdev=SUNWdtdev
	fi

	TOP=`pwd`
	CHECK=YES
	CDE_CHECK=YES
	EXIT_STATUS=0
	VERT="NO"
	NEW_VERT=
	DEBUG=
	CLEAN=YES
	NEW_CLEAN=
	PATCH=YES
	ANSWER=NO
	DTLOGIN=YES
        MIN_INSTALL=YES
	END_INSTALL=YES
	DEV_INSTALL=NO
	SDTHOME=/usr/dt
        LOCALE=EN
    	MIN_LOC_SIZE=0
    	END_LOC_SIZE=0
    	DEV_LOC_SIZE=0
	ANSWER_PACKAGES="SUNWdta"
	ANSWER_SIZE=120000
	SUNWdta=
	SUNWtltk=
	SUNWtltkm=
	SUNWtltkd=
        LOC_COPYRIGHT_PKGS=""
	NEW_SDTHOME=
	INSTALL_GOOD="NO"
	SEND_MAIL="YES"
	REMOVE_TT_ONLY="NO"
	PLATFORM=`uname -p`
	if [ $PLATFORM == "i386" ] 
	then
		PLATFORM="x86"
	fi	

	RELEASE=`uname -r`

	DATE=`LANG=C date '+%d%b%y-%H:%M:%S'`
	PATH=/bin:/usr/bin:/etc:/usr/bin
	ADMIN_LOG=/usr/tmp/SunSoft_CDE1.0.1_install.log.${DATE}
	PKG_RM_LOG=/usr/tmp/SunSoft_CDE1.0.1_pkgrm.log.${DATE}
	PKG_LOG=/usr/tmp/SunSoft_CDE1.0.1_pkgadd.log.${DATE}
	VERBOSE="-n -a /tmp/admin.$$"
	MENU_SELECT=NO
	current="Default"
	CURRENT="DEFAULT"
	CONFIG_MENU_SELECT=YES
	DONE=NO
	LINE="____________________________________________________________________________"

	cat >/tmp/admin.$$ <<EOF
basedir=default
mail=
runlevel=quit
conflict=nocheck
setuid=nocheck
action=nocheck
partial=nocheck
instance=unique
idepend=nocheck
rdepend=nocheck
space=quit
EOF


# ********************************************************************
#
#	Section 2.3, Argument Processing
#
# ********************************************************************

#
# Determine if we should display FTP license agreement
#

if [ -f $TOP/CDE_License ]
then
	License
fi

      	if [ $# -gt 14 ]
        then
                HELP $1      # exit on error
        fi

	while [ $# -gt 0 ]
	   do case $1 in
		-loc)  SDTHOME=$2; 			shift 2	;; # install location for /usr/dt
		-locale)  NEW_LOCALE=$2; LoadLocale; 	shift 2	;; # additional local packages
		-link)  LINKDIR=$2 ; LinkFunc ;		exit	;; 
		-noclean) CLEAN="NO"; 			shift	;;
		-nospace) CHECK="NO"; 			shift	;;
		-nocheck) CDE_CHECK="NO"; 		shift	;;
		-nopatches) PATCH="NO";			shift	;;
		-nologin) DTLOGIN="NO";			shift   ;;
		-debug) DEBUG="set -xv"; 		shift	;;
		-uninstall) LoadStrings; RemoveCDE;	exit	;;
		-help) HELP; 				exit	;;
		?) HELP; 				exit	;;
		-ver)  VERT="YES"; VERBOSE="";  	shift   ;;
		-min)  MENU_SELECT="YES"; END_INSTALL="NO"; response="1"; shift 	;;
		-end)  MENU_SELECT="YES"; END_INSTALL="YES";response="1"; shift	;;
		-dev)  MENU_SELECT="YES"; END_INSTALL="YES"; DEV_INSTALL="YES"; response="1"; shift	;;
		*) HELP $1; 				shift	;; # exit on error
    	   esac
	done


# ********************************************************************
#
#	Section 2.4, Main Menu                     
#
# ********************************************************************
#	This section is the main login of install-cde, once all the
# 	variables are set, either from the command line or via the
# 	options menu, the use selects 1 to start the install or
#	3 to exit. 
#
#	The case statment for the menu selection will then execute
# 	the necessary functions in the correct order. This essentially
# 	installs CDE. The order of these functions is as follows:
#
#		1. LoadStrings
#               2. CheckDisk 
#               3. CreateTheLink
#               4. InstallMin 
#  		5. MinPatch  
#               6. RunDtconfig                         
#		7. InstallEnd
#		8. EndPatch
#		9. InstallDev
#		10. DevPatch
#
# 	Thanks goes to Bill S. for these comments.:-)
#
# ********************************************************************

# Menu Items

MENU_VAR[1]="	Installation Location"
MENU_VAR[2]="	End User CDE Packages (28M):"
MENU_VAR[3]="	Developer CDE Packages (24M):"
MENU_VAR[4]="	Answerbook CDE Package (120M):"
MENU_VAR[5]="	Remove Old CDE Packages:"
MENU_VAR[6]="	Interactive Installation:"
MENU_VAR[7]="	Solaris Desktop Login
		 at System Boot:"
MENU_VAR[8]="	Installation Locale:"

while [ $DONE == "NO" ]
do
while [ $MENU_SELECT == "NO" ]
do
 
clear

cat <<XYZZY

		Solaris Common Desktop Environment
			  Installation Script
			      Main Menu

$LINE


	1. 	Begin Installation (With $current Configuration Settings)

	2. 	Modify Configuration Settings

	3.	Cancel Installation 


		$CURRENT CONFIGURATION SETTINGS

	${MENU_VAR[1]}		[ $SDTHOME ]
	${MENU_VAR[2]}	[ $END_INSTALL 	]
	${MENU_VAR[3]}	[ $DEV_INSTALL 	]
	${MENU_VAR[4]}	[ $ANSWER	]   
	${MENU_VAR[6]}	[ $VERT	]   
	${MENU_VAR[7]}		[ $DTLOGIN	]   
	${MENU_VAR[8]}		[ $LOCALE	]   

$LINE

XYZZY
print -n "\tSELECT A NUMBER [1] "

read response

MENU_SELECT=YES

if [[ $response = `` ]] then response="1";  fi
if [[ $response == "1" ]] then
print ""
print -n "\tBegin CDE Installation Now ? (Y/N) [Y]"
 
read abort_chance
if [[ $abort_chance = "N"  ||  $abort_chance = "n" ]] then
        MENU_SELECT=NO
fi
if [[ $abort_chance = `` ]] then MENU_SELECT=YES;  fi
fi


done
 
if [[ $MENU_SELECT = YES ]] then

case $response in

	"1" )

	clear
	LoadStrings
	if [ $CHECK == "YES" ] 	; then CheckDisk 	; else DONE=YES;  fi
	if [ $SDTHOME != "/usr/dt" ] ; then CreateTheLink ; else DONE=YES;  fi
	if [ $DONE = "YES" ]    ; then InstallMin	;	fi
	if [ $PATCH = "YES" ]	; then MinPatch		; else DONE=YES;	fi
	if [ $DTLOGIN = "YES" ] ; then RunDtconfig	; else DONE=YES;	fi

	if [ $END_INSTALL = "YES" ]
	then
		if [ $DONE = "YES" ]    ; then InstallEnd 	;	fi
		if [ $PATCH = "YES" ]	; then EndPatch		; else DONE=YES;	fi
	fi

	if [ $DEV_INSTALL = "YES" ]
	then
		if [ $DONE = "YES" ] 	; then InstallDev 	;	fi
		if [ $PATCH = "YES" ]	; then DevPatch		; else DONE=YES;	fi
	fi
	;;

        "2" )
	clear
	CURRENT="CURRENT"
	current="Current"
	SetOptions
	MENU_SELECT=NO
        ;;

        "3" )
	DONE="YES"
        ;;

 	*)
        print ""
        print ""
        print "\t\tI don't recognize..\"$response\" Try Again.. "
        sleep 1
        MENU_SELECT=NO
        ;;
 
esac
fi

done 
Exit 



# ********************************************************************
#
#	The End
#
# ********************************************************************
