#! /bin/sh
#
#	WARNING: This software is protected by copyright law and international treaties.
#
#	Unauthorized reproduction or distribution of this program, or any portion of it,
#	may result in severe civil and criminal penalties, and will be prosecuted to
#	the maximum extent possible under law.
#
DEFAULT_INSTALLATION_DIR=/opt/SYBSasa6
SYBASE_DEFAULT_DIR=/opt/sybase
PACKAGE_NAME="Sybase SQL Anywhere Studio 6.0.4"
# basic product packages are:
#    INSTALL_ASA
#    INSTALL_REPAGENT
#    INSTALL_SSREMOTE
#    INSTALL_SYBASECENTRAL
#    INSTALL_CTLIB

PDB_INSTALLED=false

MEDIA_ROOT=`dirname $0`
PWD=`pwd`
case _$MEDIA_ROOT in
    _/* )
	true
	;;

    * )
	MEDIA_ROOT=`dirname $PWD/$0`
	;;
esac
TARFILE_NAME=files.tar

PATH=$MEDIA_ROOT/bin:/bin:/usr/bin:$PATH
export PATH

OS_TYPE=`uname -s`
if [ $OS_TYPE = "SunOS" ]
then
    OS_TYPE="${OS_TYPE}_`uname -p`"
fi

OS_NAME=`uname -n`

MADE_NEW_SYBASE_DIR=false
 
export OS_TYPE OS_NAME

get_syb_dest_dir () {
    DEF_DEST_DIR=$DEFAULT_INSTALLATION_DIR
    DEFAULT_INSTALLATION_DIR=$SYBASE_DEFAULT_DIR
    if [ $INSTALL_CTLIB = true ]
    then
	echo "The Open Client/Open Server libraries will be installed"
	echo "the directory \$SYBASE($SYBASE)."
    fi
    if [ -z "${SYBASE:-}" ] || [ ! -d "${SYBASE:-}" ]
    then
        echo "The \$SYBASE directory does not exist."
        echo "Please enter a location for \$SYBASE."
        get_dest_dir
        OVERWRITE_SYBASEDIR=true
    else
        if [ $OVERWRITE_SYBASEDIR = false ]
        then
            echo "The \$SYBASE directory $SYBASE already exists."
            CLIC=x
            while [ "$CLIC" != "Y" ] && [ "$CLIC" != "y" ] && [ "$CLIC" != "N" ] && [ "$CLIC" != "n" ]
            do
                echo "Do you wish to overwrite the files in this location (Y/N)?"
                read CLIC
            done
            if [ "$CLIC" != "y" ] && [ "$CLIC" != "Y" ]
            then
                echo "Please enter a new location for \$SYBASE."
                get_dest_dir
            else
                DEST_DIR=$SYBASE
            fi
            OVERWRITE_SYBASEDIR=true
        else
            DEST_DIR=$SYBASE
        fi
    fi
    SYBASE=$DEST_DIR
    export SYBASE
    MADE_NEW_SYBASE_DIR=true
    DEFAULT_INSTALLATION_DIR=$DEF_DEST_DIR
}

get_dest_dir () {
    DEST_DIR=
    while [ "_$DEST_DIR" = "_" ]
    do
	echo
	echo "Please enter the installation directory (default $DEFAULT_INSTALLATION_DIR):"
	read DEST_DIR

	if [ "_$DEST_DIR" = "_" ]
	then
	    DEST_DIR=$DEFAULT_INSTALLATION_DIR
	fi

	if [  -f "$DEST_DIR" ]
	then
	    echo "$DEST_DIR exists but is not a directory."
	    DEST_DIR=
	elif [ -d "$DEST_DIR" ]
	then
	    echo
	    echo "NOTE: $DEST_DIR exists -- files will be overwritten"
	    echo
	else
	    if mkdir -p "$DEST_DIR" 2>/dev/null
	    then
		true;
	    else
		echo "Cannot create directory $DEST_DIR"
		DEST_DIR=
	    fi
	fi
    done
    PATH=$DEST_DIR:$PATH
    export PATH
    LIBPATH=$DEST_DIR/lib:$PATH
    export PATH
    case "$OS_TYPE" in
	AIX)	LIBPATH=$DEST_DIR/lib:$LIBPATH
                export LIBPATH
		;;

	HP-UX)	SHLIB_PATH=$DEST_DIR/lib:$SHLIB_PATH
                export SHLIB_PATH
		;;

	SunOS_sparc)	LD_LIBRARY_PATH=$DEST_DIR/lib:$LD_LIBRARY_PATH
                export LD_LIBRARY_PATH
		;;

	SunOS_i386)	LD_LIBRARY_PATH=$DEST_DIR/lib:$LD_LIBRARY_PATH
                export LD_LIBRARY_PATH
		;;

	Linux)	LD_LIBRARY_PATH=$DEST_DIR/lib:$LD_LIBRARY_PATH
                export LD_LIBRARY_PATH
		;;

	* )	LD_LIBRARY_PATH=$DEST_DIR/lib:$LD_LIBRARY_PATH
                export LD_LIBRARY_PATH
		;;
    esac			
}

show_product_choices () {
    cat <<-PRODUCT_CHOICES


	Please choose one of the following packages to install:
	
        1. Network Client
        2. Network Server (includes Personal Server with SQL Remote)
        3. Personal Server
        4. Personal Server with SQL Remote

	Choice:
PRODUCT_CHOICES
}

show_package_choices () {
    cat <<-PACKAGE_CHOICES


	Select which component(s) you would like to install:
	
	1. Adaptive Server Anywhere 6.0.4
	2. Replication Agent for ASA 6.0.4
	3. SQL Remote for ASE
	4. Finish Install (install Sybase libraries if needed)

	Choice:
PACKAGE_CHOICES
}

get_product() {
    PKG=
    INSTALL_SYBASECENTRAL=false
    while [ "_$PKG" = "_" ]
    do
        PKG=
	show_product_choices
	read CHOICE
	case "$CHOICE" in
	    "1" )
		PKG=n_client
		DESC="Network Client"
		;;

	    "2" )
		PKG=n_server
		DESC="Network Server"
                PDB_INSTALLED=true
                case "`echo $REG_KEY | cut -c4`" in
                    "A" )
                        NUM_USERS=1
		        ;;

                    "E" )
                        NUM_USERS=5
		        ;;

                    *   )
                        NUM_USERS=1
		        ;;
                esac
		;;

	    "3" )
		PKG=p_server
		DESC="Personal Server"
                PDB_INSTALLED=true
		;;

	    "4" )
		PKG=p_srv_sr
		DESC="Personal Server with SQL Remote"
                PDB_INSTALLED=true
		;;

	    *   )
		echo "Please enter a number from 1 to 4."
		;;

	esac
        INSTALL_SYBASECENTRAL=false
        CLIC=x
        while [ "$CLIC" != "Y" ] && [ "$CLIC" != "y" ] && [ "$CLIC" != "N" ] && [ "$CLIC" != "n" ]
        do
            echo "Do you wish to install Sybase Central (Java) Support Files (Y/N)?"
            read CLIC
        done
        if [ "$CLIC" = "y" ] || [ "$CLIC" = "Y" ]
        then
            INSTALL_SYBASECENTRAL=true
        else
            INSTALL_SYBASECENTRAL=false
        fi
    done
}

get_package() {
    PRD=
    CONT=true
    while [ "$CONT" = "true" ]
    do
        PRD=
        INSTALL_ASA=false
        INSTALL_REPAGENT=false
        INSTALL_SSREMOTE=false
        if [ $OS_TYPE != "SunOS_i386" ]
	then
	    show_package_choices
	    read CHOICE
	else
	    CHOICE=1
	    CONT=false
	fi
	case "$CHOICE" in
	    "1" )
                INSTALL_ASA=true
                INSTALL_REPAGENT=false
                INSTALL_SSREMOTE=false
		;;

	    "2" )
                INSTALL_ASA=false
                INSTALL_REPAGENT=true
                INSTALL_SSREMOTE=false
                INSTALL_CTLIB=true
		;;

	    "3" )
                INSTALL_ASA=false
                INSTALL_REPAGENT=false
                INSTALL_SSREMOTE=true
                INSTALL_CTLIB=true
		;;

	    "4" )
                finish_install
                exit
		;;

	    *   )
		echo "Please enter a number from 1 to 4."
		;;

	esac
        do_package_install
    done
    if [ $OS_TYPE = "SunOS_i386" ]
    then
        finish_install
    fi
}

create_sybcentral_res_file () {
    RES_FILE=$DEST_DIR/java/SybCentral.res

    echo
    echo "Creating the file  $RES_FILE"
    cat <<-SYBCENTRAL_RES_FILE  >> $RES_FILE

Providers/Adaptive_Server_Anywhere/provider=sybase.scp.sa.bo.ASAPlugin
Providers/Adaptive_Server_Anywhere/classpath=$ASA_DEST_DIR/java/asaplugin.jar:$ASA_DEST_DIR/java
Providers/Adaptive_Server_Anywhere/name=Adaptive Server Anywhere
Providers/Adaptive_Server_Anywhere/autoload=true
Profiles/Adaptive_Server_Anywhere/ASANY=$ASA_DEST_DIR
#
RepositoryInfo/Version=3
SYBCENTRAL_RES_FILE

    # set the permissions on the file
    chmod a+w  $RES_FILE
    chmod a+r  $RES_FILE

    # ask the user if they want a local copy
    echo "By default, Sybase Central users on this machine will use the"
    echo "repository file:  $RES_FILE."
    CLIC=x
    while [ "$CLIC" != "Y" ] && [ "$CLIC" != "y" ] && [ "$CLIC" != "N" ] && [ "$CLIC" != "n" ]
    do
        echo "Would you prefer that each user have a separate copy (Y/N)?"
        read CLIC
    done

    echo
    echo "Modifying the SybaseCentral startup script..."
    mv -f $DEST_DIR/java/scjview $DEST_DIR/java/scjview.old

    if [ "$CLIC" != "n" ] && [ "$CLIC" != "N" ]
    then
        sed "s%\-Dsyb%-DSybCentral.rep=\$HOME -Dsyb%" $DEST_DIR/java/scjview.old  > $DEST_DIR/java/scjview
        echo
        echo "For this change to take effect, each user must copy"
        echo "$RES_FILE to their home directory."
        echo
        echo "Press ENTER to continue"
        read CLIC
    else
        sed "s%\-Dsyb%-DSybCentral.rep=$DEST_DIR\/java -Dsyb%" $DEST_DIR/java/scjview.old  > $DEST_DIR/java/scjview
        echo
    fi
    chmod +x $DEST_DIR/java/scjview
    rm -f $DEST_DIR/java/scjview.old
}

do_package_install () {
    if [ $INSTALL_ASA = true ]
    then
        PRODUCT_NAME="Sybase Adaptive Server Anywhere 6.0.4"
        TARFILE_NAME="files.tar"
        echo
        echo "Please enter the location for the $PRODUCT_NAME files."
        get_dest_dir
        ASANY_DIR=$DEST_DIR
        ASA_DEST_DIR=$DEST_DIR
        get_product
        do_install

        if [ $PKG != n_client ]
        then
            PRODUCT_NAME="Unicode Infrastructure Library 4.0 Lite"
            PKG="unilib"
            TARFILE_NAME="unifiles.tar"
            DESC="Character set conversion"
            DEST_DIR=$ASANY_DIR
            if [ -z "${ASANY_DIR:-}" ] && [ $INSTALL_CTLIB = true ]
            then
                echo
                echo "Installing the Unicode files into $SYBASE ..."
                echo
                get_syb_dest_dir
            elif [ -z "${ASANY_DIR:-}" ]
            then
                echo
                echo "Please enter a location for the Unicode files."
                get_dest_dir
                ASANY_DIR=$DEST_DIR
            fi
            do_install
        fi

        if [ $INSTALL_SYBASECENTRAL = true ]
        then
            PRODUCT_NAME="Sybase Central (Java)"
            PKG="scentral"
            TARFILE_NAME="sc_files.tar"
            DESC=""
            echo
            echo "Sybase Central (Java) will now be installed into the \$SYBASE/sybcentral32 directory."
            get_syb_dest_dir
            DEST_DIR=$SYBASE/sybcentral32
            mkdir -p $SYBASE/sybcentral32
            do_install
	    create_sybcentral_res_file
            if [ "$OS_TYPE" = "AIX" ]
            then
                rm -rf $SYBASE/sybcentral32/java/jre
                ln -s /usr/jdk_base "$SYBASE/sybcentral32/java/jre-`uname -s`"
            else
                if [ $OS_TYPE = "SunOS_i386" ]; then
                    rm -rf $SYBASE/sybcentral32/java/jre
                    ln -s /usr/java1.1 "$SYBASE/sybcentral32/java/jre-`uname -s`"
                else
                    (cd $SYBASE/sybcentral32/java; $MEDIA_ROOT/bin/gtar x -f jre.tar; mv jre "jre-`uname -s`"; rm -f jre.tar)
                fi
            fi
        fi
    fi

    if [ $INSTALL_REPAGENT = true ]
    then
        PRODUCT_NAME="Replication Agent for ASA 6.0.4"
        PKG="repagent"
        TARFILE_NAME="repfiles.tar"
        DESC="Replication Agent"
        if [ -z "${ASANY_DIR:-}" ]
        then
            echo
            echo "Please enter the location for the $PRODUCT_NAME files."
            get_dest_dir
            ASANY_DIR=$DEST_DIR
        else
            DEST_DIR=$ASANY_DIR
        fi
        do_install
    fi
    if [ $INSTALL_SSREMOTE = true ]
    then
        PRODUCT_NAME="SQL Remote for Adaptive Server Enterprise"
        PKG="ssremote"
        TARFILE_NAME="ssrfiles.tar"
        DESC=""
        echo
        echo "The SQL Remote for ASE files will now be installed into the \$SYBASE directory."
        get_syb_dest_dir
        DEST_DIR=$SYBASE
        do_install
    fi
}

is_numeric()
# $1: argument to check
{
    JUNK=`echo $1 |grep "[^0-9]"`
    if [ "_$1" != "_" ] && [ "_$JUNK" = "_" ]; then
        echo "true"
    else
        echo "false"
    fi
}

do_install () {
    echo 
    echo "Installing $PRODUCT_NAME $DESC to $DEST_DIR"
    echo 
    cd $DEST_DIR
    if $MEDIA_ROOT/bin/gtar xv -U -T $MEDIA_ROOT/$PKG/files -f $MEDIA_ROOT/$TARFILE_NAME
    then
	cd $MEDIA_ROOT
    else
	cd $MEDIA_ROOT
	echo 
	echo "WARNING: Installation of $PRODUCT_NAME failed or is incomplete."
	echo 
	exit 1
    fi

    if [ $PKG = "n_server" ]
    then
        clear
        USERNAME=
        while [ "_$USER_NAME" = "_" ]
        do
            echo "Enter your name:"
            read USER_NAME
        done
        CO_NAME=
        while [ "_$CO_NAME" = "_" ]
        do
            echo "Enter your company name:"
            read CO_NAME
        done
        echo "Have you purchased a concurrent license?"
        CLIC=x
        while [ "$CLIC" != "Y" ] && [ "$CLIC" != "y" ] && [ "$CLIC" != "N" ] && [ "$CLIC" != "n" ]
        do
            echo "(Enter Y for concurrent, N for per-seat)"
            read CLIC
        done
        if [ "$CLIC" = "y" ] || [ "$CLIC" = "Y" ]
        then
            LIC_TYPE="concurrent"
        else
            LIC_TYPE="perseat"
        fi
  
	NUM_SEATS=default
        while [ "`is_numeric $NUM_SEATS`" = "false" ]; do
            echo
            echo "Enter number of seats [$NUM_USERS]: "
            read JUNK
            if [ "_$JUNK" = "_" ]; then
                NUM_SEATS=$NUM_USERS
            else
                NUM_SEATS=$JUNK
            fi
        done

        chmod +w $DEST_DIR/bin/dbsrv6
        $DEST_DIR/bin/dblic -l $LIC_TYPE -p UNIX -u $NUM_SEATS $DEST_DIR/bin/dbsrv6 \""$USER_NAME"\" \""$CO_NAME"\"
        chmod -w $DEST_DIR/bin/dbsrv6
    fi

    echo "$PRODUCT_NAME has been successfully installed."
}

finish_install () {

    if [ $PDB_INSTALLED = true ]; then
        if [ "$OS_TYPE" = "AIX" ]; then
            rm -rf $ASA_DEST_DIR/ProcDebug/jre
            ln -s /usr/jdk_base $ASA_DEST_DIR/ProcDebug/jre
        else
            if [ $OS_TYPE = "SunOS_i386" ]; then
                rm -rf $ASA_DEST_DIR/ProcDebug/jre
                ln -s /usr/java1.1 $ASA_DEST_DIR/ProcDebug/jre
            else
                (cd $ASA_DEST_DIR/ProcDebug; $MEDIA_ROOT/bin/gtar x -f jre.tar; rm -f jre.tar)
            fi
        fi
    fi

    if [ $INSTALL_CTLIB = true ]
    then
        PRODUCT_NAME="Sybase Open Server/Open Client libraries 11.1.1"
        PKG="ctlib"
        TARFILE_NAME="ct_files.tar"
        DESC=""
        echo
        echo "The Sybase libraries will now be installed into the \$SYBASE directory."
        get_syb_dest_dir
        DEST_DIR=$SYBASE
        do_install
    fi

    echo
    if is_cdrom_install; then
        HELP_ROOT=$COMMON_ROOT
        echo "On-line help for this product is available on the CD-ROM in"
        echo "HTML format in the directory:  help"
    else
        HELP_ROOT=$MEDIA_ROOT
    fi
    CLIC=x
    while [ "$CLIC" != "Y" ] && [ "$CLIC" != "y" ] && [ "$CLIC" != "N" ] && [ "$CLIC" != "n" ]
    do
        echo "Do you wish to install a copy of the on-line help files"
        echo "onto your machine (Y/N)?"
        read CLIC
    done
    if [ "$CLIC" != "n" ] && [ "$CLIC" != "N" ]
    then
        PRODUCT_NAME="Adaptive Server Anywhere On-Line Help"
        PKG="help"
        TARFILE_NAME="files.tar"
        DESC=""
        DEST_DIR=
        while [ "_$DEST_DIR" = "_" ]
        do
    	    DEF_INST_DIR="$ASA_DEST_DIR"
    	    echo
    	    echo "Please enter the installation directory (default $DEF_INST_DIR):"
	    read DEST_DIR

	    if [ "_$DEST_DIR" = "_" ]
	    then
	        DEST_DIR=$DEF_INST_DIR
	    fi

	    if [  -f "$DEST_DIR" ]
	    then
	        echo "$DEST_DIR exists but is not a directory."
	        DEST_DIR=
	    elif [ -d "$DEST_DIR" ]
	    then
	        echo
	        echo "NOTE: $DEST_DIR exists -- files will be overwritten"
	        echo
	    else
	        if mkdir -p "$DEST_DIR" 2>/dev/null
	        then
		    true;
	        else
		    echo "Cannot create directory $DEST_DIR"
		    DEST_DIR=
	        fi
	    fi
        done
        echo
        echo "Installing $PRODUCT_NAME $DESC to $DEST_DIR"
        echo 
        cd $DEST_DIR
        if $MEDIA_ROOT/bin/gtar xv -U -T $HELP_ROOT/$PKG/files -f $HELP_ROOT/$TARFILE_NAME
        then
	    cd $MEDIA_ROOT
        else
	    cd $MEDIA_ROOT
    	    echo 
	    "WARNING: Installation of $PRODUCT_NAME failed or is incomplete."
	    echo 
	    exit 1
	fi
    fi
}

is_cdrom_install() {
    COMMON_ROOT=$MEDIA_ROOT/../common
    if [ -d "$COMMON_ROOT" ]
    then
	true
    else
	false
    fi
}

is_reg_invalid() {
    INSTALL_ASA=false
    INSTALL_REPAGENT=false
    INSTALL_SSREMOTE=false
    INSTALL_CTLIB=false
    case "`echo $REG_KEY | cut -c5`" in
        "B"|"D"|"F"|"H" )
            ;;
        "J"|"L"|"N"|"Q" )
            INSTALL_ASA=true
            ;;
        "K"|"M"|"P"|"R" )
            INSTALL_ASA=true
            ;;
    esac
    case "`echo $REG_KEY | cut -c6`" in
        "E"|"F"|"G"|"H" )
            INSTALL_SSREMOTE=true
            ;;
        "J"|"K"|"L"|"M" )
            INSTALL_REPAGENT=true
            ;;
        "N"|"P"|"Q"|"R" )
            INSTALL_SSREMOTE=true
            INSTALL_REPAGENT=true
            ;;
    esac
    if [ $OS_TYPE = "SunOS_i386" ]; then
        if [ $INSTALL_REPAGENT = true ]; then
            INSTALL_REPAGENT=false
        fi
        if [ $INSTALL_SSREMOTE = true ]; then
            INSTALL_SSREMOTE=false
        fi
    fi
    if [ $INSTALL_REPAGENT = true ]
    then
        CLIC=x
        while [ "$CLIC" != "Y" ] && [ "$CLIC" != "y" ] && [ "$CLIC" != "N" ] && [ "$CLIC" != "n" ]
        do
            echo "Do you wish to install Replication Agent for ASA (Y/N) [default=Y]?"
            read CLIC
        done
        if [ "$CLIC" = "n" ] || [ "$CLIC" = "N" ]
        then
            INSTALL_REPAGENT=false
        fi
    fi
    if [ $INSTALL_SSREMOTE = true ]
    then
        CLIC=x
        while [ "$CLIC" != "Y" ] && [ "$CLIC" != "y" ] && [ "$CLIC" != "N" ] && [ "$CLIC" != "n" ]
        do
            echo "Do you wish to install SQL Remote for ASE (Y/N) [default=Y]?"
            read CLIC
        done
        if [ "$CLIC" = "n" ] || [ "$CLIC" = "N" ]
        then
            INSTALL_SSREMOTE=false
        fi
    fi
    case "`echo $REG_KEY | cut -c1`" in
        "A" )
            _PLATFORM="$OS_TYPE"
            ;;
        "B" )
            _PLATFORM="$OS_TYPE"
            ;;
        * )
            _PLATFORM="(none)"
            ;;
    esac

    if [ $_PLATFORM = $OS_TYPE ]
    then
        false
    else
        true
    fi
}

Check_OS()
{
    case "$OS_TYPE" in
	AIX)	OS_REL=`oslevel`
		OS_REL_COMP=`oslevel | sed 's?\.??' | sed 's?\.??'`

		OS_MIN_REL="4.2.0.0"
		OS_MIN_COMP="420.0"
		;;

	HP-UX)	OS_REL=`uname -r`
		OS_REL_COMP=`uname -r|sed 's?B.??'`

		OS_MIN_REL="11.00"
		OS_MIN_COMP="11.00"
		;;

	SunOS_sparc)	OS_REL=`uname -r`
		OS_REL_COMP=`echo $OS_REL |sed 's?\.??'`

		OS_MIN_REL="5.5"
		OS_MIN_COMP="55"
		;;

	SunOS_i386)	OS_REL=`uname -r`
		OS_REL_COMP=`echo $OS_REL |sed 's?\.??'`

		OS_MIN_REL="5.6"
		OS_MIN_COMP="56"
		;;
       Linux)  OS_REL=`uname -r`
               OS_REL_1=`echo $OS_REL | cut -d. -f,1`
               OS_REL_2=`echo $OS_REL | cut -d. -f,2`
               OS_REL_3=`echo $OS_REL | sed 's?\-.*??' | cut -d. -f,3`
               OS_REL_COMP=`expr $OS_REL_1 \* 1000 + $OS_REL_2 \* 100 + $OS_REL_3`

               OS_MIN_REL="2.0.34"
               OS_MIN_COMP="2034"
               ;;
 
       *)      echo "This O/S is not supported"

		exit 1
		;;
    esac			

    if [ "$OS_REL_COMP" -lt "$OS_MIN_COMP" ]
    then
	echo "Error: 
	Current  O/S release level: ${OS_REL}
	Required O/S release level: ${OS_MIN_REL}\n
	The current O/S level is less then required for running 
	$PACKAGE_NAME.  You will need to upgrade the 
	O/S before attempting to run this product.\n"
        echo "Setup will now terminate without installing $PACKAGE_NAME.";
    fi
    false
}

invalid_reg1() {
    cat <<-INVALID_REG1
	You have entered an invalid registration number.
	Please check your registration card, and re-enter your registration number.
INVALID_REG1
    read REG_KEY
}

invalid_reg2 () {
    cat <<-INVALID_REG2
	You have entered an invalid registration number.
	Please verify that you are properly licensed for this
	product before continuing.
INVALID_REG2
}

invalid_platform () {
    cat <<-INVALID_PLATFORM
	You have chosen to install this software"
	package on an invalid platform."
INVALID_PLATFORM
}

clear
cat <<-WELCOME
	Welcome to $PACKAGE_NAME Setup. 
	Setup will install $PACKAGE_NAME on your computer.

	WARNING: This software is protected by copyright law and international treaties.

	Unauthorized reproduction or distribution of this program, or any portion of it,
	may result in severe civil and criminal penalties, and will be prosecuted to
	the maximum extent possible under law.
	
	Press ENTER to continue
WELCOME

read INP
clear

cat <<-LICENSE
	IMPORTANT NOTICE.

	Before installing or using this software, please read the Sybase License
	Agreement included in this product package.

	THE ENCLOSED SOFTWARE IS PROVIDED SUBJECT TO THE TERMS OF THE ACCOMPANYING
	SYBASE LICENSE AGREEMENT.  You indicate your acceptance of such Sybase
	License Agreement by installing and using the enclosed software unless you
	have already agreed to license terms for this software by executing a
	separate written license agreement with Sybase or one of its subsidiaries
	or authorized resellers. 

	Sybase, Inc. 6475 Christie Avenue, Emeryville, CA 94608, USA



	Do you accept all the terms of the accompanying License Agreement?  If you
	choose No, setup will close.  To install $PACKAGE_NAME,
	you must accept this agreement.

	Press Y to accept or N to refuse
LICENSE

read ACCEPT_LICENSE
if test "$ACCEPT_LICENSE" = "N"  || ( test "$ACCEPT_LICENSE" != "y"  && test "$ACCEPT_LICENSE" != "Y" )
then
	echo "You have chosen to refuse the License Agreement.";
	echo "Setup will now terminate without installing $PACKAGE_NAME.";
	exit
fi

if [ "$OS_TYPE" != "Linux" ]
then
        echo "You have chosen to install this software package on an invalid platform."
        echo "Current  O/S: ${OS_TYPE}"
        echo "Required O/S: Linux"
        echo
        echo "Setup will now terminate without installing $PACKAGE_NAME.";
        exit
fi

Check_OS

clear
cat <<-REGISTRATION
	Please enter your registration number.
	It is the 21-digit number on your registration card.
REGISTRATION

read REG_KEY
if is_reg_invalid; then
    invalid_reg1;
    if is_reg_invalid; then
        invalid_reg2;
    fi
fi

INSTALL_SYBASECENTRAL=false
OVERWRITE_SYBASEDIR=false

if [ $INSTALL_REPAGENT = true ] || [ $INSTALL_SSREMOTE = true ]
then
    INSTALL_CTLIB=true
    get_syb_dest_dir
fi

if [ $INSTALL_ASA = false ] && [ $INSTALL_REPAGENT = false ] && [ $INSTALL_SSREMOTE = false ]
then
    get_package
else
    do_package_install
    finish_install
fi

if [ $MADE_NEW_SYBASE_DIR = true ]
then
    echo
    echo "Don't forget to set the SYBASE environment variable to"
    echo "$SYBASE in your profile."
fi
