#!/bin/sh
#
# Script to help untar packages from release media and
# run platform specific installation
#
#
# (c) Copyright 1994-2004 CA  and/or its subsidiaries. All Rights
# Reserved. Use by the United States Government is subject to
# RESTRICTED RIGHTS as set out in the license agreement.
#

[ `echo ".\c"` = '.\c' ] && echo() { builtin echo -e "$@"; }

Update_Agent_22()
{
AGENT_CFG=/opt/CA/BABcmagt/agent.cfg
grep "^\[22\]" ${AGENT_CFG} >/dev/null 2>&1
if [ $? -ne 0 ]; then
	return 0
fi

sed -e "s%^\[22\]%\[46\]%" $AGENT_CFG > $AGENT_CFG.$$ 2>/dev/null
cp $AGENT_CFG.$$ $AGENT_CFG 2>/dev/null
rm -f $AGENT_CFG.$$ 2>/dev/null
}

Update_Agent_36()
{
AGENT_CFG=/opt/CA/BABcmagt/agent.cfg
grep "^#UDP_BCAST_PORT" ${AGENT_CFG} >/dev/null 2>&1
if [ $? -eq 0 ]; then
	return 0
fi

sed "/^#UDP_PORT/a\\
#UDP_BCAST_PORT 41524" $AGENT_CFG > $AGENT_CFG.$$ 2>/dev/null
cp $AGENT_CFG.$$ $AGENT_CFG 2>/dev/null
rm -f $AGENT_CFG.$$ 2>/dev/null
}

# set execution mode of the script
#
MY_ECHO()
{
        TEMP_STRING_INSTALL=`echo $1|sed "s/TEMP_VARIABLE_INSTALL1/$2/"`
        if [ "X$3" != "X" ] ; then
        	TEMP_STRING_INSTALL1=`echo $TEMP_STRING_INSTALL|sed "s/TEMP_VARIABLE_INSTALL2/$3/"`
        else
        	TEMP_STRING_INSTALL1=${TEMP_STRING_INSTALL}
        fi
        echo $TEMP_STRING_INSTALL1
}
special_char_check()
{
	echo $1 |grep '\$' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\@' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\!' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\^' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\&' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\*' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\#' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\?' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\%' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\ ' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
	echo $1 |grep '\"' >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 1
	fi
}
GET_INSTALL_FLAG2()
{
	INSTALL_FLAG=0
	echo "$INST_MSG_183"
	read ANS
	case $ANS in
		y|Y|yes|YES)
			INSTALL_FLAG=1
			;;
		q|Q|quit|QUIT)
			echo $INST_MSG_60
			echo
			exit 128
			;;
		*)
			echo $INST_MSG_184
			echo
			GET_INSTALL_FLAG2
			;;
	esac
}
GET_INSTALL_FLAG()
{
	INSTALL_FLAG=0
	echo $INST_MSG_195
	read ANS
	case $ANS in
		y|Y|yes|YES)
			INSTALL_FLAG=1
			;;
		q|Q|quit|QUIT)
			echo
			echo $INST_MSG_60
			echo
			exit 128
			;;
		n|N|no|NO)
			;;
		*)
			echo $INST_MSG_184
			echo
			GET_INSTALL_FLAG
			;;
	esac
}
GET_INSTALL_FLAG_YN()
{
      INSTALL_FLAG=0
      echo $INST_MSG_212
      read ANS
      if [ "X${ANS}" = "X" ]; then
      	ANS="y"
      fi
      case $ANS in
              y|Y|yes|YES)
                      INSTALL_FLAG=1
                      ;;
              n|N|no|NO)
                      ;;
              *)
                      echo $INST_MSG_184
                      echo
                      GET_INSTALL_FLAG_YN
                      ;;
      esac
}

create_tmp_nlsfile()
{
	if [ ! -d /tmp ]  
	then
		mkdir -m 666 -p /tmp 2>/dev/null
	fi
	
	if [ -f ${TMP_NLSFILE} ] 
	then
		rm -f ${TMP_NLSFILE} 2>/dev/null
	fi
	
	NLS_DEPOT=${DEPOT}
	if [ -f ${PKG_LOCATION}/NLS/NLS.CFG ]
	then
		cp ${PKG_LOCATION}/NLS/NLS.CFG ${TMP_NLSFILE}
	else
		cp ${PKG_LOCATION}/nls/nls.cfg ${TMP_NLSFILE}
	fi
}
remove_tmp_nlsfile()
{
	if [ -f ${TMP_NLSFILE} ]
	then
		rm -f ${TMP_NLSFILE}
	fi
}

#function get_config is required be called before this function for setting required variables
lang_menu()
{
	OLD_NLS_LANG=$NLS_LANG
	if [ "$LANG" = "" ] 
	then
		LANG=C
	fi
	
	NLS_LOCALE=$LANG
        NLS_LANG=`$NLS_UTILITY_FILE -c $LANG  $NLSMAPFILE 2>/dev/null`
	if [  "$NLS_LANG" = "C" -a "$LC_CTYPE" != "" ]
	then
	        LC_CTYPE_TYPE=`$NLS_UTILITY_FILE -c $LC_CTYPE  $NLSMAPFILE 2>/dev/null`
	        if [ "$LC_CTYPE_TYPE" != "$NLS_LANG" ]
	        then
	                NLS_LANG=$LC_CTYPE_TYPE
	                NLS_LOCALE=$LC_CTYPE
	        fi
	fi
	
        #If install script detects one of the Chinese/Japanese locales included in our map file then
        #we should switch to Chinese/Japanese by default without going through the language selection menu.
        if [ "$NLS_LANG" = "sc" -o "$NLS_LANG" = "tc" -o  "$NLS_LANG" = "ja_euc" -o "$NLS_LANG" = "ja_sjis" ]
        then
                :
        else
		create_tmp_nlsfile
		
		${NLS_LIST_FILE} ${C_INSTALL_MESSAGES_PATH} ${TMP_NLSFILE} ${NLS_UTILITY_FILE} ${NLS_PATH} ${NLS_LOCALE}  $NLSMAPFILE
		
		NLS_LANG=`$NLS_UTILITY_FILE -g $TMP_NLSFILE "CA_NLS_LANG" 2>/dev/null`
                NLS_LOCALE=`$NLS_UTILITY_FILE -gl $TMP_NLSFILE "CA_NLS_LANG" 2>/dev/null`
		
		remove_tmp_nlsfile
	fi
}

read_nls()
{

		if [ "$UPPER_FLAG" = "TRUE" ] 
		then
			NLS_LIST_FILE=${PKG_LOCATION}/NLS/NLS_LIST
			NLS_UTILITY_FILE=${PKG_LOCATION}/NLS/NLS_UTILITY
			NLSCFGFILE=${PKG_LOCATION}/NLS/NLS.CFG
			NLSMAPFILE=${PKG_LOCATION}/NLS/NLS.MAP
		else
			NLS_LIST_FILE=${PKG_LOCATION}/nls/nls_list
			NLS_UTILITY_FILE=${PKG_LOCATION}/nls/nls_utility
			NLSCFGFILE=${PKG_LOCATION}/nls/nls.cfg	
			NLSMAPFILE=${PKG_LOCATION}/nls/nls.map
		fi
	
		if [ -f $NLSCFGFILE -a -x $NLS_UTILITY_FILE ]
		then
	
			NLS_LANG=`$NLS_UTILITY_FILE -g $NLSCFGFILE "CA_NLS_LANG" 2>/dev/null`
			NLS_LOCALE=`$NLS_UTILITY_FILE -gl $NLSCFGFILE "CA_NLS_LANG" 2>/dev/null`
		fi
			
}
set_msgpath()
{
		if [ "$NLS_LANG" = "" ] 
		then
			NLS_LANG=C
		fi
		
		if [ "$UPPER_FLAG" = "TRUE" ] 
		then
			UPPER_LANG=`echo $NLS_LANG | tr "[:lower:]" "[:upper:]" `
			NLS_PATH=${PKG_LOCATION}/NLS
			INSTALL_MESSAGES_PATH=$NLS_PATH/${UPPER_LANG}/INSTALL.MSG
			C_INSTALL_MESSAGES_PATH=${PKG_LOCATION}/NLS/C/INSTALL.MSG
			UPGRADE_MESSAGES_PATH=$NLS_PATH/${UPPER_LANG}/UPGRADE.MSG
			LIC_PATH=$NLS_PATH/${UPPER_LANG}/LICENSE.TXT
			INSTALL_NOTES=${PKG_LOCATION}/INSTALL.${UPPER_LANG}.TXT
			INSTALL_README=${PKG_LOCATION}/README.${UPPER_LANG}.TXT
			INSTALL_README_HTML=${PKG_LOCATION}/README.${UPPER_LANG}.HTML
					
		else
			NLS_PATH=${PKG_LOCATION}/nls
			INSTALL_MESSAGES_PATH=$NLS_PATH/${NLS_LANG}/install.msg
			C_INSTALL_MESSAGES_PATH=${PKG_LOCATION}/nls/C/install.msg
			UPGRADE_MESSAGES_PATH=$NLS_PATH/${NLS_LANG}/upgrade.msg
			LIC_PATH=$NLS_PATH/${NLS_LANG}/license.txt
			INSTALL_NOTES=${PKG_LOCATION}/install.${NLS_LANG}.txt
			INSTALL_README=${PKG_LOCATION}/readme.${NLS_LANG}.txt
			INSTALL_README_HTML=${PKG_LOCATION}/readme.${NLS_LANG}.html
		fi
}
get_config()
{
	if [ -f ${INSTALL_MESSAGES_PATH} ]
	then
		. ${INSTALL_MESSAGES_PATH}
		THE_LIC_FILE=${LIC_PATH}
	elif [ -f ${C_INSTALL_MESSAGES_PATH} ]; then
		. ${C_INSTALL_MESSAGES_PATH}
		THE_LIC_FILE=${NLS_PATH}/C/license.txt
		NLS_LANG="C"
		NLS_LOCALE="C"
	else
		echo "Can not locate the message file: ${INSTALL_MESSAGES_PATH}!"
		echo "Exiting..."
		exit 7
	fi

}
Installation_Initialize()
{
	INSTALL_DOC=""
	Portal_Server_Name=""
	License_Path=""
	LICENSE_CHOICE=""
	LIC_CHECK=""
	CAAGENT_INSTALLED_ALREADY="NO"
	RESPONSE_FILE=/tmp/install_bab.rsp
	REGR_MODE=0
	RESP_MODE=1
	SLNT_MODE=2
	SDO_MODE=3
	EXEC_MODE=0
        LIC_INSTALLED=0
        BEB_COMPONENTS_MIGRATION=0
        BAB_COMPONENTS_UPGRADE=0
	PROFILE_MODIFY=""
	AGENTS_AUTO_START=""
	if [ "$THISSCRIPT" = "install_response" ]
	then
	    EXEC_MODE=$RESP_MODE
	    /bin/rm $RESPONSE_FILE 2> /dev/null
	    touch $RESPONSE_FILE
	elif [ "$THISSCRIPT" = "install_silent" ]
	then
	    EXEC_MODE=$SLNT_MODE
	elif [ "$THISSCRIPT" = "install_sdo" ]
	then
	    EXEC_MODE=$SDO_MODE
	fi
	TMP_NLSFILE=/tmp/nls.cfg
	NLS_LANG=C
	NLS_INITIAL_LANG=""
	read_nls
	set_msgpath    
	if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
		lang_menu
	fi
	set_msgpath
	get_config
	if [ $EXEC_MODE -eq $REGR_MODE ]; then
		BK_LINE_FLAG="\r"
	else
		BK_LINE_FLAG="\n"
	fi
	
    if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ] ; then
	LOG_FILE=/tmp/BAB_SILENT_INSTALL.LOG
    	CHECK_PLATFORM >> ${LOG_FILE} 2>&1
    	check_root_account >> ${LOG_FILE} 2>&1
    else
	LOG_FILE=/tmp/BrightStorInstall`date '+%m%d%y-%H%M'.log`
    	CHECK_PLATFORM
    	check_root_account
    fi
	TMPFILENAME="/tmp/babsilentinstall.$$.log"
	
	BOLD=`tput bold 2>/dev/null`
	NORM=`tput rmso 2>/dev/null`
	
	SAVEMASK=`umask`
	umask 022
	
	PATH=/usr/sbin:/usr/bin:/bin:/etc:$PATH; export PATH
	UNTAR="/usr/bin/tar oxf"
	PID="BrightStor$$"
	LIC98_INSTALL=./install
	LIC98_D=license
if [ "$OS" = "SunOS" ]; then
	PKGADD="pkgadd -d"
	PKGINFO="pkginfo"
	PKGRM="pkgrm"
	AWK=nawk
elif [ "$OS" = "HP-UX" ]; then
	PKGADD="swinstall -x allow_incompatible=true -v -s"
	PKGINFO="swlist"
	PKGRM="swremove"
	AWK=awk
elif [ "$OS" = "AIX" ]; then
	PKGADD="installp -ac -d"
	PKGINFO="lslpp -L all"
	PKGRM="installp -u"
	AWK=awk
elif [ "$OS" = "OSF1" ]; then
	GREP=grep
	AWK=awk
	PKGADD="setld -l"
	PKGINFO="PKGINFO_OSF1"
	PKGRM="setld -d"
elif [ "$OS" = "FreeBSD" ]; then
	PKGADD="pkg_add"
	PKGINFO="pkg_info"
	PKGRM="pkg_delete"
	AWK=nawk
fi
	EGREP=egrep
	GREP=grep
	ECHO="echo"
	SPACE_ERR=0
	TEMP_CREATE=0
	
	# install script to be used only with Enterprise Edition
	# always unset CAIGLBL0000
	#
	unset CAIGLBL0000
	
	
#	if [ $EXEC_MODE -ne $SDO_MODE -a $EXEC_MODE -ne $SLNT_MODE ] ; then
#	fi
	AGPLTF=`dirname $PKG_LOCATION`
	TEMP2=`dirname $AGPLTF`
	TEMP1=`dirname $TEMP2`
	TEMP2=$TEMP1
	TEMP1=`basename $TEMP2`
	if [ "X$TEMP1" = "Xagents" \
             -o -f $PKG_LOCATION/.BrightStorARCserveAgtTru64 \
	     -o -f $PKG_LOCATION/.BrightStorARCserveAgtSolaris26 \
             -o -f $PKG_LOCATION/.BrightStorARCserveAgtSolaris \
	     -o -f $PKG_LOCATION/.BrightStorARCserveAgtHP11 \
             -o -f $PKG_LOCATION/.BrightStorARCserveAgtAix \
	     -o -f $PKG_LOCATION/.BrightStorARCserveAgtS86 \
             -o -f $PKG_LOCATION/.BrightStorARCserveAgtS86.amd64 \
             -o -f $PKG_LOCATION/.BrightStorARCserveAgtFreeBSD ]; then
		AGENTS_DIR=1
	    	AGENT_PLATFORM=`basename $AGPLTF`
	    	case $PLATFORM in
                hp11)        
                        if [ "X$AGENT_PLATFORM" != "Xhp" -a ! -f $PKG_LOCATION/.BrightStorARCserveAgtHP11 ]; then
                        	AGENT_INST_OK="NO"
                        fi
                        ;;
                aix)
                        if [ "X$AGENT_PLATFORM" != "Xaix" -a ! -f $PKG_LOCATION/.BrightStorARCserveAgtAix ]; then
                        	AGENT_INST_OK="NO"
                        fi
                        ;;
                osf)
                        if [ "X$AGENT_PLATFORM" != "Xtru64" -a ! -f $PKG_LOCATION/.BrightStorARCserveAgtTru64 ]; then
                        	AGENT_INST_OK="NO"
                        fi
                        ;;
                sun5)
                        if [ "X$AGENT_PLATFORM" != "Xsolaris" -a ! -f $PKG_LOCATION/.BrightStorARCserveAgtSolaris ]; then
                        	AGENT_INST_OK="NO"
                        fi
                        ;;
                sun5-6)
                        if [ "X$AGENT_PLATFORM" != "Xsolaris26" -a ! -f $PKG_LOCATION/.BrightStorARCserveAgtSolaris26 ]; then
                        	AGENT_INST_OK="NO"
                        fi
                        ;;
                s86)
                        if [ "X$AGENT_PLATFORM" != "Xs86" -a ! -f $PKG_LOCATION/.BrightStorARCserveAgtS86 ]; then
                        	AGENT_INST_OK="NO"
                        fi
                        ;;
                s86-amd64)
                        if [ "X$AGENT_PLATFORM" != "Xs86-amd64" -a ! -f $PKG_LOCATION/.BrightStorARCserveAgtS86.amd64 ]; then
                        	AGENT_INST_OK="NO"
                        fi
                        ;;
                freebsd)
                        if [ "X$AGENT_PLATFORM" != "Xfreebsd" -a ! -f $PKG_LOCATION/.BrightStorARCserveAgtFreeBSD ]; then
                        	AGENT_INST_OK="NO"
                        fi
                        ;;
                *)
               		AGENT_INST_OK="NO"
                	;;
                esac
		if [ "X$AGENT_INST_OK" = "XNO" -a $OS_TOO_NEW -ne 1 ]; then
		        echo "${INST_MSG_73}${NORM}"
		        echo
		        echo "         ${INST_MSG_60}"
		        echo
		        exit 1
		fi
	else
		AGENTS_DIR=0
		if [ "X${PLATFORM}" = "Xsun5-6" ];then
		        echo "${INST_MSG_73}${NORM}"
		        echo
		        echo "         ${INST_MSG_60}"
		        echo
		        exit 1
		fi
		
		if [ ! -f ${PKG_LOCATION}/${THE_OSFLAG} -a $EXEC_MODE -ne $SDO_MODE ]; then
		        echo "${INST_MSG_73}${NORM}"
		        echo
		        echo "         ${INST_MSG_60}"
		        echo
		        exit 1
		fi
	fi
    if [ $EXEC_MODE -eq $SDO_MODE -o $AGENTS_DIR -eq 1 ]
    then
	BEB_PKG=${PKG_LOCATION}/babux.tar
	AGNTUX_PKG=${PKG_LOCATION}/babagtux.tar
	CMAGT_PKG=${PKG_LOCATION}/babcmagt.tar
	DRO_PKG=${PKG_LOCATION}/babdr.tar
	NAS_PKG=${PKG_LOCATION}/babnas.tar
	SAN_PKG=${PKG_LOCATION}/babsan.tar
	ORA8_AGENT_PKG=${PKG_LOCATION}/babora.tar
	IBM_PKG=${PKG_LOCATION}/babibm.tar
	NLO_PKG=${PKG_LOCATION}/babstk.tar
	NOTES_AGENT_PKG=${PKG_LOCATION}/babnotes.tar
	SAP_AGENT_PKG=${PKG_LOCATION}/babsap.tar
	BAIM_AGENT_PKG=${PKG_LOCATION}/babbaim.tar
	SYBASE_AGENT_PKG=${PKG_LOCATION}/babsybse.tar
	INFMX_AGENT_PKG=${PKG_LOCATION}/babinfmx.tar
	LIC98_PKG=${PKG_LOCATION}/lic98.tar
	PROD_CODE=${PKG_LOCATION}/prod_codes.txt
	DB2_AGENT_PKG=${PKG_LOCATION}/babdb2.tar
	ING_AGENT_PKG=${PKG_LOCATION}/babingres.tar
	IGATEWAY_FILE=${PKG_LOCATION}/iGateway.sh
	ISPONSOR_FILE=${PKG_LOCATION}/iSponsor.sh
    else
	BEB_PKG=${PKG_LOCATION}/bab/babux.tar
	AGNTUX_PKG=${PKG_LOCATION}/babagent/babagtux.tar
	CMAGT_PKG=${PKG_LOCATION}/cmagent/babcmagt.tar
	DRO_PKG=${PKG_LOCATION}/dro/babdr.tar
	NAS_PKG=${PKG_LOCATION}/nas/babnas.tar
	SAN_PKG=${PKG_LOCATION}/san/babsan.tar
	ORA8_AGENT_PKG=${PKG_LOCATION}/oracle/babora.tar
	IBM_PKG=${PKG_LOCATION}/ibmlib/babibm.tar
	NLO_PKG=${PKG_LOCATION}/nlo/babstk.tar
	NOTES_AGENT_PKG=${PKG_LOCATION}/notes/babnotes.tar
	SAP_AGENT_PKG=${PKG_LOCATION}/sap/babsap.tar
	BAIM_AGENT_PKG=${PKG_LOCATION}/sap/babbaim.tar
	SYBASE_AGENT_PKG=${PKG_LOCATION}/sybase/babsybse.tar
	INFMX_AGENT_PKG=${PKG_LOCATION}/infmx/babinfmx.tar
	LIC98_PKG=${PKG_LOCATION}/license/lic98.tar
	PROD_CODE=${PKG_LOCATION}/license/prod_codes.txt
	DB2_AGENT_PKG=${PKG_LOCATION}/db2/babdb2.tar
	ING_AGENT_PKG=${PKG_LOCATION}/ingres/babingres.tar
	IGATEWAY_FILE=${PKG_LOCATION}/bab/iGateway.sh
	ISPONSOR_FILE=${PKG_LOCATION}/bab/iSponsor.sh
    fi
#	LICENSE_FILE=${PKG_LOCATION}/license.txt
#	INSTALL_NOTES=${PKG_LOCATION}/install.txt
#	INSTALL_README=${PKG_LOCATION}/readme.txt
#	SILENT_INSTALL_NOTES=${PKG_LOCATION}/silent_install.txt

	#Added for Tru64 C++ Runtime Library
	CPATCH="${PKG_LOCATION}/compaq/CXXREDIST650V14.tar"
	CKIT="CXXREDIST650.kit"
	
	# Package variable name
	#
if [ "${OS}" = "OSF1" ]; then
	MGR_PKG=BEBMGR10
	SVR_PKG=BEBSVR10
	CMG_PKG=BABCMAGT
	AGT_PKG=BABAGNTUX
	NLO_N_PKG=BEBNLO10
	SAN_N_PKG=BEBSAN10
	ORA8_PKG=BABORA12
	INFMX_PKG=BABINFMX
else
	MGR_PKG=BABmgr
	SVR_PKG=BABsvr
	DRO_N_PKG=BABdr
	NAS_N_PKG=BABnas
	NLO_N_PKG=BABstklib
	SAN_N_PKG=BABsan
	IBM_N_PKG=BABibmlib
	INFMX_PKG=BABinfmx
	SYBASE_PKG=BABsybase
	DB2_PKG=BABdb2
	ING_PKG=BABing
	GATEWAY_N_PKG=iGateway
	CMG_PKG=BABcmagt
	AGT_PKG=BABagntux
	ORA8_PKG=BABora
	SAP_PKG=BABsap
	BAIM_PKG=BABbaim
	NOTES_PKG=BABlotus
fi
	
	INSTALL_CHOICE=
	BEB_GROUP_CREATED=0
	UAGENT_GROUP_CREATED=0
	CFGAGTAUTOSTRTSTOP=0
	HEADERFLAG=0
	
	DIALTMPFILE="/tmp/.BrightStorInstallDial.$$"
	export DIALTMPFILE
	
	# variables that keep track of install paths
	#
	BEB_PKG_DIR_NEW=0
	AGNTUX_PKG_DIR_NEW=0
	ORA8_PKG_DIR_NEW=0
	SYBASE_PKG_DIR_NEW=0
	INFMX_PKG_DIR_NEW=0
	SAP_PKG_DIR_NEW=0
	NOTES_PKG_DIR_NEW=0
	DB2_PKG_DIR_NEW=0
	ING_PKG_DIR_NEW=0
	
	BEB_PKG_DIR=/opt/CA
	BEB_PKG_DIR_DEFAULT=/opt/CA
	BEB_BASE_INSTALLED=0
	BEB_BASE_REQUESTED=0
	AGNTUX_PKG_DIR=/opt/CA
	ORA8_PKG_DIR=/opt/CA
	NOTES_PKG_DIR=/opt/CA
	SAP_PKG_DIR=/opt/CA
	SYBASE_PKG_DIR=/opt/CA
	INFMX_PKG_DIR=/opt/CA
	DB2_PKG_DIR=/opt/CA
	ING_PKG_DIR=/opt/CA
	BEB_CMG_REQUESTED=0
	BEB_NEW_INSTALLED=0
	AUTO_SET_ENV=1
	
if [ "$OS" = "AIX" ]; then
	#for english nls config
	#
	CAAGENT_HOME=/opt/CA/BABcmagt
	TMPFILE=${CAAGENT_HOME}/nls/nls.cfg.tmp.$$
	CFGFILE=${CAAGENT_HOME}/nls/nls.cfg
	ASAGLANG=C
	LANGUAGE="English"
fi

	FILESYS_COUNT=1
#	set -A FILESYS_GROUP
#	set -A SPACE_GROUP
#	set -A CHOICE_ARR

        SERVER_INSTALL="NO"
        UAGENT_INSTALL="NO"
        SAN_INSTALL="NO"
        IBM_INSTALL="NO"
        DRO_INSTALL="NO"
        NAS_INSTALL="NO"
        NLO_INSTALL="NO"
        ORA8_INSTALL="NO"
        SYBASE_INSTALL="NO"
        INFMX_INSTALL="NO"
        SAP_INSTALL="NO"
        NOTES_INSTALL="NO"
        DB2_INSTALL="NO"
        ING_INSTALL="NO"

}

PKGINFO_OSF1_BEB()
{
    setld -i | ${AWK} '/BEB/ && $2 == "installed" { print $1 }'
}
PKGINFO_OSF1()
{
    setld -i | ${AWK} '/BAB/ && $2 == "installed" { print $1 }'
}
prompt_response_location()
{
  echo "${INST_MSG_1}"
  echo "${BOLD}${INST_MSG_2}${NORM}" 
  echo "${INST_MSG_3} \c"
  read RES_LOC
  if [ "$RES_LOC" != "" ];
  then
    RESPONSE_FILE=$RES_LOC
  fi
    
  if [ -f $RESPONSE_FILE ] ;
  then
    /bin/rm $RESPONSE_FILE 2> /dev/null
  fi
    
  touch $RESPONSE_FILE
}

CLEANUP_DIR()
{
	if [ "$BEB_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $BEB_PKG_DIR_NEW > /dev/null 2>&1
	fi
	if [ "$AGNTUX_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $AGNTUX_PKG_DIR_NEW > /dev/null 2>&1
	fi
	if [ "$ORA8_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $ORA8_PKG_DIR_NEW > /dev/null 2>&1
	fi
	if [ "$SYBASE_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $SYBASE_PKG_DIR_NEW > /dev/null 2>&1
	fi
	if [ "$INFMX_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $INFMX_PKG_DIR_NEW > /dev/null 2>&1
	fi
	if [ "$SAP_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $SAP_PKG_DIR_NEW > /dev/null 2>&1
	fi
	if [ "$NOTES_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $NOTES_PKG_DIR_NEW > /dev/null 2>&1
	fi
	if [ "$DB2_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $DB2_PKG_DIR_NEW > /dev/null 2>&1
	fi
	if [ "$ING_PKG_DIR_NEW" = "1" ]; then
	  rm -rf $ING_PKG_DIR_NEW > /dev/null 2>&1
	fi
}

CREATE_DIR()
{
if [ "$OS" = "SunOS" ]; then
  if [ "$PLATFORM" = "s86" ]; then
  	PKG_LIST="$AGNTUX_PKG_DIR $ORA8_PKG_DIR"
  else
	PKG_LIST="$BEB_PKG_DIR $AGNTUX_PKG_DIR $ORA8_PKG_DIR $SYBASE_PKG_DIR $INFMX_PKG_DIR $SAP_PKG_DIR $NOTES_PKG_DIR $DB2_PKG_DIR $ING_PKG_DIR"
  fi
elif [ "$OS" = "HP-UX" ]; then
	PKG_LIST="$BEB_PKG_DIR $AGNTUX_PKG_DIR $ORA8_PKG_DIR $SYBASE_PKG_DIR $INFMX_PKG_DIR $SAP_PKG_DIR $NOTES_PKG_DIR $ING_PKG_DIR"
elif [ "$OS" = "AIX" ]; then
	PKG_LIST="$BEB_PKG_DIR $AGNTUX_PKG_DIR $ORA8_PKG_DIR $INFMX_PKG_DIR $SAP_PKG_DIR $NOTES_PKG_DIR $DB2_PKG_DIR $ING_PKG_DIR"
elif [ "$OS" = "OSF1" ]; then
	PKG_LIST="$AGNTUX_PKG_DIR"
elif [ "$OS" = "FreeBSD" ]; then
	PKG_LIST="$AGNTUX_PKG_DIR"
fi
	for pkg_dir in $PKG_LIST
	do
	  if [ ! -d $pkg_dir ]; then
	    mkdir -p $pkg_dir > /dev/null 2>&1
	    if [ $? -ne 0 ]
	    then
	      echo "${INST_MSG_4} $pkg_dir !"
	      CLEANUP_DIR
	      CLEANUP 16
	    fi
	  fi
	done
}

# clean up
#
CLEANUP()
{
    status=$1
    status_str="${INST_MSG_237}"
    PRNTCFGTASK=0

    cd $HOMEDIR
    if [ -d $TMPDIR/$PID ]
    then
        rm -rf $TMPDIR/$PID
    fi
    if [ -f $YES_FILE ]; then
    	rm -f $YES_FILE 2> /dev/null
    fi

    if [ $TEMP_CREATE -eq 1 ]; then
        rm -rf $TMPDIR
    fi
    if [ "$status" = "" -o "$status" != "0" ]
    then
        status_str="${INST_MSG_238}"
    elif [ ! -s ${LOG_FILE} ]
    then
        status_str="${INST_MSG_239}"
    else
        PRNTCFGTASK=1
    fi
          
    if [ $EXEC_MODE -eq $RESP_MODE ]
    then
        exit
    fi
    dialCleanup

	echo
    echo "###########################################################################"
    echo " ${INST_MSG_5}                                  ==> [ $status_str ]" 

         if [ "${PRNTCFGTASK}" -eq 1 ]
         then
                 Print_Cfg_Task
         fi

    if [ -s ${LOG_FILE} ]; then
      echo " ${INST_MSG_6}                      ==> [ ${LOG_FILE} ]"
    fi
    echo "###########################################################################"
	echo
        if [ $status -eq 0 -a $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ]; then
	        if [ "${HEADERFLAG}" -eq 1 ]; then
                  getyn "${INST_MSG_193}" 1
                  if [ $? -eq 1 ]
                  then
			view_readme
                  fi
		fi
		echo
		if [ "X${BASE_SUC_INST}" != "XNO" ]; then
		    if [ $BEBSVR_OLD_INSTALLED -eq 1 -o $SERVER_NEED_UPGRADE -eq 1 ]; then
			getyn "${INST_MSG_41}" 1
	                if [ $? -eq 1 ]; then
				if [ -x $BAB_HOME/sbin/cstart ]; then
					$BAB_HOME/sbin/cstart
					$BAB_HOME/bin/alterDB >$BAB_HOME/dbase/alterDB.log 2>&1
				else
					echo "${INST_MSG_42}"
				fi
	                else
	                	echo "${INST_MSG_235}"
	                fi
	            fi
		fi
		echo "$INST_MSG_180"
		echo
	fi
    exit $status
}

view_readme()
{
        if [ ! -f $INSTALL_README ]; then
        	INSTALL_README=${PKG_LOCATION}/readme.txt
        fi
        more $INSTALL_README
}
Print_Header ()
{
        if [ "${HEADERFLAG}" -eq 0 ]
        then
                HEADERFLAG=1
	      	if [ $AGENTS_DIR -ne 1 ]; then
	           	echo 
	      		echo "$INST_MSG_7" 
		fi
        fi
}

Print_Trailer ()
{
        if [ "${HEADERFLAG}" -eq 1 ]
        then
           echo
           echo "${INST_MSG_8}"
           echo "${INST_MSG_9}"
        fi
}

# function to print configuration/setup tasks that need to be done
# after the installation is complete
Print_Cfg_Task ()
{
   if [ ${BEB_BASE_REQUESTED} -eq 1 -a "X${BASE_SUC_INST}" != "XNO" ]
        then
     if [ $BEBSVR_OLD_INSTALLED -ne 1 -a $SERVER_NEED_UPGRADE -ne 1 ]; then 
      Print_Header
      echo "    Server & Manager                          (BABsvr & BABmgr)==> [ ${INST_MSG_231} ]"
      echo "    Server & Manager                          (BABsvr & BABmgr)==> [ csetup ]"
     elif [ $BEBSVR_OLD_INSTALLED -eq 1 ]; then
      Print_Header
      echo "    Server & Manager                          (BABsvr & BABmgr)==> [ ${INST_MSG_231} ]"
      echo "    Server & Manager                          (BABsvr & BABmgr)==> [ migrateingres2.6 ]"
     fi
   fi
   if [ "${AGT_PKG}" = "BABagntux" -a "X${UAG_SUC_INST}" != "XNO" ]
        then
      Print_Header
#      	if [ $AGENTS_DIR -ne 1 ]; then
#      echo "    Client Agent for UNIX                     (BABagntux)      ==> [ NONE ]"
#   	fi
   fi
   if [ "${SAN_N_PKG}" = "BABsan" -a "X${SAN_SUC_INST}" != "XNO" ]
        then
	if [ $SAN_OLD_INSTALLED -eq 1 -o $SAN_NEED_UPGRADE -eq 1 ]; then
	      Print_Header
#	      echo "    Storage Area Network (SAN) Option         (BABsan)       ==> [ NONE ]"
	else
                Print_Header
      		echo "    Storage Area Network (SAN) Option         (BABsan)         ==> [ csetup ]"
        fi
   fi
   if [ "${IBM_N_PKG}" = "BABibmlib" -a "X${IBM_SUC_INST}" != "XNO" ]
        then
	if [ $IBM_OLD_INSTALLED -eq 1 -o $IBM_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#     		echo "    Enterprise Option for IBM3494             (BABibmlib)      ==> [ NONE ]"
	else
                Print_Header
      		echo "    Enterprise Option for IBM3494             (BABibmlib)      ==> [ csetup ]"
        fi
   fi
   if [ "${DRO_N_PKG}" = "BABdr" -a "X${DRO_SUC_INST}" != "XNO" ]
        then
	if [ $DRO_OLD_INSTALLED -eq 1 -o $DRO_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#      		echo "    Disaster Recovery Option                  (${DRO_N_PKG})          ==> [ NONE ]"
	else
                Print_Header
      		echo "    Disaster Recovery Option                  (${DRO_N_PKG})          ==> [ cadro_setup ]"
        fi
   fi
   if [ "${NAS_N_PKG}" = "BABnas" -a "X${NAS_SUC_INST}" != "XNO" ]
        then
	if [ $NAS_OLD_INSTALLED -eq 1 -o $NAS_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#		echo "    NDMP NAS Option                           (BABnas)         ==> [ NONE ]"
	else
                Print_Header
		echo "    NDMP NAS Option                           (BABnas)         ==> [ csetup ]"
        fi
   fi
   if [ "${NLO_N_PKG}" = "BABstklib" -a "X${NLO_SUC_INST}" != "XNO" ]
        then
	if [ $NLO_OLD_INSTALLED -eq 1 -o $NLO_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#      		echo "    Enterprise Option for StorageTek ACSLS    (BABstklib)      ==> [ NONE ]"
	else
                Print_Header
      		echo "    Enterprise Option for StorageTek ACSLS    (BABstklib)      ==> [ csetup ]"
        fi
   fi
   if [ "${ORA8_PKG}" = "BABora" -a "X${ORA_SUC_INST}" != "XNO" ]
        then
	if [ $ORA_OLD_INSTALLED -eq 1 -o $ORA8_OLD_INSTALLED -eq 1 -o $ORA8SL_OLD_INSTALLED -eq 1 \
		-o $TIMEFINDER_OLD_INSTALLED -eq 1 -o $ORA_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#      		echo "    Backup Agent for Oracle                   (BABora)         ==> [ NONE ]"
	else
                Print_Header
      		echo "    Backup Agent for Oracle                   (BABora)         ==> [ orasetup ]"
        fi
   fi
   if [ "${SYBASE_PKG}" = "BABsybase" -a "X${SYB_SUC_INST}" != "XNO" ]
        then
	if [ $SYB_NEED_UPGRADE -eq 1 -o $SYBASE_OLD_INSTALLED -eq 1 ]; then
                Print_Header
#      		echo "    Backup Agent for Sybase                   (BABsybase)      ==> [ NONE ]"
	else
                Print_Header
      		echo "    Backup Agent for Sybase                   (BABsybase)      ==> [ sybsetup ]"
        fi
   fi
   if [ "${INFMX_PKG}" = "BABinfmx" -a "X${INF_SUC_INST}" != "XNO" ]
        then
	if [ $INFMX_OLD_INSTALLED -eq 1 -o $INFMX_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#      		echo "    Backup Agent for Informix                 (BABinfmx)       ==> [ NONE ]"
	else
                Print_Header
      		echo "    Backup Agent for Informix                 (BABinfmx)       ==> [ infmxsetup ]"
        fi
   fi
   if [ "${SAP_PKG}" = "BABsap" -a "X${SAP_SUC_INST}" != "XNO" ]
        then
	if [ $SAP_OLD_INSTALLED -eq 1 -o $SAP_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#      		echo "    Enterprise Option for SAP R/3 for Oracle  (BABsap)         ==> [ NONE ]"
	else
                Print_Header
      		echo "    Enterprise Option for SAP R/3 for Oracle  (BABsap)         ==> [ sapsetup ]"
        fi
   fi
   if [ "${NOTES_PKG}" = "BABlotus" -a "X${NOTE_SUC_INST}" != "XNO" ]
        then
	if [ $NOTES_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#      		echo "    Backup Agent for Lotus Domino             (BABlotus)       ==> [ lotussetup ]"
	else
                Print_Header
      		echo "    Backup Agent for Lotus Domino             (BABlotus)       ==> [ lotussetup ]"
        fi
   fi
   if [ "${DB2_PKG}" = "BABdb2" -a "X${DB2_SUC_INST}" != "XNO" ]
        then
	if [ $DB2_OLD_INSTALLED -eq 1 -o $DB2_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#      		echo "    Enterprise Option for DB2 UDB             (BABdb2)         ==> [ NONE ]"
	else
                Print_Header
      		echo "    Enterprise Option for DB2 UDB             (BABdb2)         ==> [ casdb2setup ]"
        fi
   fi
   if [ "${ING_PKG}" = "BABing" -a "X${ING_SUC_INST}" != "XNO" ]
        then
	if [ $ING_OLD_INSTALLED -eq 1 -o $ING_NEED_UPGRADE -eq 1 ]; then
                Print_Header
#      		echo "    Enterprise Option for Advantage Ingres    (BABing)         ==> [ NONE ]"
	else
                Print_Header
      		echo "    Enterprise Option for Advantage Ingres    (BABing)         ==> [ ingsetup ]"
        fi
   fi
   if [ "${NAS_N_PKG}" = "BABnas" -a "X${NAS_SUC_INST}" != "XNO" ]
        then
	if [ $NAS_OLD_INSTALLED -eq 1 ]; then
                Print_Header
		echo "${INST_MSG_233}"
        fi
   fi

  if [ "$LICENSE_CHOICE" = "1" ]; then
    echo
    echo "${INST_MSG_225}"
  elif [ "$LICENSE_CHOICE" = "4" ]; then
    echo
    echo "${INST_MSG_230}"
  fi
   Print_Trailer
}

# Function writes the UAG_LANG variable to $UAGENT_HOME/nls/nls.cfg
#
Modify_Nls_Cfg()
{
    if [ "${LANGUAGE}" != "English" ]
    then
        return
    fi

    $AWK '/^[ \t]*\#/ { print; next; }
    {
        if (match($1,"UAG_LANG")) { 
            print $1, "'$ASAGLANG'" 
        } else { 
            print; 
        }
    }' $CFGFILE > $TMPFILE

    mv $TMPFILE $CFGFILE
    chmod 644 $CFGFILE
    chown bin:bin $CFGFILE
    /opt/CA/BABcmagt/caagentsetup >> ${LOG_FILE} 2>&1
}


# Verify if required run time libraries are installed on host system
#
Check_Platform()
{
    tmp_file=/tmp/runtime_libs
    chd_list='xlC.rte|xlC.aix43.rte|xlC.msg.en_US.rte'
    $PKGINFO | $EGREP $chd_list > $tmp_file
    level=`oslevel`
    case $level in
        4.3.2.*)
            pkg_count=`cat $tmp_file | $GREP "5......" | wc -l`
            if [ $pkg_count -eq 3 ]; then
                return
            fi
            echo "    ${INST_MSG_10} $level"
            echo "    ${INST_MSG_11}"
            echo "    ${INST_MSG_12} http://techsupport.services.ibm.com/server/fixes"
            printf "    ${INST_MSG_13}" "IY17981" "IY20437"
            echo "    ${INST_MSG_14}"
            echo "    xlC.rte.5.0.2.0"
            echo "    xlC.aix43.rte.5.0.2.0"
            echo "    xlC.msg.en_US.rte.5.0.2.0"

            while [ true ]
            do
                echo
              if [ $EXEC_MODE -eq $REGR_MODE ]
              then
                echo "${INST_MSG_15} \c"
                read y_or_n
              else
                y_or_n="n"
              fi
                case $y_or_n in
                    Y|y|Yes|yes) break ;;
                    N|n|No|no)   CLEANUP 17 ;;
                    "")          break ;;
                    *)           echo "${INST_MSG_16}" ;;
                esac
            done
            ;;
    esac
    rm -f $tmp_file 2> /dev/null
}

# function to get required space for target FS
#
Get_Space()
{
    tmp=""
    tmp2=""
    module=$1
    check_dir=$2
    found=0

    if [ ! -d "${check_dir}" ]
    then
        #Try to get the base dir that would exist  
        #Exit when you find a valid dir or reach . or reach ""  
        while [ 1 ]
        do
            tmpdir=`dirname $check_dir`
            check_dir=$tmpdir
            if [ -d "${tmpdir}" -o "${tmpdir}" = "." -o -z "{tmpdir}" ]
            then
                break
            fi
        done
    fi

    case $module in
        BASE) space=400 ;;
        DRO)  space=3 ;;
        NAS)  space=4 ;;
        SAN)  space=4 ;;
        NLO)  space=5 ;;
        UAG)  space=15 ;;
        ORA)  space=17 ;;
        SAP)  space=15 ;;
        NOT)  space=15 ;;
        INF)  space=22 ;;
        IBM)  space=15 ;;
        SYB)  space=22 ;;
        DB2)  space=20 ;;
        ING)  space=20 ;;
    esac

    # Want to be sure we pick up the newer awk
if [ "$OS" = "SunOS" -o "$OS" = "OSF1" -o "$OS" = "FreeBSD" ]; then
    filesys=`df -k $check_dir | $AWK '{ if (NR == 2) { print $6 } }'`
elif [ "$OS" = "HP-UX" ]; then
    filesys=`df -k $check_dir | $AWK '{ if (NR == 1){ print $1 } }'`
elif [ "$OS" = "AIX" ]; then
    filesys=`df -k $check_dir | $AWK '{ if (NR == 2){ print $7 } }'` 
fi
    if [ "$FILESYS_COUNT" = "1" ]; then
        # add the first entry to the array
        eval FILESYS_GROUP_${FILESYS_COUNT}=$filesys
        eval SPACE_GROUP_${FILESYS_COUNT}=$space

        FILESYS_COUNT=$(($FILESYS_COUNT+1))
    else
        # check if the file system is already in the array
        cnt=1
        while [ "$cnt" -lt "$FILESYS_COUNT" ]
        do
            eval tmp=\$FILESYS_GROUP_${cnt}
            if [ "${tmp}" = "$filesys" ]; then
                eval tmp2=\$SPACE_GROUP_${cnt}
                eval SPACE_GROUP_${cnt}=$((${tmp2}+$space))
                found=1
                break
            fi
            cnt=$(($cnt+1))
        done
        # if not in the array, add it as a new entry
        if [ "$found" = "0" ]; then
             eval FILESYS_GROUP_${FILESYS_COUNT}=$filesys
             eval SPACE_GROUP_${FILESYS_COUNT}=$space

            FILESYS_COUNT=$(($FILESYS_COUNT+1))
        fi
    fi
    if [ "$module" = "BASE" ]; then
       	FILESYS_BASE=$filesys
    fi
}


Verify_Space()
{
    tmp=""
    tmp2=""
    VCOUNT=1
    while [ "$VCOUNT" -lt "$FILESYS_COUNT" ]
     do
        eval tmp=\$FILESYS_GROUP_${VCOUNT}
        echo ""
        printf "%-42s" "${INST_MSG_17} ${tmp}"
        echo "                    ==> [\c"

        ok=0
if [ "$OS" = "SunOS" -o "$OS" = "OSF1" -o "$OS" = "FreeBSD" ]; then
        available=`df -k ${tmp} | $AWK '{ if (NR == 2) { print $4 } }'`
elif [ "$OS" = "HP-UX" ]; then
        available=`df -b ${tmp} | $AWK '{ if (NR == 1){ print $(NF-2) } }'`
elif [ "$OS" = "AIX" ]; then
        available=`df -k ${tmp} | $AWK '{ if (NR == 2){ print $3 } }'`
fi
        if [ "$available" != "-" ]; then
            available=`expr $available / 1024` >/dev/null ## break it down to megs
            eval tmp2=\$SPACE_GROUP_${VCOUNT}
            if [ "$available" -ge "${tmp2}" ]
            then
                ok=1
            fi
        fi

        if [ "$ok" = "1" ]
        then
            echo " ${INST_MSG_20} ]"
        else
            echo " ${INST_MSG_21} ]"
            printf "${INST_MSG_22}\n" "${tmp2}" "${tmp}"
#            echo "         ${INST_MSG_22}  ."
            echo "         ${INST_MSG_23}"
            CLEANUP 15
        fi
        VCOUNT=$(($VCOUNT+1))
    done
}


# Reset menu choices (works as a flag if a package should be installed or not)
#
Init_Choices()
{
    BEB_BASE_REQUESTED=0
    AGT_PKG=
    DRO_N_PKG=
    NAS_N_PKG=
    NLO_N_PKG= 
    SAN_N_PKG=
    ORA8_PKG=
    IBM_N_PKG=
    INFMX_PKG=
    SAP_PKG=
    SYBASE_PKG=
    NOTES_PKG=
    DB2_PKG=
    ING_PKG=
}


# Display package selection menu 
#
Display_Package_Menu()
{
    Init_Choices

if [ $AGENTS_DIR -eq 1 ]; then
   if [ "X${PLATFORM}" = "Xsun5-6" -o "X${PLATFORM}" = "Xs86-amd64" -o "X${PLATFORM}" = "Xfreebsd" -o ! -f $ORA8_AGENT_PKG ]; then
     INSTALL_CHOICE="1"
   else
    echo
	echo $INST_MSG_185
	echo
    echo "#############################################################################"
    echo "$INST_MSG_25"
    echo "#############################################################################"
    echo "#  1. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
    echo "#  2. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
    echo "#                                                                           "
    echo "$INST_MSG_38"
    echo "#############################################################################"

    echo
    if [ $BEB_COMPONENTS_MIGRATION -eq 1 ]; then
    	echo ${INST_MSG_39a}
    elif [ $BAB_COMPONENTS_UPGRADE -eq 1 ]; then
    	echo ${INST_MSG_39b}
    else
    	echo ${INST_MSG_39c}
    fi
    read INSTALL_CHOICE
    if [ "$INSTALL_CHOICE" = "" -a $BEB_COMPONENTS_MIGRATION -ne 1 -a $BAB_COMPONENTS_UPGRADE -ne 1 ]; then
	INSTALL_CHOICE="1"
    fi
    if [ "$INSTALL_CHOICE" = "0" ]; then
        echo
        echo "$INST_MSG_60"
	echo
	exit 0
    fi
    if [ "$INSTALL_CHOICE" = "all" ]; then
   	INSTALL_CHOICE="1,2"
    fi
  fi

elif [ "$LICENSE_CHOICE" = "2" ]; then
    echo "#############################################################################"
    echo "$INST_MSG_25"
    echo "#############################################################################"
    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
    echo "#                                                                           "
    echo "$INST_MSG_38"
    echo "#############################################################################"
    echo
    echo "$INST_MSG_220 \c"
    read INSTALL_CHOICE
    if [ "$INSTALL_CHOICE" = "0" ]; then
        echo
        echo "$INST_MSG_60"
	echo
	exit 0
    fi
else
    echo
	echo $INST_MSG_185
	echo
    echo "#############################################################################"
    echo "$INST_MSG_25"
    echo "#############################################################################"

	if [ "$OS" = "SunOS" ]; then
	  if [ "$PLATFORM" = "s86" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
	  else
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option       (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX Disaster Recovery Option                (BABdr)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX NDMP NAS Option                         (BABnas)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                  (BABlotus)"
		    echo "#  8. BrightStor ARCserve Backup for UNIX Enterprise Option for DB2 UDB           (BABdb2)"
		elif [ "X${NLS_LANG}" = "Xsc" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option       (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX Disaster Recovery Option                (BABdr)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX NDMP NAS Option                         (BABnas)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Agent for Sybase                        (BABsybase)"
		    echo "#  8. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                  (BABlotus)"
		    echo "#  9. BrightStor ARCserve Backup for UNIX Enterprise Option for DB2 UDB           (BABdb2)"
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option       (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX Disaster Recovery Option                (BABdr)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX NDMP NAS Option                         (BABnas)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                  (BABlotus)"
		    echo "#  8. BrightStor ARCserve Backup for UNIX Enterprise Option for DB2 UDB           (BABdb2)"
		    echo "#  9. BrightStor ARCserve Backup for UNIX Enterprise Option for Advantage Ingres  (BABing)"
		else
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option       (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX Enterprise Option for IBM3494           (BABibmlib)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX Disaster Recovery Option                (BABdr)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX NDMP NAS Option                         (BABnas)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Enterprise Option for StorageTek ACSLS  (BABstklib)"
		    echo "#  8. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
		    echo "#  9. BrightStor ARCserve Backup for UNIX Agent for Sybase                        (BABsybase)"
		    echo "# 10. BrightStor ARCserve Backup for UNIX Agent for Informix                      (BABinfmx)"
		    echo "# 11. BrightStor ARCserve Backup for UNIX Enterprise Option for SAP R/3 for Oracle(BABsap)"
		    echo "# 12. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                  (BABlotus)"
		    echo "# 13. BrightStor ARCserve Backup for UNIX Enterprise Option for DB2 UDB           (BABdb2)"
		    echo "# 14. BrightStor ARCserve Backup for UNIX Enterprise Option for Advantage Ingres  (BABing)"
		fi
	  fi
	elif [ "$OS" = "HP-UX" ]; then
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option       (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX NDMP NAS Option                         (BABnas)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                  (BABlotus)"
		elif [ "X${NLS_LANG}" = "Xsc" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option       (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX NDMP NAS Option                         (BABnas)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Agent for Sybase                        (BABsybase)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                  (BABlotus)"
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option       (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX NDMP NAS Option                         (BABnas)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                  (BABlotus)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Enterprise Option for Advantage Ingres  (BABing)"
		else
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                        (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                            (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option       (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX Enterprise Option for IBM3494           (BABibmlib)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX NDMP NAS Option                         (BABnas)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Enterprise Option for StorageTek ACSLS  (BABstklib)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Agent for Oracle                        (BABora)"
		    echo "#  8. BrightStor ARCserve Backup for UNIX Agent for Sybase                        (BABsybase)"
		    echo "#  9. BrightStor ARCserve Backup for UNIX Agent for Informix                      (BABinfmx)"
		    echo "# 10. BrightStor ARCserve Backup for UNIX Enterprise Option for SAP R/3 for Oracle(BABsap)"
		    echo "# 11. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                  (BABlotus)"
		    echo "# 12. BrightStor ARCserve Backup for UNIX Enterprise Option for Advantage Ingres  (BABing)"
		fi
	elif [ "$OS" = "AIX" ]; then
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" -o "X${NLS_LANG}" = "Xsc" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                         (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                             (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option        (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX Agent for Oracle                         (BABora)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                   (BABlotus)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Enterprise Option for DB2 UDB            (BABdb2)"
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                         (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                             (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option        (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX Agent for Oracle                         (BABora)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                   (BABlotus)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Enterprise Option for DB2 UDB            (BABdb2)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Enterprise Option for Advantage Ingres   (BABing)"
		else
		    echo "#  1. BrightStor ARCserve Backup for UNIX Server & Manager                         (BABsvr & BABmgr)"
		    echo "#  2. BrightStor ARCserve Backup for UNIX Client Agent                             (BABagntux)"
		    echo "#  3. BrightStor ARCserve Backup for UNIX Storage Area Network (SAN) Option        (BABsan)"
		    echo "#  4. BrightStor ARCserve Backup for UNIX Enterprise Option for IBM3494            (BABibmlib)"
		    echo "#  5. BrightStor ARCserve Backup for UNIX Enterprise Option for StorageTek ACSLS   (BABstklib)"
		    echo "#  6. BrightStor ARCserve Backup for UNIX Agent for Oracle                         (BABora)"
		    echo "#  7. BrightStor ARCserve Backup for UNIX Agent for Informix                       (BABinfmx)"
		    echo "#  8. BrightStor ARCserve Backup for UNIX Enterprise Option for SAP R/3 for Oracle (BABsap)"
		    echo "#  9. BrightStor ARCserve Backup for UNIX Agent for Lotus Domino                   (BABlotus)"
		    echo "# 10. BrightStor ARCserve Backup for UNIX Enterprise Option for DB2 UDB            (BABdb2)"
		    echo "# 11. BrightStor ARCserve Backup for UNIX Enterprise Option for Advantage Ingres   (BABing)"
		fi
	fi
    echo "#                                                                           "
    echo "$INST_MSG_38"
    echo "#############################################################################"

    echo
    if [ $BEB_COMPONENTS_MIGRATION -eq 1 ]; then
    	echo ${INST_MSG_39a}
    elif [ $BAB_COMPONENTS_UPGRADE -eq 1 ]; then
    	echo ${INST_MSG_39b}
    else
    	echo ${INST_MSG_39}
    fi
    read INSTALL_CHOICE
  if [ "$OS" = "SunOS" -a "$PLATFORM" != "s86" -o "$OS" = "HP-UX" -o "$OS" = "AIX" ]; then
    if [ "$INSTALL_CHOICE" = "" -a $BEB_COMPONENTS_MIGRATION -ne 1 -a $BAB_COMPONENTS_UPGRADE -ne 1 ]; then
	INSTALL_CHOICE="1,2"
    fi
  fi

    if [ "$INSTALL_CHOICE" = "0" ]; then
        echo
        echo "$INST_MSG_60"
	echo
	exit 0
    fi
    if [ "$INSTALL_CHOICE" = "all" ]; then
	if [ "$OS" = "SunOS" ]; then
	  if [ "$PLATFORM" = "s86" ]; then
	  	INSTALL_CHOICE="1,2"
	  else
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6,7,8"
		elif [ "X${NLS_LANG}" = "Xsc" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6,7,8,9"
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6,7,8,9"
		else
			INSTALL_CHOICE="1,2,3,4,5,6,7,8,9,10,11,12,13,14"
		fi
	  fi
	elif [ "$OS" = "HP-UX" ]; then
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6"
		elif [ "X${NLS_LANG}" = "Xsc" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6,7"
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6,7"
		else
			INSTALL_CHOICE="1,2,3,4,5,6,7,8,9,10,11,12"
		fi
	elif [ "$OS" = "AIX" ]; then
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6"
		elif [ "X${NLS_LANG}" = "Xsc" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6,7"
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
			INSTALL_CHOICE="1,2,3,4,5,6,7"
		else
			INSTALL_CHOICE="1,2,3,4,5,6,7,8,9,10,11"
		fi
	fi
    fi
fi
}

# Initialize choice array
#
Initialize_Choice_Arr()
{
    index=0
	if [ "$OS" = "SunOS" ]; then
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				choice_max=9
		elif [ "X${NLS_LANG}" = "Xsc" ]; then
				choice_max=10
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				choice_max=10
		else
				choice_max=15
		fi
	elif [ "$OS" = "HP-UX" ]; then
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				choice_max=7
		elif [ "X${NLS_LANG}" = "Xsc" ]; then
				choice_max=8
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				choice_max=8
		else
				choice_max=13
		fi
	elif [ "$OS" = "AIX" ]; then
		if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				choice_max=7
		elif [ "X${NLS_LANG}" = "Xsc" ]; then
				choice_max=8
		elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				choice_max=8
		else
				choice_max=12
		fi
	elif [ "$OS" = "OSF1" ]; then
	choice_max=8
	elif [ "$OS" = "FreeBSD" ]; then
		choice_max=1
	fi

    #Possible 15 different user choices
    while [ ${index} -lt ${choice_max} ]
    do
#       CHOICE_ARR[$index]=0
       index=`expr $index + 1`
    done
}

# Display and process user package selection
#
Process_Package_Menu_Silent()
{
        if [ $EXEC_MODE -eq $SLNT_MODE ]; then
    		Process_Package_Migrate
        fi
	if [ "$UAGENT_INSTALL" = "YES" -o "$SYBASE_INSTALL" = "YES" -o "$INFMX_INSTALL" = "YES" -o "$SAP_INSTALL" = "YES" -o "$NOTES_INSTALL" = "YES" -o "$DB2_INSTALL" = "YES" -o "$ING_INSTALL" = "YES" -o "$SERVER_INSTALL" = "YES" -o "$ORA8_INSTALL" = "YES" ]; then
            	BEB_CMG_REQUESTED=1
	fi
}

Process_Package_Menu()
{
    choice_err=1
    if [ $EXEC_MODE -eq $REGR_MODE ]; then
    	Process_Package_Migrate
    fi
    while [ $choice_err -eq 1 ]
    do
        Display_Package_Menu
        Initialize_Choice_Arr
        if [ "X${INSTALL_CHOICE}" != "X" ]; then
        	num_choices=`echo $INSTALL_CHOICE | awk -F, '{print NF}'`
        else
        	num_choices=0
        fi
        choice_counter=1
        choice_err=0

	if [ "X${INSTALL_CHOICE}" != "X" ]; then
	      if [ "$LICENSE_CHOICE" = "2" ]; then
	          case $INSTALL_CHOICE in
	            1)
	                SVR_SELECTED=1
	                AGT_SELECTED=1
	                BEB_CMG_REQUESTED=1
	                selected_1=1
	                break
	                ;;
	            *)  choice_err=1
	                echo "${INST_MSG_16}"
	                ;;
	          esac
	      else
	
	        while [ $choice_counter -le $num_choices ]
	        do
	            choice_id=`echo $INSTALL_CHOICE | cut -d',' -f$choice_counter`
	
	            expr "$choice_id" + 1 >/dev/null 2>&1
	            if [ $? -ge 2 ]
	            then
	              choice_err=1
	              echo "${INST_MSG_16}"
	              break
	            fi
	            #Check for duplicate choice entries
#	            if [ "${CHOICE_ARR[$choice_id]}" -eq 1 ]
#	            then
#	               choice_err=1
#	               echo "${INST_MSG_42}"
#	               break
#	            else
#                       :
#	               CHOICE_ARR[$choice_id]=1
#	            fi
	
if [ $AGENTS_DIR -eq 1 ]; then
	            case $choice_id in
	                1)
				AGT_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
	                2)
				ORA8_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
	                *)  choice_err=1
	                    echo "${INST_MSG_16}"
	                    ;;
	            esac
else
	if [ "$OS" = "SunOS" ]; then
	  if [ "$PLATFORM" = "s86" ]; then
	            case $choice_id in
	                1)
				AGT_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
	                2)
				ORA8_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
	                *)  choice_err=1
	                    echo "${INST_MSG_16}"
	                    ;;
	            esac
	  else
	            case $choice_id in
	                1)
				SVR_SELECTED=1
				AGT_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    	selected_1=1
	                    ;;
	                2)
				AGT_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
			3)
				SAN_SELECTED=1
	                    ;;
			4)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				DRO_SELECTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				DRO_SELECTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				DRO_SELECTED=1
else
				IBM_SELECTED=1
fi
	                    ;;
			5)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				NAS_SELECTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				NAS_SELECTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				NAS_SELECTED=1
else
				DRO_SELECTED=1
fi
	                    ;;
			6)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				ORA8_SELECTED=1
		                BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				ORA8_SELECTED=1
		                BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				ORA8_SELECTED=1
		                BEB_CMG_REQUESTED=1
else
				NAS_SELECTED=1
fi
	                    ;;
			7)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				SYBASE_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
else
				NLO_SELECTED=1
fi
	                    ;;
	                8)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				DB2_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				DB2_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
else
				ORA8_SELECTED=1
		                BEB_CMG_REQUESTED=1
fi
	                    ;;
			9)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				DB2_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				ING_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
else
				SYBASE_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			10)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				INFMX_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			11)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				SAP_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			12)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
fi
	                    ;;
			13)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				DB2_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			14)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				ING_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
	                *)  choice_err=1
	                    echo "${INST_MSG_16}"
	                    ;;
	            esac
	          fi
	elif [ "$OS" = "HP-UX" ]; then
	            case $choice_id in
	                1)
				SVR_SELECTED=1
	 			AGT_SELECTED=1
	                   	BEB_CMG_REQUESTED=1
	                    	selected_1=1
	                    ;;
	                2)
				AGT_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
			3)
				SAN_SELECTED=1
	                    ;;
			4)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				NAS_SELECTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				NAS_SELECTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				NAS_SELECTED=1
else
				IBM_SELECTED=1
fi
	                    ;;
			5)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
	                    ORA8_SELECTED=1
	                    BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
	                    ORA8_SELECTED=1
	                    BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
	                    ORA8_SELECTED=1
	                    BEB_CMG_REQUESTED=1
else
				NAS_SELECTED=1
fi
	                    ;;
			6)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				SYBASE_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
else
				NLO_SELECTED=1
fi
	                    ;;
	                7)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				ING_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
else
	                    ORA8_SELECTED=1
	                    BEB_CMG_REQUESTED=1
fi
	                    ;;
			8)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				SYBASE_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			9)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				INFMX_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			10)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				SAP_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			11)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
fi
	                    ;;
			12)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				ING_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
	                *)  choice_err=1
	                    echo "${INST_MSG_16}"
	                    ;;
	            esac
	elif [ "$OS" = "AIX" ]; then
	            case $choice_id in
	                1)
				SVR_SELECTED=1
				AGT_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    	selected_1=1
	                    ;;
	                2)
				AGT_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
			3)
				SAN_SELECTED=1
	                    ;;
			4)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				ORA8_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				ORA8_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				ORA8_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
else
				IBM_SELECTED=1
fi
	                    ;;
			5)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
else
				NLO_SELECTED=1
fi
	                    ;;
			6)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
				DB2_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsc" ]; then
				DB2_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				DB2_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
else
				ORA8_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			7)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
				ING_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
else
				INFMX_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			8)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				SAP_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			9)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				NOTES_SELECTED=1
		                BEB_CMG_REQUESTED=1
fi
	                    ;;
			10)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				DB2_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
			11)
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsc" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
		                choice_err=1
		                echo "${INST_MSG_16}"
else
				ING_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
fi
	                    ;;
	                *)  choice_err=1
	                    echo "${INST_MSG_16}"
	                    ;;
	            esac
	elif [ "$OS" = "OSF1" ]; then
	            case $choice_id in
	                1)
				AGT_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
	                2)
				ORA8_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
	                3)
				INFMX_SELECTED=1
	                    	BEB_CMG_REQUESTED=1
	                    ;;
	                *)  choice_err=1
	                    echo "${INST_MSG_16}"
	                    ;;
	            esac
	fi
fi
	            choice_counter=`expr $choice_counter + 1 `
	
	        done 
	      fi
	fi
    done
}


# Create a server pkg response file
#
Create_Server_Package_Response()
{
    pkg_name=$1
    svr_dir=`pkgparam $pkg_name CAS_HOME 2> /dev/null`
    if [ -z "$svr_dir" ]
    then
        printf "${INST_MSG_166}" "$pkg_name"
        CLEANUP 6
    fi
    svr_dir=`dirname $svr_dir`
    echo "CAS_HOME='$svr_dir'/BrightStorARCserve" > ${TMPDIR}/${PID}/${SVR_PKG}.pkgask
}


Test_Link()
{
if [ "$OS" = "AIX" ]; then
    link_name=$1
#    if [ -f $link_name -o -d $link_name ]
#    then
#        echo
#        echo "${INST_MSG_43}"
#        echo "${INST_MSG_44} ${link_name}"
#        echo "${INST_MSG_45}"
#        CLEANUP 17
#    fi
fi
}

# Create a pkg response file
#
Create_Package_Response()
{
    pkg_name=$1
    var_name=$2
    ins_dir_name=$3
    sub_dir_name=$4
    echo "$var_name='$ins_dir_name'/$sub_dir_name" > ${TMPDIR}/${PID}/${pkg_name}.pkgask
}


# Ask user for path where the package needs to be installed
#
Get_Package_Path_Migrate()
{
    case $pkg_name in
      $SVR_PKG)
	if [ $BEBSVR_OLD_INSTALLED -eq 1 -o $SERVER_NEED_UPGRADE -eq 1 ]; then
		pkg_dir=${BEB_OLD_PKG_DIR}
		PRODUCT_INSTALLED=1
	fi
        ;;
      $AGT_PKG)
	if [ $UAGENT_OLD_INSTALLED -eq 1 -o $UAG_NEED_UPGRADE -eq 1 ]; then
		pkg_dir=${UAGENT_OLD_PKG_DIR}
		PRODUCT_INSTALLED=1
	fi
        ;;
      $ORA8_PKG)
	if [ $ORA_OLD_INSTALLED -eq 1 -o $ORA_NEED_UPGRADE -eq 1 -o $TIMEFINDER_OLD_INSTALLED -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${ORA_OLD_PKG_DIR}
	elif [ $ORA8_OLD_INSTALLED -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${ORA8_OLD_PKG_DIR}
	elif [ $ORA8SL_OLD_INSTALLED -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${ORA8SL_OLD_PKG_DIR}
	fi
        ;;
      $SYBASE_PKG)
	if [ $SYBASE_OLD_INSTALLED -eq 1 -o $SYB_NEED_UPGRADE -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${SYBASE_OLD_PKG_DIR}
	fi
        ;;
      $INFMX_PKG)
	if [ $INFMX_OLD_INSTALLED -eq 1 -o $INFMX_NEED_UPGRADE -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${INFMX_OLD_PKG_DIR}
	fi
        ;;
      $SAP_PKG)
	if [ $SAP_OLD_INSTALLED -eq 1 -o $SAP_NEED_UPGRADE -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${SAP_OLD_PKG_DIR}
	fi
        ;;
      $NOTES_PKG)
	if [ $NOTES_OLD_INSTALLED -eq 1 -o $NOTES_NEED_UPGRADE -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${NOTES_OLD_PKG_DIR}
	fi
        ;;
      $DB2_PKG)
	if [ $DB2_OLD_INSTALLED -eq 1 -o $DB2_NEED_UPGRADE -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${DB2_OLD_PKG_DIR}
	fi
        ;;
      $ING_PKG)
	if [ $ING_OLD_INSTALLED -eq 1 -o $ING_NEED_UPGRADE -eq 1 ]; then
		PRODUCT_INSTALLED=1
		pkg_dir=${ING_OLD_PKG_DIR}
	fi
        ;;
    esac
}
Get_Package_Path()
{
    pkg_name=$1
    default_path=$2
    if [ -z "$pkg_name" -o -z "$default_path" ]
    then 
        return 
    fi    
	PRODUCT_INSTALLED=0
	Get_Package_Path_Migrate

	if [ $PRODUCT_INSTALLED -ne 1 ]; then
	
	    choice_err=1
	
	    while [ $choice_err -eq 1 ]
	    do
	        choice_err=0
	        if [ "$pkg_name" = "$SVR_PKG" ]; then
	          printf "$INST_MSG_46" "$SVR_PKG" "$MGR_PKG" "$default_path"
	        else
	          printf "$INST_MSG_47" "$pkg_name" "$default_path"
	        fi
	        read pkg_dir
	        if [ "${pkg_dir}X" = "X" ]
	        then
	            pkg_dir=$default_path
	        else
	            if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ]; then
	              absolute_path=`echo $pkg_dir | grep "^/"`
	              if [ "$absolute_path" = "" ]; then
	                echo "${INST_MSG_48}"
	                choice_err=1
	                continue
	              fi
	              special_char_check $pkg_dir
	              if [ $? -ne 0 ]; then
	                echo "${INST_MSG_207}"
	                choice_err=1
	                continue
	              fi
	            fi
	            if [ $EXEC_MODE -ne $RESP_MODE ]; then
	              pkg_dir_check=$pkg_dir
	    	      if [ ! -d "${pkg_dir_check}" ]
	    	      then
	                #Try to get the base dir that would exist  
	                while [ 1 ]
	                do
	                  tmpdir=`dirname $pkg_dir_check`
	                  pkg_dir_check=$tmpdir
	                  if [ -d "${pkg_dir_check}" ]
	                  then
	                    break
	                  fi
	                done
	              fi
	              if [ ! -w $pkg_dir_check ]; then
	                if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ]; then
	                  printf "${INST_MSG_49}" "$pkg_name"
	                  choice_err=1
	                  continue
	                else
	                  printf "${INST_MSG_49}" "$pkg_name"
	                  CLEANUP 20
	                fi
	              fi
	            fi
	        fi
	
	    done
	else
	        if [ "${pkg_dir}X" = "X" ]
	        then
	            pkg_dir=$default_path
	        fi
	fi
	Get_Package_Path_Post
}

Get_Package_Path_Silent()
{
    pkg_name=$1
    default_path=$2
    if [ -z "$pkg_name" -o -z "$default_path" ]
    then 
        return 
    fi    
    PRODUCT_INSTALLED=0
    Get_Package_Path_Migrate
    
    if [ $PRODUCT_INSTALLED -ne 1 ]; then
    
            case $pkg_name in
              $SVR_PKG)
		pkg_dir=${SERVER_INSTALL_PATH}
                ;;
              $AGT_PKG)
		pkg_dir=${UAGENT_INSTALL_PATH}
                ;;
              $ORA8_PKG)
		pkg_dir=${ORA8_INSTALL_PATH}
                ;;
              $SYBASE_PKG)
		pkg_dir=${SYBASE_INSTALL_PATH}
                ;;
              $INFMX_PKG)
		pkg_dir=${INFMX_INSTALL_PATH}
                ;;
              $SAP_PKG)
		pkg_dir=${SAP_INSTALL_PATH}
                ;;
              $NOTES_PKG)
		pkg_dir=${NOTES_INSTALL_PATH}
                ;;
              $DB2_PKG)
		pkg_dir=${DB2_INSTALL_PATH}
                ;;
              $ING_PKG)
		pkg_dir=${ING_INSTALL_PATH}
                ;;
            esac
        if [ "${pkg_dir}X" = "X" ]
        then
            	pkg_dir=$default_path
        else
            if [ $EXEC_MODE -ne $RESP_MODE ]; then
              pkg_dir_check=$pkg_dir
    	      if [ ! -d "${pkg_dir_check}" ]
    	      then
                #Try to get the base dir that would exist  
                while [ 1 ]
                do
                  tmpdir=`dirname $pkg_dir_check`
                  pkg_dir_check=$tmpdir
                  if [ -d "${pkg_dir_check}" ]
                  then
                    break
                  fi
                done
              fi
              if [ ! -w $pkg_dir_check ]; then
                  printf "${INST_MSG_49}" "$pkg_name"
                  CLEANUP 20
              fi
            fi
        fi
    else
	        if [ "${pkg_dir}X" = "X" ]
	        then
	            pkg_dir=$default_path
	        fi
    fi
	Get_Package_Path_Post

}
Get_Package_Path_Post()
{
        if [ ! -d $pkg_dir ]
        then
            case $pkg_name in
              $SVR_PKG)
                BEB_PKG_DIR_NEW=1
                ;;
              $AGT_PKG)
                AGNTUX_PKG_DIR_NEW=1
                ;;
              $ORA8_PKG)
                ORA8_PKG_DIR_NEW=1
                ;;
              $SYBASE_PKG)
                SYBASE_PKG_DIR_NEW=1
                ;;
              $INFMX_PKG)
                INFMX_PKG_DIR_NEW=1
                ;;
              $SAP_PKG)
                SAP_PKG_DIR_NEW=1
                ;;
              $NOTES_PKG)
                NOTES_PKG_DIR_NEW=1
                ;;
              $DB2_PKG)
                DB2_PKG_DIR_NEW=1
                ;;
              $ING_PKG)
                ING_PKG_DIR_NEW=1
                ;;
            esac
        fi

    case $pkg_name in
        $SVR_PKG)
            BEB_PKG_DIR=$pkg_dir
            ;;
        $AGT_PKG)
            AGNTUX_PKG_DIR=$pkg_dir
            ;;
        $ORA8_PKG)
            ORA8_PKG_DIR=$pkg_dir
            ;;
        $NOTES_PKG)
            NOTES_PKG_DIR=$pkg_dir
            ;;
        $SAP_PKG)
            SAP_PKG_DIR=$pkg_dir
            ;;
        $SYBASE_PKG)
            SYBASE_PKG_DIR=$pkg_dir
            ;;
        $INFMX_PKG)
            INFMX_PKG_DIR=$pkg_dir
            ;;
        $DB2_PKG)
            DB2_PKG_DIR=$pkg_dir
            ;;
        $ING_PKG)
            ING_PKG_DIR=$pkg_dir
            ;;
    esac
}
# Common routine for performing selection specific commands
#
Perform_Selection_Switch_Silent()
{
    command=$1
       UAG_PROC_ALREADY=0
       BASE_PROCED=0
       NLO_PROCED=0
       ORA_PROCED=0
       SAN_PROCED=0
       DRO_PROCED=0
       NAS_PROCED=0
       IBM_PROCED=0
       NOTES_PROCED=0
       DB2_PROCED=0
       ING_PROCED=0
       SYBASE_PROCED=0
       SAP_PROCED=0
       INFMX_PROCED=0
    ca_agent_install=0
    

	if [ "$SERVER_INSTALL" = "YES" ] ; then
                Perform_Selection_Switch_BASE
	fi
	if [ "$UAGENT_INSTALL" = "YES" ] ; then
                Perform_Selection_Switch_UAG
	fi
	if [ "$SAN_INSTALL" = "YES" ] ; then
		Perform_Selection_Switch_SAN
	fi
	if [ "$IBM_INSTALL" = "YES" ] ; then
                Perform_Selection_Switch_IBM
	fi
	if [ "$DRO_INSTALL" = "YES" ] ; then
                Perform_Selection_Switch_DRO
	fi
	if [ "$NAS_INSTALL" = "YES" ] ; then
		Perform_Selection_Switch_NAS
	fi
	if [ "$NLO_INSTALL" = "YES" ] ; then
		Perform_Selection_Switch_NLO
	fi
	if [ "$ORA8_INSTALL" = "YES" ] ; then
		Perform_Selection_Switch_ORA8
	fi
	if [ "$SYBASE_INSTALL" = "YES" ] ; then
                Perform_Selection_Switch_SYBASE
	fi
	if [ "$INFMX_INSTALL" = "YES" ] ; then
                Perform_Selection_Switch_INFMX
	fi
	if [ "$SAP_INSTALL" = "YES" ] ; then
		Perform_Selection_Switch_SAP
	fi
	if [ "$NOTES_INSTALL" = "YES" ] ; then
		Perform_Selection_Switch_NOTES
	fi
	if [ "$DB2_INSTALL" = "YES" ] ; then
                Perform_Selection_Switch_DB2
	fi
	if [ "$ING_INSTALL" = "YES" ] ; then
                Perform_Selection_Switch_ING
	fi
}

Perform_Selection_Switch_BASE()
{
	if [ $BASE_PROCED -ne 1 ]; then
		BEB_BASE_REQUESTED=1
                if [ $command  = "echo" ]; then 
          if [ $BEBSVR_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Server & Manager                          (BABsvr & BABmgr)==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          elif [ $SERVER_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Server & Manager                          (BABsvr & BABmgr)==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          else
                    $command "  . ${INST_MSG_206} Server & Manager                          (BABsvr & BABmgr)==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
	  fi
if [ "$OS" = "SunOS" -o "$OS" = "AIX" -o "$OS" = "HP-UX" ]; then
                    $command "  . ${INST_MSG_206} iGateway                                  (iGateway)       ==> [ /opt/CA/igateway ]" 
                    $command "  . ${INST_MSG_206} iSponsor                                  (iSponsor)       ==> [ /opt/CA/igateway ]" 
fi
                elif  [ $command  = "Get_Space" -a $SERVER_ALREADY_INSTALLED -ne 1 ]; then 
                    $command BASE $BEB_PKG_DIR/BrightStorARCserve
                elif [ $SERVER_ALREADY_INSTALLED -ne 1 ]; then
                    $command $SVR_PKG $BEB_PKG_DIR 
                fi
                
		# From BEB11, to install base will also install uagent
		
		Perform_Selection_Switch_UAG 
	fi
}
Perform_Selection_Switch_UAG()
{
       		if [ $UAG_PROC_ALREADY -eq 0 ]; then
if [ "$OS" = "OSF1" ]; then
	            	AGT_PKG=BABAGNTUX
else
	            	AGT_PKG=BABagntux
fi
	                if [ $command  = "echo" ]; then 
          if [ $UAGENT_OLD_INSTALLED -eq 1 ]; then
	                    $command "  . ${INST_MSG_205} Client Agent for UNIX                     (${AGT_PKG})      ==> [ $AGNTUX_PKG_DIR/BABuagent ]"
          elif [ $UAG_NEED_UPGRADE -eq 1 ]; then
	                    $command "  . ${INST_MSG_215} Client Agent for UNIX                     (${AGT_PKG})      ==> [ $AGNTUX_PKG_DIR/BABuagent ]"
          else
	                    $command "  . ${INST_MSG_206} Client Agent for UNIX                     (${AGT_PKG})      ==> [ $AGNTUX_PKG_DIR/BABuagent ]"
	  fi
	                elif  [ $command  = "Get_Space" -a $UAG_ALREADY_INSTALLED -ne 1 ]; then 
	                    $command UAG $AGNTUX_PKG_DIR/BABuagent
	                elif [ $UAG_ALREADY_INSTALLED -ne 1 ]; then
	                    $command $AGT_PKG $AGNTUX_PKG_DIR 
	                fi
	                ca_agent_install=1 
	                UAG_PROC_ALREADY=1 
                fi
}
Perform_Selection_Switch_SAN()
{
	if [ $SAN_PROCED -ne 1 ]; then
                SAN_N_PKG=BABsan
                if [ $command  = "echo" ]; then  
          if [ $SAN_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Storage Area Network (SAN) Option         (${SAN_N_PKG})         ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          elif [ $SAN_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Storage Area Network (SAN) Option         (${SAN_N_PKG})         ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          else
                    $command "  . ${INST_MSG_206} Storage Area Network (SAN) Option         (${SAN_N_PKG})         ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
	  fi
                elif  [ $command  = "Get_Space" ]; then 
                    $command SAN $BEB_PKG_DIR/BrightStorARCserve
                fi
	fi
}

Perform_Selection_Switch_IBM()
{
	if [ $IBM_PROCED -ne 1 ]; then
                IBM_N_PKG=BABibmlib
                if [ $command  = "echo" ]; then  
          if [ $IBM_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Enterprise Option for IBM3494             (BABibmlib)      ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          elif [ $IBM_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Enterprise Option for IBM3494             (BABibmlib)      ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          else
                    $command "  . ${INST_MSG_206} Enterprise Option for IBM3494             (BABibmlib)      ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
	  fi
                elif  [ $command  = "Get_Space" ]; then 
                    $command IBM $BEB_PKG_DIR/BrightStorARCserve
                fi
	fi
}

Perform_Selection_Switch_DRO()
{
	if [ $DRO_PROCED -ne 1 ]; then
                DRO_N_PKG=BABdr
                if [ $command  = "echo" ]; then   
          if [ $DRO_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Disaster Recovery Option                  (${DRO_N_PKG})          ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          elif [ $DRO_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Disaster Recovery Option                  (${DRO_N_PKG})          ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          else
                    $command "  . ${INST_MSG_206} Disaster Recovery Option                  (${DRO_N_PKG})          ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
	  fi
                elif  [ $command  = "Get_Space" ]; then 
                    $command DRO $BEB_PKG_DIR/BrightStorARCserve
                fi
	fi
}

Perform_Selection_Switch_NAS()
{
	if [ $NAS_PROCED -ne 1 ]; then
                NAS_N_PKG=BABnas
                if [ $command  = "echo" ]; then   
          if [ $NAS_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} NDMP NAS Option                           (BABnas)         ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          elif [ $NAS_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} NDMP NAS Option                           (BABnas)         ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          else
                    $command "  . ${INST_MSG_206} NDMP NAS Option                           (BABnas)         ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
	  fi
                elif  [ $command  = "Get_Space" ]; then 
                    $command NAS $BEB_PKG_DIR/BrightStorARCserve
                fi
	fi
}

Perform_Selection_Switch_NLO()
{
	if [ $NLO_PROCED -ne 1 ]; then
                NLO_N_PKG=BABstklib
                if [ $command  = "echo" ]; then   
          if [ $NLO_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Enterprise Option for StorageTek ACSLS    (${NLO_N_PKG})      ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          elif [ $NLO_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Enterprise Option for StorageTek ACSLS    (${NLO_N_PKG})      ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
          else
                    $command "  . ${INST_MSG_206} Enterprise Option for StorageTek ACSLS    (${NLO_N_PKG})      ==> [ $BEB_PKG_DIR/BrightStorARCserve ]" 
	  fi
                elif  [ $command  = "Get_Space" ]; then 
                    $command NLO $BEB_PKG_DIR/BrightStorARCserve
                fi
	fi
}

Perform_Selection_Switch_ORA8()
{
if [ "$OS" != "OSF1" ]; then
  ORA8_SPACE="  "
else
  ORA8_SPACE=""
fi

	if [ $ORA_PROCED -ne 1 ]; then
if [ "$OS" = "OSF1" ]; then
	        ORA8_PKG=BABORA12
else
                ORA8_PKG=BABora
fi
		if [ "X${ORA8_PKG_DIR}" = "X" ]; then
			CAS_ENV_ORACLE_AGENT_HOME="/opt/CA/BABoraagt"
		elif [ "X${ORA8_PKG_DIR}" = "X/" ]; then
			CAS_ENV_ORACLE_AGENT_HOME="/BABoraagt"
		else
			CAS_ENV_ORACLE_AGENT_HOME="${ORA8_PKG_DIR}/BABoraagt"
		fi
                if [ $command  = "echo" ]; then   
          if [ $ORA_OLD_INSTALLED -eq 1 -o $ORA8SL_OLD_INSTALLED -eq 1 -o $TIMEFINDER_OLD_INSTALLED -eq 1 -o $ORA8_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Backup Agent for Oracle                   (${ORA8_PKG})$ORA8_SPACE       ==> [ $CAS_ENV_ORACLE_AGENT_HOME ]"
          elif [ $ORA_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Backup Agent for Oracle                   (${ORA8_PKG})$ORA8_SPACE       ==> [ $CAS_ENV_ORACLE_AGENT_HOME ]"
          else
                    $command "  . ${INST_MSG_206} Backup Agent for Oracle                   (${ORA8_PKG})$ORA8_SPACE       ==> [ $CAS_ENV_ORACLE_AGENT_HOME ]"
	  fi
                elif  [ $command  = "Get_Space" -a $ORA_ALREADY_INSTALLED -ne 1 ]; then 
                    $command ORA $CAS_ENV_ORACLE_AGENT_HOME
                elif [ $ORA_ALREADY_INSTALLED -ne 1 ]; then
                    $command $ORA8_PKG $ORA8_PKG_DIR 
                fi
                ca_agent_install=1 
	fi
}

Perform_Selection_Switch_SYBASE()
{
	if [ $SYBASE_PROCED -ne 1 ]; then
                SYBASE_PKG=BABsybase
		if [ "X${SYBASE_PKG_DIR}" = "X" ]; then
			CA_ENV_SYB_AGENT_HOME="/opt/CA/BABsybagt"
		elif [ "X${SYBASE_PKG_DIR}" = "X/" ]; then
			CA_ENV_SYB_AGENT_HOME="/BABsybagt"
		else
			CA_ENV_SYB_AGENT_HOME="${SYBASE_PKG_DIR}/BABsybagt"
		fi
                if [ $command  = "echo" ]; then   
          if [ $SYBASE_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Backup Agent for Sybase                   (BABsybase)      ==> [ $CA_ENV_SYB_AGENT_HOME ]"
          elif [ $SYB_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Backup Agent for Sybase                   (BABsybase)      ==> [ $CA_ENV_SYB_AGENT_HOME ]"
          else
                    $command "  . ${INST_MSG_206} Backup Agent for Sybase                   (BABsybase)      ==> [ $CA_ENV_SYB_AGENT_HOME ]"
	  fi
                elif  [ $command  = "Get_Space" -a $SYB_ALREADY_INSTALLED -ne 1 ]; then 
                    $command SYB $CA_ENV_SYB_AGENT_HOME
                elif [ $SYB_ALREADY_INSTALLED -ne 1 ]; then
                    $command $SYBASE_PKG $SYBASE_PKG_DIR 
                fi
                ca_agent_install=1 
	fi
}

Perform_Selection_Switch_INFMX()
{
	if [ $INFMX_PROCED -ne 1 ]; then
if [ "$OS" = "OSF1" ]; then
	        INFMX_PKG=BABINFMX
else
                INFMX_PKG=BABinfmx
fi
		if [ "X${INFMX_PKG_DIR}" = "X" ]; then
			CAINFMX_HOME="/opt/CA/BABinfmx"
		elif [ "X${INFMX_PKG_DIR}" = "X/" ]; then
			CAINFMX_HOME="/BABinfmx"
		else
			CAINFMX_HOME="${INFMX_PKG_DIR}/BABinfmx"
		fi
                if [ $command  = "echo" ]; then   
          if [ $INFMX_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Backup Agent for Informix                 (${INFMX_PKG})       ==> [ $CAINFMX_HOME ]"
          elif [ $INFMX_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Backup Agent for Informix                 (${INFMX_PKG})       ==> [ $CAINFMX_HOME ]"
          else
                    $command "  . ${INST_MSG_206} Backup Agent for Informix                 (${INFMX_PKG})       ==> [ $CAINFMX_HOME ]"
	  fi
                elif  [ $command  = "Get_Space" -a $INFMX_ALREADY_INSTALLED -ne 1 ]; then 
                    $command INF $CAINFMX_HOME
                elif [ $INFMX_ALREADY_INSTALLED -ne 1 ]; then
                    $command $INFMX_PKG $INFMX_PKG_DIR 
                fi
                ca_agent_install=1 
	fi
}

Perform_Selection_Switch_SAP()
{
	if [ $SAP_PROCED -ne 1 ]; then
                SAP_PKG=BABsap
                if [ $command  = "echo" ]; then   
          if [ $SAP_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Enterprise Option for SAP R/3 for Oracle  (${SAP_PKG})         ==> [ $SAP_PKG_DIR/BABsapagt ]"
          elif [ $SAP_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Enterprise Option for SAP R/3 for Oracle  (${SAP_PKG})         ==> [ $SAP_PKG_DIR/BABsapagt ]"
          else
                    $command "  . ${INST_MSG_206} Enterprise Option for SAP R/3 for Oracle  (${SAP_PKG})         ==> [ $SAP_PKG_DIR/BABsapagt ]"
	  fi
                    $command "  . ${INST_MSG_206} Backup Agent Integration Module           (${BAIM_PKG})        ==> [ $SAP_PKG_DIR/BABsapagt ]"
                elif  [ $command  = "Get_Space" -a $SAP_ALREADY_INSTALLED -ne 1 ]; then 
                    $command SAP $SAP_PKG_DIR/BABsapagt
                elif [ $SAP_ALREADY_INSTALLED -ne 1 ]; then
                    $command $SAP_PKG $SAP_PKG_DIR 
                fi
                ca_agent_install=1 
	fi
}
Perform_Selection_Switch_NOTES()
{
	if [ $NOTES_PROCED -ne 1 ]; then
                NOTES_PKG=BABlotus
                if [ $command  = "echo" ]; then   
          if [ $NOTES_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Backup Agent for Lotus Domino             (${NOTES_PKG})       ==> [ $NOTES_PKG_DIR/BABlotusagt ]"
          elif [ $NOTES_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Backup Agent for Lotus Domino             (${NOTES_PKG})       ==> [ $NOTES_PKG_DIR/BABlotusagt ]"
          else
                    $command "  . ${INST_MSG_206} Backup Agent for Lotus Domino             (${NOTES_PKG})       ==> [ $NOTES_PKG_DIR/BABlotusagt ]"
	  fi
                elif  [ $command  = "Get_Space" -a $NOTES_ALREADY_INSTALLED -ne 1 ]; then 
                    $command NOT $NOTES_PKG_DIR/BABlotusagt
                elif [ $NOTES_ALREADY_INSTALLED -ne 1 ]; then
                    $command $NOTES_PKG $NOTES_PKG_DIR 
                fi
                ca_agent_install=1 
	fi
}
Perform_Selection_Switch_DB2()
{
	if [ $DB2_PROCED -ne 1 ]; then
                DB2_PKG=BABdb2
                if [ $command  = "echo" ]; then   
          if [ $DB2_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Enterprise Option for DB2 UDB             (BABdb2)         ==> [ $DB2_PKG_DIR/BABdb2agt ]"
          elif [ $DB2_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Enterprise Option for DB2 UDB             (BABdb2)         ==> [ $DB2_PKG_DIR/BABdb2agt ]"
          else
                    $command "  . ${INST_MSG_206} Enterprise Option for DB2 UDB             (BABdb2)         ==> [ $DB2_PKG_DIR/BABdb2agt ]"
	  fi
                elif  [ $command  = "Get_Space" -a $DB2_ALREADY_INSTALLED -ne 1 ]; then 
                    $command DB2 $DB2_PKG_DIR/BABdb2agt
                elif [ $DB2_ALREADY_INSTALLED -ne 1 ]; then
                    $command $DB2_PKG $DB2_PKG_DIR 
                fi
                ca_agent_install=1 
	fi
}
Perform_Selection_Switch_ING()
{
	if [ $ING_PROCED -ne 1 ]; then
           	ING_PKG=BABing
                if [ $command  = "echo" ]; then   
          if [ $ING_OLD_INSTALLED -eq 1 ]; then
                    $command "  . ${INST_MSG_205} Enterprise Option for Advantage Ingres    (BABing)         ==> [ $ING_PKG_DIR/BABingagt ]"
          elif [ $ING_NEED_UPGRADE -eq 1 ]; then
                    $command "  . ${INST_MSG_215} Enterprise Option for Advantage Ingres    (BABing)         ==> [ $ING_PKG_DIR/BABingagt ]"
          else
                    $command "  . ${INST_MSG_206} Enterprise Option for Advantage Ingres    (BABing)         ==> [ $ING_PKG_DIR/BABingagt ]"
	  fi
                elif  [ $command  = "Get_Space" -a $ING_ALREADY_INSTALLED -ne 1 ]; then 
                    $command ING $ING_PKG_DIR/BABingagt
                elif [ $ING_ALREADY_INSTALLED -ne 1 ]; then
                    $command $ING_PKG $ING_PKG_DIR 
                fi
                ca_agent_install=1 
	fi
}
Perform_Selection_Switch()
{
    	command=$1
    	UAG_PROC_ALREADY=0
	BASE_PROCED=0
	NLO_PROCED=0
	ORA_PROCED=0
	SAN_PROCED=0
	DRO_PROCED=0
	NAS_PROCED=0
	IBM_PROCED=0
	NOTES_PROCED=0
	DB2_PROCED=0
	ING_PROCED=0
	SYBASE_PROCED=0
	SAP_PROCED=0
	INFMX_PROCED=0
        if [ "X${INSTALL_CHOICE}" != "X" ]; then
	    	num_choices=`echo $INSTALL_CHOICE | awk -F, '{print NF}'`
        else
        	num_choices=0
        fi
    choice_counter=1
    ca_agent_install=0
    if [ $command  = "echo" ]
    then 
if [ $AGENTS_DIR -eq 1 ]; then
	echo; echo $INST_MSG_199; echo
else
        echo; echo "${INST_MSG_152}"; echo
fi
    fi

    if [ $BEBSVR_OLD_INSTALLED -eq 1 -o $SERVER_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_BASE
		BASE_PROCED=1
    fi
    if [ $UAGENT_OLD_INSTALLED -eq 1 -o $UAG_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_UAG
		UAG_PROC_ALREADY=1
    fi
    if [ $ORA_OLD_INSTALLED -eq 1 -o $ORA_NEED_UPGRADE -eq 1 -o $ORA8SL_OLD_INSTALLED -eq 1 -o $TIMEFINDER_OLD_INSTALLED -eq 1 -o $ORA8_OLD_INSTALLED -eq 1 ]; then
		Perform_Selection_Switch_ORA8
		ORA_PROCED=1
    fi
    if [ $DRO_OLD_INSTALLED -eq 1 -o $DRO_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_DRO
		DRO_PROCED=1
    fi
    if [ $NAS_OLD_INSTALLED -eq 1 -o $NAS_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_NAS
		NAS_PROCED=1
    fi
    if [ $NLO_OLD_INSTALLED -eq 1 -o $NLO_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_NLO
		NLO_PROCED=1
    fi
    if [ $SAN_OLD_INSTALLED -eq 1 -o $SAN_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_SAN
		SAN_PROCED=1
    fi
    if [ $IBM_OLD_INSTALLED -eq 1 -o $IBM_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_IBM
		IBM_PROCED=1
    fi
    if [ $SYBASE_OLD_INSTALLED -eq 1 -o $SYB_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_SYBASE
		SYBASE_PROCED=1
    fi
    if [ $INFMX_OLD_INSTALLED -eq 1 -o $INFMX_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_INFMX
		INFMX_PROCED=1
    fi
    if [ $SAP_OLD_INSTALLED -eq 1 -o $SAP_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_SAP
		SAP_PROCED=1
    fi
    if [ $NOTES_OLD_INSTALLED -eq 1 -o $NOTES_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_NOTES
		NOTES_PROCED=1
    fi
    if [ $DB2_OLD_INSTALLED -eq 1 -o $DB2_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_DB2
		DB2_PROCED=1
    fi
    if [ $ING_OLD_INSTALLED -eq 1 -o $ING_NEED_UPGRADE -eq 1 ]; then
		Perform_Selection_Switch_ING
		ING_PROCED=1
    fi
    while [ $choice_counter -le $num_choices ]
    do
        choice_id=`echo $INSTALL_CHOICE | cut -d',' -f$choice_counter`
if [ $AGENTS_DIR -eq 1 ]; then
        case $choice_id in
            0)  CLEANUP 0
                ;;
            1)  Perform_Selection_Switch_UAG
                ;;
            2)  Perform_Selection_Switch_ORA8
                ;;
        esac
else

if [ "$OS" = "SunOS" ]; then
  if [ "$PLATFORM" = "s86" ]; then
        case $choice_id in
            0)  CLEANUP 0
                ;;
            1)  Perform_Selection_Switch_UAG
                ;;
            2)  Perform_Selection_Switch_ORA8
                ;;
        esac
  else
       case $choice_id in
            0)  
            	CLEANUP 0
                ;;
            1)  
            	Perform_Selection_Switch_BASE
                ;;
            2)  
            	Perform_Selection_Switch_UAG
                ;;
            3)  
            	Perform_Selection_Switch_SAN
                ;;
            4)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
            	Perform_Selection_Switch_DRO
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_DRO
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
            	Perform_Selection_Switch_DRO
else
            	Perform_Selection_Switch_IBM
fi
                ;;
            5)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
            	Perform_Selection_Switch_NAS
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_NAS
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
            	Perform_Selection_Switch_NAS
else
            	Perform_Selection_Switch_DRO
fi
                ;;
            6)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
            	Perform_Selection_Switch_ORA8
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_ORA8
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
            	Perform_Selection_Switch_ORA8
else
            	Perform_Selection_Switch_NAS
fi
                ;;
            7)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	Perform_Selection_Switch_NOTES
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_SYBASE
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	Perform_Selection_Switch_NOTES
else
            	Perform_Selection_Switch_NLO
fi
                ;;
            8)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	Perform_Selection_Switch_DB2
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	Perform_Selection_Switch_NOTES
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	Perform_Selection_Switch_DB2
else
            	Perform_Selection_Switch_ORA8
fi
                ;;
            9)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	Perform_Selection_Switch_DB2
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	Perform_Selection_Switch_ING
else
            	Perform_Selection_Switch_SYBASE
fi
                ;;
           10)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_INFMX
fi
                ;;
           11)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_SAP
fi
                ;;
           12)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_NOTES
fi
                ;;
           13)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_DB2
fi
                ;;
           14)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_ING
fi
                ;;
        esac
  fi
elif [ "$OS" = "HP-UX" ]; then
        case $choice_id in
            0)  
            	CLEANUP 0
                ;;
            1)  
            	Perform_Selection_Switch_BASE
                ;;
            2)  
            	Perform_Selection_Switch_UAG
                ;;
            3)  
            	Perform_Selection_Switch_SAN
                ;;
            4)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
            	Perform_Selection_Switch_NAS
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_NAS
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
            	Perform_Selection_Switch_NAS
else
            	Perform_Selection_Switch_IBM
fi
                ;;
            5)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
            	Perform_Selection_Switch_ORA8
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_ORA8
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
            	Perform_Selection_Switch_ORA8
else
            	Perform_Selection_Switch_NAS
fi
                ;;
            6)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	Perform_Selection_Switch_NOTES
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_SYBASE
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	Perform_Selection_Switch_NOTES
else
            	Perform_Selection_Switch_NLO
fi
                ;;
            7)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	Perform_Selection_Switch_NOTES
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	Perform_Selection_Switch_ING
else
            	Perform_Selection_Switch_ORA8
fi
                ;;
            8)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
            	Perform_Selection_Switch_SYBASE
fi
                ;;
            9)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
            	Perform_Selection_Switch_INFMX
fi
                ;;
           10)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_SAP
fi
                ;;
           11)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_NOTES
fi
                ;;
           12)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_ING
fi
                ;;
       esac
elif [ "$OS" = "AIX" ]; then
        case $choice_id in
            0)  
            	CLEANUP 0
                ;;
            1)  
            	Perform_Selection_Switch_BASE
                ;;
            2)  
            	Perform_Selection_Switch_UAG 
                ;;
            3)  
            	Perform_Selection_Switch_SAN
                ;;
            4)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
            	Perform_Selection_Switch_ORA8
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_ORA8
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
            	Perform_Selection_Switch_ORA8
else
            	Perform_Selection_Switch_IBM
fi
                ;;
            5)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
            	Perform_Selection_Switch_NOTES
elif [ "X${NLS_LANG}" = "Xsc" ]; then
            	Perform_Selection_Switch_NOTES
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
            	Perform_Selection_Switch_NOTES
else
            	Perform_Selection_Switch_NLO
fi
                ;;
            6)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	Perform_Selection_Switch_DB2
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	Perform_Selection_Switch_DB2
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	Perform_Selection_Switch_DB2
else
            	Perform_Selection_Switch_ORA8
fi
                ;;
            7)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	Perform_Selection_Switch_ING
else
            	Perform_Selection_Switch_INFMX
fi
                ;;
            8)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
            	Perform_Selection_Switch_SAP
fi
                ;;
            9)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
            	Perform_Selection_Switch_NOTES
fi
                ;;
           10)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_DB2
fi
                ;;
           11)  
if [ "X${NLS_LANG}" = "Xja_euc" -o "X${NLS_LANG}" = "Xja_sjis" -o "X${NLS_LANG}" = "Xtc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsc" ]; then
           	TMPNUM=0
elif [ "X${NLS_LANG}" = "Xsp" -o "X${NLS_LANG}" = "Xit" -o "X${NLS_LANG}" = "Xde" -o "X${NLS_LANG}" = "Xfr" ]; then
           	TMPNUM=0
else
           	Perform_Selection_Switch_ING
fi
                ;;
        esac
elif [ "$OS" = "OSF1" ]; then
        case $choice_id in
            0)  CLEANUP 0
                ;;
            1)  Perform_Selection_Switch_UAG
                ;;
            2)  Perform_Selection_Switch_ORA8
                ;;
            3)  Perform_Selection_Switch_INFMX
                ;;
        esac
fi
fi
        choice_counter=`expr $choice_counter + 1 `
    done
}

check_patch_oracle()
{
# On HP UX, check if the gethrtime() system call is defined in libc.sl.
# This function is not part of the base OS and is installed by HP UX patches.
if [ `nm -op /lib/libc.sl | grep gethrtime | grep T | wc -l` -eq 0 ]
then
  echo
  echo "${INST_MSG_110}"
  echo
  os_level=`uname -r`
  case $os_level in
    *.11.00)
      echo "$INST_MSG_173"
      ;;
    *.11.*)
      echo "$INST_MSG_174"
      ;;
  esac
  echo "\n${INST_MSG_86}\n"
  exit 1
fi
}


# finalize selection of packages
#
Finalize_User_Packages()
{
    
    if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ]
    then
	Process_Package_Menu_Silent >> ${LOG_FILE} 2>&1
    	Perform_Selection_Switch_Silent Get_Package_Path_Silent  >> ${LOG_FILE} 2>&1
    	Perform_Selection_Switch_Silent echo  >> ${LOG_FILE} 2>&1
        CREATE_DIR  >> ${LOG_FILE} 2>&1
    else
	Process_Package_Menu
    	Perform_Selection_Switch Get_Package_Path
    	Perform_Selection_Switch echo

	    while [ true ]
	    do
	        echo
	        echo "${INST_MSG_50} \c"
	        read y_or_n
	
	        case $y_or_n in
	            Y|y|Yes|yes)
if [ "$OS" = "HP-UX" ]; then
	            if [ "$ORA8_PKG" != "" ]; then
	                if [ $EXEC_MODE -ne $RESP_MODE ]
	                then     
	                    check_patch_oracle
	                fi
	            fi
fi
	            if [ $EXEC_MODE -ne $RESP_MODE ]
	            then
	                CREATE_DIR
	            fi
	            break
	             ;;
	        N|n|No|no)
	            Process_Package_Menu
	            Perform_Selection_Switch Get_Package_Path
	            Perform_Selection_Switch echo
	            ;;
	        Q|q|Quit|quit)
	            CLEANUP 0
	            ;;
	        "")
	            if [ $EXEC_MODE -ne $RESP_MODE ]
	            then
	                CREATE_DIR
	            fi
	            break
	            ;;
	        *)
	            echo "${INST_MSG_16}"
	            ;;
	        esac
	    done
    fi

    if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ]
    then
        Perform_Selection_Switch_Silent Get_Space  >> ${LOG_FILE} 2>&1

        # Check if disk space checking should be enabled or not
        if [ -f /tmp/BrightStorDISABLESPACECHECK ]
        then
            echo "" >> ${LOG_FILE} 2>&1
            echo "${INST_MSG_51}" >> ${LOG_FILE} 2>&1
            echo "${INST_MSG_52}" >> ${LOG_FILE} 2>&1
            echo "${INST_MSG_53}" >> ${LOG_FILE} 2>&1
            echo "" >> ${LOG_FILE} 2>&1
        else
            Verify_Space >> ${LOG_FILE} 2>&1
        fi
    fi
    if [ $EXEC_MODE -eq $REGR_MODE ]
    then
        Perform_Selection_Switch Get_Space

        # Check if disk space checking should be enabled or not
        if [ -f /tmp/BrightStorDISABLESPACECHECK ]
        then
            echo ""
            echo "${INST_MSG_51}"
            echo "${INST_MSG_52}"
            echo "${INST_MSG_53}"
            echo ""
        else
            Verify_Space
        fi
    fi
}


# Install license
#
Install_License_Package()
{
    if [ $EXEC_MODE -eq $SDO_MODE -a "$LICENSE_INSTALL" != "YES" -o "$OS" = "FreeBSD" ]; then
       	return 0
    fi
    if [ -f $LIC98_PKG_R -a $LIC_INSTALLED -ne 1 ]
    then
        mkdir -p $TMPDIR/$PID/$LIC98_D
        cd $TMPDIR/$PID/$LIC98_D
        $UNTAR $LIC98_PKG_R
        if [ $? != 0 ]
        then
            echo "${INST_MSG_54} $UNTAR $LIC98_PKG_R"
            CLEANUP 7
        fi
        cd lic98_install
        if [ "$License_Path" = "" ]; then
          $LIC98_INSTALL >/dev/null 2>&1
        else
          $LIC98_INSTALL $License_Path >/dev/null 2>&1
        fi
        rc=$?
        if [ $rc -ne 0 ]; then
          echo "${INST_MSG_211} $rc" >> ${LOG_FILE}
          echo
          
        fi
        cd $HOMEDIR
        rm -rf $TMPDIR/$PID/$LIC98_D
        if [ $rc -ne 0 ]; then
        	echo
        	echo ${INST_MSG_211}
        	if [ $rc -eq 21 ]; then
        		echo 
        		echo "$LIC_ERR_1"
        		echo
        	elif [ $rc -eq 23 ]; then
        		echo 
        		echo "$LIC_ERR_2"
        		echo
        	elif [ $rc -eq 24 ]; then
        		echo 
        		echo "$LIC_ERR_3"
        		echo
        	elif [ $rc -eq 25 ]; then
        		echo 
        		echo "$LIC_ERR_4"
        		echo
        	elif [ $rc -eq 30 ]; then
        		echo 
        		echo "$LIC_ERR_5"
        		echo
        	elif [ $rc -eq 31 ]; then
        		echo 
        		echo "$LIC_ERR_6"
        		echo
        	elif [ $rc -eq 33 ]; then
        		echo 
        		echo "$LIC_ERR_7"
        		echo
        	elif [ $rc -eq 40 ]; then
        		echo 
        		echo "$LIC_ERR_8"
        		echo
        	fi
        	echo
                CLEANUP $rc
        fi
          . /etc/profile.CA >/dev/null 2>&1
          if [ "X${NLS_LANG}" = "X" ]; then
          	NLS_LANG="C"
          fi
	LIC_LANG="EN"
	case $NLS_LANG in
		C)
			LIC_LANG="EN"
			;;
		fr)
			LIC_LANG="FR"
			;;
		sp)
			LIC_LANG="SP"
			;;
		de)
			LIC_LANG="DE"
			;;
		tc)
			LIC_LANG="TC"
			;;
		sc)
			LIC_LANG="SC"
			;;
		ja_euc)
			LIC_LANG="JA_EUC"
			;;
		ja_sjis)
			LIC_LANG="JA"
			;;
		it)
			LIC_LANG="IT"
			;;
		*)
			LIC_LANG="EN"
			;;
	esac
          $CASHCOMP/ca_lic/lic98err/install_lang ${LIC_LANG}  >/dev/null 2>&1 #run script to configure language of lic98
          cp ${PROD_CODE} $CASHCOMP/ca_lic/ >/dev/null 2>&1 
        if [ "$OS" = "SunOS" -o "$OS" = "OSF1" ]; then
          strings $CASHCOMP/ca_lic/lic98.so|grep "LIC98 BUILD INFO"|head -1|grep "\/1.60.0\/Feb.*2004\/" >/dev/null 2>&1
          if [ $? -eq 0 ]; then
            cp ${LIC98_PATCH}.so $CASHCOMP/ca_lic/ >/dev/null 2>&1 
          fi
        elif [ "$OS" = "HP-UX" ]; then
          strings $CASHCOMP/ca_lic/lic98.sl|grep "LIC98 BUILD INFO"|head -1|grep "\/1.60.0\/Feb.*2004\/" >/dev/null 2>&1
          if [ $? -eq 0 ]; then
            cp ${LIC98_PATCH}.sl $CASHCOMP/ca_lic/ >/dev/null 2>&1 
          fi
        elif [ "$OS" = "AIX" ]; then
          strings $CASHCOMP/ca_lic/lic98.o|grep "LIC98 BUILD INFO"|head -1|grep "\/1.60.0\/Feb.*2004\/" >/dev/null 2>&1
          if [ $? -eq 0 ]; then
            cp ${LIC98_PATCH}.o $CASHCOMP/ca_lic/ >/dev/null 2>&1 
          fi
        fi
        if [ $EXEC_MODE -eq $SDO_MODE -a "$LICENSE_INSTALL" = "YES" ]; then
        	echo
        	echo "$INST_MSG_175"
        	echo
        fi
        LIC_INSTALLED=1
    elif [ ! -f $LIC98_PKG_R ];then
            echo "${INST_MSG_54} $UNTAR $LIC98_PKG_R"
            CLEANUP 7
    
    fi
}


# Untar a package, cleanup and exit if unsuccessful
#
Untar_Package()
{
    pkg_name=$1
    echo "$UNTAR $pkg_name" >> ${LOG_FILE} 2>&1
    mkdir -p $TMPDIR/$PID/tmppkg.d
    cd $TMPDIR/$PID/tmppkg.d
    $UNTAR $pkg_name
    if [ $? != 0 ]
    then
        echo "${INST_MSG_54} $UNTAR $pkg_name"
        CLEANUP 8
    fi
}


USAGE()
{
    echo "${INST_MSG_55} $THISSCRIPT [TEMP DIR] [ALTERNATE PKG LOCATION]"
    exit 1
}


Verify_Tmp_Space()
{
    start_pwd=$1
    if [ $BEB_BASE_REQUESTED -eq 1 ]; then
	if [ "$OS" = "SunOS" -o "$OS" = "OSF1" -o "$OS" = "FreeBSD" ]; then
	    filesys_tmp=`df -k $start_pwd | $AWK '{ if (NR == 2) { print $6 } }'`
	elif [ "$OS" = "HP-UX" ]; then
	    filesys_tmp=`df -k $start_pwd | $AWK '{ if (NR == 1){ print $1 } }'`
	elif [ "$OS" = "AIX" ]; then
	    filesys_tmp=`df -k $start_pwd | $AWK '{ if (NR == 2){ print $7 } }'` 
	fi
	if [ "X${FILESYS_BASE}" = "X${filesys_tmp}" ]; then
          mustHave=900
	else
          mustHave=500
        fi
    else
          mustHave=50
    fi
    printf "%-42s" "${INST_MSG_56} $start_pwd"
    echo "                    ==> [\c"
if [ "$OS" = "SunOS" -o "$OS" = "OSF1" -o "$OS" = "FreeBSD" ]; then
    available=`df -k $start_pwd | $AWK '{ if (NR == 2) { print $4 } }'` 
elif [ "$OS" = "HP-UX" ]; then
    available=`df -k $start_pwd | $AWK '{ if (NR == 2) { print $1 } }'`
elif [ "$OS" = "AIX" ]; then
   available=`df -k $start_pwd | $AWK '{ if (NR == 2){ print $3 } }'` 
fi
    available=`expr $available / 1024` ## break it down to megs

    if [ $available -ge $mustHave ]
    then
        echo " ${INST_MSG_20} ]"
        echo
   else
        echo " ${INST_MSG_21} ]"
        SPACE_ERR=1
   fi
}

Get_Choice()
{
if [ $EXEC_MODE -ne $RESP_MODE ]; then
	Verify_Tmp_Space $TMPDIR
else
	return 0
fi
if [ $SPACE_ERR -eq 1 ]; then
        echo
       	printf "${INST_MSG_57}\n" "$TMPDIR"
        if [ $EXEC_MODE -eq $SDO_MODE -o $EXEC_MODE -eq $SLNT_MODE ]; then
        	CLEANUP 2
        fi
        dir=""
        while [ "$dir" = "" ]
        do
          echo "${INST_MSG_58} \c"
          read dir
        done
        
        if [ -d $dir ]; then
                TMPDIR=$dir
        else
                yorn_err=1

                while [ "$yorn_err" != "0" ]
                do
                        echo
                        yorn_err=0
                        echo "${INST_MSG_59} \c"
                        read yorn

                        case $yorn in
                        Y|y|Yes|yes)
                                mkdir -p $dir
                                TMPDIR=$dir
                                TEMP_CREATE=1
                                ;;
                        N|n|No|no)
                                echo "${INST_MSG_60}"
                                exit 1
                                ;;
                        "")
                                mkdir -p $dir
                                TMPDIR=$dir
                                TEMP_CREATE=1
                                ;;
                        *)
                                yorn_err=1
                                echo "${INST_MSG_16}"
                                ;;
                        esac
                done
        fi

        SPACE_ERR=0
        echo
        Verify_Tmp_Space $TMPDIR
        if [ $SPACE_ERR -eq 1 ]; then
                echo
#                printf "${INST_MSG_18}\n" "$mustHave"
                printf "${INST_MSG_61}\n" "$mustHave" "$TMPDIR"
                echo "         ${INST_MSG_23}"
                CLEANUP 4
        fi
fi
}
Update_Oracfg()
{
	ORA_PREFIX=${ORA8_PKG_DIR}
	if [ "X${ORA_PREFIX}" = "X" ]; then
		CAS_ENV_ORACLE_AGENT_HOME="/opt/CA/BABoraagt"
	elif [ "X${ORA_PREFIX}" = "X/" ]; then
		CAS_ENV_ORACLE_AGENT_HOME="/BABoraagt"
	else
		CAS_ENV_ORACLE_AGENT_HOME="${ORA_PREFIX}/BABoraagt"
	fi
	cp -p ${ORA_OLD_PKG_DIR}/${ORA_OLD_PKG_DIR_SUB}/sbt.cfg ${ORA_PREFIX:-/opt/CA}/BABoraagt/ 2>/dev/null
	cp -p ${ORA_OLD_PKG_DIR}/${ORA_OLD_PKG_DIR_SUB}/instance.cfg ${ORA_PREFIX:-/opt/CA}/BABoraagt/ 2>/dev/null
	cp -Rp ${ORA_OLD_PKG_DIR}/${ORA_OLD_PKG_DIR_SUB}/logs/* ${ORA_PREFIX:-/opt/CA}/BABoraagt/logs/ 2>/dev/null
	chmod 666 ${ORA_PREFIX:-/opt/CA}/BABoraagt/logs/*.log 2>/dev/null
	echo "" >>${AGENT_CFG}
	echo "[22]" >>${AGENT_CFG}
	echo "# Oracle Agent" >>${AGENT_CFG}
	echo "NAME	OracleAgent" >>${AGENT_CFG}
	echo "VERSION	12.5.0" >>${AGENT_CFG}
	echo "HOME    $CAS_ENV_ORACLE_AGENT_HOME" >>${AGENT_CFG}
	echo "#ENV    BAB_HOME=/opt/CA/BrightStorARCserve" >>${AGENT_CFG}
	echo "ENV     CAS_ENV_ORACLE_AGENT_HOME=$CAS_ENV_ORACLE_AGENT_HOME" >>${AGENT_CFG}
	TEMP_STR=`grep ORACLE_RM_USERNAME $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	TEMP_STR=`grep ORACLE_RM_PASSWORD $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	echo "#ENV    CA_ENV_NUM_OF_REST_BUFF=" >>${AGENT_CFG}
	echo "ENV     DAYS_ORAGENTD_LOGS_RETAINED=30" >>${AGENT_CFG}
	echo "ENV     CAS_INITIATED=1" >>${AGENT_CFG}
	echo "ENV     ORACLE_SHUTDOWN_TYPE=immediate" >>${AGENT_CFG}
	echo "#ENV    NLS_LANG=american" >>${AGENT_CFG}
	echo "ENV     NLS_DATE_FORMAT=MM/DD/YYYY/HH24:MI:SS" >>${AGENT_CFG}
	if [ "$OS" = "SunOS" ]; then
		echo "ENV     LD_LIBRARY_PATH=/opt/CA/BABcmagt:/usr/lib:$CAS_ENV_ORACLE_AGENT_HOME:$CAS_ENV_ORACLE_AGENT_HOME/lib:/opt/CA/CAlib:${CALIB}:\$LD_LIBRARY_PATH" >>${AGENT_CFG}
	elif [ "$OS" = "HP-UX" ]; then
		echo "ENV     SHLIB_PATH=/opt/CA/BABcmagt:/usr/lib:$CAS_ENV_ORACLE_AGENT_HOME:$CAS_ENV_ORACLE_AGENT_HOME/lib:/opt/CA/CAlib:${CALIB}:\$SHLIB_PATH" >>${AGENT_CFG}
	elif [ "$OS" = "AIX" ]; then
		echo "ENV     LIBPATH=/opt/CA/BABcmagt:/usr/lib:$CAS_ENV_ORACLE_AGENT_HOME:$CAS_ENV_ORACLE_AGENT_HOME/lib:/opt/CA/CAlib:${CALIB}:\$LIBPATH" >>${AGENT_CFG}
	fi
	echo "BROWSER oraclebr" >>${AGENT_CFG}
	echo "AGENT	oragentd" >>${AGENT_CFG}
}

Update_Nascfg()
{
	echo "" >>${AGENT_CFG}
	echo "[34]" >>${AGENT_CFG}
	echo "#[NASAGENT]" >>${AGENT_CFG}
	echo "NAME    NASagent" >>${AGENT_CFG}
	echo "VERSION	12.5.0" >>${AGENT_CFG}
	echo "HOME    ${BEB_PKG_DIR}/BrightStorARCserve/nasagent" >>${AGENT_CFG}
	echo "#ENV     CA_ENV_DEBUG_LEVEL=4" >>${AGENT_CFG}
	echo "ENV     LD_LIBRARY_PATH=${BEB_PKG_DIR}/BrightStorARCserve/nasagent/lib:/opt/CA/BABcmagt:\$LD_LIBRARY_PATH" >>${AGENT_CFG}
	echo "ENV     SHLIB_PATH=${BEB_PKG_DIR}/BrightStorARCserve/nasagent/lib:/opt/CA/BABcmagt:\$SHLIB_PATH" >>${AGENT_CFG}
	echo "ENV     LIBPATH=${BEB_PKG_DIR}/BrightStorARCserve/nasagent/lib:/opt/CA/BABcmagt:\$LIBPATH" >>${AGENT_CFG}
	echo "BROWSER nasbr" >>${AGENT_CFG}
	echo "AGENT   nasbr" >>${AGENT_CFG}
}

Update_Sybcfg()
{
	SYB_PREFIX=${SYBASE_PKG_DIR}
	if [ "X${SYB_PREFIX}" = "X" ]; then
		CA_ENV_SYB_AGENT_HOME="/opt/CA/BABsybagt"
	elif [ "X${SYB_PREFIX}" = "X/" ]; then
		CA_ENV_SYB_AGENT_HOME="/BABsybagt"
	else
		CA_ENV_SYB_AGENT_HOME="${SYB_PREFIX}/BABsybagt"
	fi
	cp -p ${SYBASE_OLD_PKG_DIR}/${SYBASE_OLD_PKG_DIR_SUB}/installation.cfg ${SYB_PREFIX:-/opt/CA}/BABsybagt/ 2>/dev/null
	cp -Rp ${SYBASE_OLD_PKG_DIR}/${SYBASE_OLD_PKG_DIR_SUB}/logs/* ${SYB_PREFIX:-/opt/CA}/BABsybagt/logs/ 2>/dev/null
	echo "" >>${AGENT_CFG}
	echo "[30]" >>${AGENT_CFG}
	echo "NAME	SybaseAgent" >>${AGENT_CFG}
	echo "VERSION	12.5.0" >>${AGENT_CFG}
	echo "HOME	$CA_ENV_SYB_AGENT_HOME" >>${AGENT_CFG}
	echo "ENV     CA_ENV_SYB_AGENT_HOME=$CA_ENV_SYB_AGENT_HOME" >>${AGENT_CFG}
	TEMP_STR=`grep SYBASE_OCS $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	TEMP_STR1=`echo $TEMP_STR | ${AWK} '{ print $2 }'`
	SYB_OCS=`echo $TEMP_STR1 | ${AWK} -F"=" '{ print $2 }'`
	TEMP_STR=`grep SYBASE_ASE $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	TEMP_STR1=`echo $TEMP_STR | ${AWK} '{ print $2 }'`
	SYB_ASE=`echo $TEMP_STR1 | ${AWK} -F"=" '{ print $2 }'`
	if [ "$OS" = "SunOS" ]; then
		echo "ENV     LD_LIBRARY_PATH=/opt/CA/BABcmagt:${CALIB}:$CA_ENV_SYB_AGENT_HOME/lib:/lib:\$LD_LIBRARY_PATH" >>${AGENT_CFG}
		echo "#ENV    SHLIBSYB_PATH=" >>${AGENT_CFG}
		echo "#ENV    LIBSYBPATH=" >>${AGENT_CFG}
	elif [ "$OS" = "HP-UX" ]; then
		echo "#ENV    LDSYB_LIBRARY_PATH=" >>${AGENT_CFG}
		echo "ENV     SHLIB_PATH=/opt/CA/BABcmagt:${CALIB}:$CA_ENV_SYB_AGENT_HOME/lib:/lib:\$SHLIB_PATH" >>${AGENT_CFG}
		echo "#ENV    LIBSYBPATH=" >>${AGENT_CFG}
	elif [ "$OS" = "AIX" ]; then
		echo "#ENV    LDSYB_LIBRARY_PATH=" >>${AGENT_CFG}
		echo "#ENV    SHLIBSYB_PATH=" >>${AGENT_CFG}
		echo "ENV     LIBPATH=/opt/CA/BABcmagt:${CALIB}:$CA_ENV_SYB_AGENT_HOME/lib:/lib:\$LIBPATH" >>${AGENT_CFG}
	fi
	TEMP_STR=`grep SYBASE= $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	TEMP_STR1=`echo $TEMP_STR | ${AWK} '{ print $2 }'`
	SYB_DIR=`echo $TEMP_STR1 | ${AWK} -F"=" '{ print $2 }'`
	echo "#ENV    CA_ENV_DEBUG_LEVEL=4" >>${AGENT_CFG}
	echo "BROWSER sybbr" >>${AGENT_CFG}
	echo "AGENT	sybagntd" >>${AGENT_CFG}
	if [ -f ${SYB_PREFIX:-/opt/CA}/BABsybagt/installation.cfg ]; then
		if [ "X$SYB_DIR" != "X" -a "X$SYB_ASE" != "X" -a "X$SYB_OCS" != "X" ]; then
		        cd $CA_ENV_SYB_AGENT_HOME >/dev/null 2>&1
		        $CA_ENV_SYB_AGENT_HOME/sybsetup -s "$CA_ENV_SYB_AGENT_HOME" "${SYB_DIR}" "${SYB_OCS}" "${SYB_ASE}" >> ${LOG_FILE} 2>&1
	        elif [ "X$SYB_DIR" != "X" ]; then
		        cd $CA_ENV_SYB_AGENT_HOME >/dev/null 2>&1
		        $CA_ENV_SYB_AGENT_HOME/sybsetup -s "$CA_ENV_SYB_AGENT_HOME" "${SYB_DIR}" >> ${LOG_FILE} 2>&1
	        fi
        fi
}
Update_Infcfg()
{
	INF_PREFIX=${INFMX_PKG_DIR}
	if [ "X${INF_PREFIX}" = "X" ]; then
		CAINFMX_HOME="/opt/CA/BABinfmx"
	elif [ "X${INF_PREFIX}" = "X/" ]; then
		CAINFMX_HOME="/BABinfmx"
	else
		CAINFMX_HOME="${INF_PREFIX}/BABinfmx"
	fi
	cp -p ${INFMX_OLD_PKG_DIR}/${INFMX_OLD_PKG_DIR_SUB}/installation.cfg $CAINFMX_HOME/ 2>/dev/null
	cp -p ${INFMX_OLD_PKG_DIR}/${INFMX_OLD_PKG_DIR_SUB}/infmx_cmd_line_utl.param $CAINFMX_HOME/ 2>/dev/null
	cp -Rp ${INFMX_OLD_PKG_DIR}/${INFMX_OLD_PKG_DIR_SUB}/logs/* $CAINFMX_HOME/logs/ 2>/dev/null
	TEMP_STR=`grep INFORMIXDIR $OLD_AGENT_CFG 2>/dev/null | grep -v INFORMIXDIR/lib`
	TEMP_STR1=`echo $TEMP_STR | ${AWK} '{ print $2 }'`
	INFO_DIR=`echo $TEMP_STR1 | ${AWK} -F"=" '{ print $2 }'`
	echo "" >>${AGENT_CFG}
	echo "[32]" >>${AGENT_CFG}
	echo "# Informix OnBar Agent" >>${AGENT_CFG}
	echo "NAME	InfmxAgent" >>${AGENT_CFG}
	echo "VERSION	12.5.0" >>${AGENT_CFG}
	echo "HOME	$CAINFMX_HOME" >>${AGENT_CFG}
	if [ "$OS" = "SunOS" ]; then
		echo "ENV     LD_LIBRARY_PATH=/opt/CA/BABcmagt:${CALIB}:${INFO_DIR}/lib/esql:\$INFORMIXDIR/lib/cli:$CAINFMX_HOME/lib:/lib:\$LD_LIBRARY_PATH" >>${AGENT_CFG}
		echo "#ENV    SHLIBSYB_PATH=" >>${AGENT_CFG}
		echo "#ENV    LIBSYBPATH=" >>${AGENT_CFG}
	elif [ "$OS" = "HP-UX" ]; then
		echo "#ENV    LDSYB_LIBRARY_PATH=" >>${AGENT_CFG}
		echo "ENV     SHLIB_PATH=/opt/CA/BABcmagt:${CALIB}:${INFO_DIR}/lib/esql:\$INFORMIXDIR/lib/cli:$CAINFMX_HOME/lib:/lib:\$SHLIB_PATH" >>${AGENT_CFG}
		echo "#ENV    LIBSYBPATH=" >>${AGENT_CFG}
	elif [ "$OS" = "AIX" ]; then
		echo "#ENV    LDSYB_LIBRARY_PATH=" >>${AGENT_CFG}
		echo "#ENV    SHLIBSYB_PATH=" >>${AGENT_CFG}
		echo "ENV     LIBPATH=/opt/CA/BABcmagt:${CALIB}:${INFO_DIR}/lib/esql:\$INFORMIXDIR/lib/cli:$CAINFMX_HOME/lib:/lib:\$LIBPATH" >>${AGENT_CFG}
	fi
	echo "ENV     PATH=${INFO_DIR}/bin:\$PATH" >>${AGENT_CFG}
	echo "ENV     CAINFMX_HOME=$CAINFMX_HOME" >>${AGENT_CFG}
	echo "ENV     INFORMIXDIR=${INFO_DIR}" >>${AGENT_CFG}
	TEMP_STR=`grep ARCHIVE_TEST $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	echo "#ENV	CA_ENV_DEBUG_LEVEL=4" >>${AGENT_CFG}
	TEMP_STR=`grep INFMX_AGNT_PORT_NO $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	echo "BROWSER infmxbr" >>${AGENT_CFG}
	echo "AGENT	onbarcmd" >>${AGENT_CFG}
	if [ -f $CAINFMX_HOME/installation.cfg -a "X${INFO_DIR}" != "X" ]; then
	        cd $CAINFMX_HOME >/dev/null 2>&1
	        $CAINFMX_HOME/infmxsetup -s "$CAINFMX_HOME" "${INFO_DIR}" "2" >> ${LOG_FILE} 2>&1
        fi
}


Update_Notescfg()
{
	echo "" >>${AGENT_CFG}
       cp -Rp $NOTES_OLD_PKG_DIR/$NOTES_OLD_PKG_DIR_SUB/logs/* ${NOTES_PKG_DIR}/BABlotusagt/logs/ >/dev/null 2>&1
       cp -Rp $NOTES_OLD_PKG_DIR/$NOTES_OLD_PKG_DIR_SUB/*.cfg ${NOTES_PKG_DIR}/BABlotusagt/ >/dev/null 2>&1
       cp -Rp $NOTES_OLD_PKG_DIR/$NOTES_OLD_PKG_DIR_SUB/scripts/* ${NOTES_PKG_DIR}/BABlotusagt/scripts/ >/dev/null 2>&1
#       cp -R $NOTES_OLD_PKG_DIR/$NOTES_OLD_PKG_DIR_SUB/scripts/*.sample ${NOTES_PKG_DIR}/BABlotusagt/scripts/ >/dev/null 2>&1
#       cp -R $NOTES_OLD_PKG_DIR/$NOTES_OLD_PKG_DIR_SUB/scripts/*.lst ${NOTES_PKG_DIR}/BABlotusagt/scripts/ >/dev/null 2>&1
}

Update_Sapcfg()
{
	SAP_PREFIX=${SAP_PKG_DIR}
	if [ "X${SAP_PREFIX}" = "X" ]; then
		CAS_HOME_SAP="/opt/CA/BABsapagt"
	elif [ "X${SAP_PREFIX}" = "X/" ]; then
		CAS_HOME_SAP="/BABsapagt"
	else
		CAS_HOME_SAP="${SAP_PREFIX}/BABsapagt"
	fi
	cp -Rp ${SAP_OLD_PKG_DIR}/${SAP_OLD_PKG_DIR_SUB}/init*.utl ${SAP_PREFIX:-/opt/CA}/BABsapagt/ 2>/dev/null
	if [ ! -d ${SAP_PREFIX:-/opt/CA}/BABsapagt/logs ]; then
		mkdir ${SAP_PREFIX:-/opt/CA}/BABsapagt/logs  >/dev/null 2>&1
	fi
	cp -Rp ${SAP_OLD_PKG_DIR}/${SAP_OLD_PKG_DIR_SUB}/logs/* ${SAP_PREFIX:-/opt/CA}/BABsapagt/logs/ 2>/dev/null
	echo "" >>${AGENT_CFG}
	echo "[20]" >>${AGENT_CFG}
	echo "# SAP/Oracle Agent" >>${AGENT_CFG}
	echo "NAME    SAPAgent" >>${AGENT_CFG}
	echo "VERSION	12.5.0" >>${AGENT_CFG}
	echo "HOME    $CAS_HOME_SAP" >>${AGENT_CFG}
	echo "ENV     CAS_HOME_SAP=$CAS_HOME_SAP" >>${AGENT_CFG}
	TEMP_STR=`grep ORACLE_HOME $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	TEMP_STR=`grep SAPSID $OLD_AGENT_CFG 2>/dev/null`
	echo "$TEMP_STR" >>${AGENT_CFG}
	echo "ENV   LD_LIBRARY_PATH=/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:\$LD_LIBRARY_PATH" >>${AGENT_CFG}
	echo "ENV   SHLIB_PATH=/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:\$SHLIB_PATH" >>${AGENT_CFG}
	echo "ENV   LIBPATH=/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:\$LIBPATH" >>${AGENT_CFG}
	echo "#BROWSER" >>${AGENT_CFG}
	echo "AGENT   sapagentd" >>${AGENT_CFG}
}

Update_Db2cfg()
{
	DB2_PREFIX=${DB2_PKG_DIR}
	if [ "X${DB2_PREFIX}" = "X" ]; then
		CAS_ENV_DB2_AGENT_HOME="/opt/CA/BABdb2agt"
	elif [ "X${DB2_PREFIX}" = "X/" ]; then
		CAS_ENV_DB2_AGENT_HOME="/BABdb2agt"
	else
		CAS_ENV_DB2_AGENT_HOME="${DB2_PREFIX}/BABdb2agt"
	fi
	cp -p ${DB2_OLD_PKG_DIR}/${DB2_OLD_PKG_DIR_SUB}/instance.cfg ${DB2_PREFIX:-/opt/CA}/BABdb2agt/ 2>/dev/null
	sed -e "s%BEB%BAB%" ${DB2_OLD_PKG_DIR}/${DB2_OLD_PKG_DIR_SUB}/sqluv.cfg > ${DB2_PREFIX:-/opt/CA}/BABdb2agt/sqluv.cfg 2>/dev/null
	sed -e "s%BrightStorEB%BrightStor ARCserve Backup%" ${DB2_PREFIX:-/opt/CA}/BABdb2agt/sqluv.cfg > ${DB2_PREFIX:-/opt/CA}/BABdb2agt/sqluv.cfg.old 2>/dev/null
	mv -f ${DB2_PREFIX:-/opt/CA}/BABdb2agt/sqluv.cfg.old ${DB2_PREFIX:-/opt/CA}/BABdb2agt/sqluv.cfg >/dev/null 2>&1
	if [ ! -d ${DB2_PREFIX:-/opt/CA}/BABdb2agt/logs ]; then
		mkdir ${DB2_PREFIX:-/opt/CA}/BABdb2agt/logs  >/dev/null 2>&1
	fi
	cp -Rp ${DB2_OLD_PKG_DIR}/${DB2_OLD_PKG_DIR_SUB}/logs/* ${DB2_PREFIX:-/opt/CA}/BABdb2agt/logs/ 2>/dev/null
	if [ -f ${DB2_PREFIX:-/opt/CA}/BABdb2agt/sqluv.cfg ]; then
		TEMP_DB2=`grep "DB2_HOME_LOCATION_DIR" ${DB2_PREFIX:-/opt/CA}/BABdb2agt/sqluv.cfg 2>/dev/null`
		if [ "X$TEMP_DB2" != "X" ]; then
			DB2_HOME_LOC=`echo $TEMP_DB2 | awk -F"=" '{ print $2 }'`
		fi
	fi
	echo "" >>${AGENT_CFG}
	echo "[37]" >>${AGENT_CFG}
	echo "# DB2 UDB Agent" >>${AGENT_CFG}
	echo "NAME    DB2 UDB Agent" >>${AGENT_CFG}
	echo "VERSION	12.5.0" >>${AGENT_CFG}
	echo "HOME   $CAS_ENV_DB2_AGENT_HOME" >>${AGENT_CFG}
	echo "ENV    CAS_ENV_DB2_AGENT_HOME=$CAS_ENV_DB2_AGENT_HOME" >>${AGENT_CFG}
	echo "#ENV    CAS_HOME=${BEB_PKG_DIR:-/opt/CA}/BrightStorARCserve" >>${AGENT_CFG}
	echo "ENV     CAS_INITIATED=1" >>${AGENT_CFG}
	if [ "$OS" = "SunOS" ]; then
		echo "ENV   LD_LIBRARY_PATH=/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:${DB2_HOME_LOC}/lib:$CAS_ENV_DB2_AGENT_HOME/lib:\$LD_LIBRARY_PATH" >>${AGENT_CFG}
	elif [ "$OS" = "HP-UX" ]; then
		echo "ENV   SHLIB_PATH=/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:${DB2_HOME_LOC}/lib:$CAS_ENV_DB2_AGENT_HOME/lib:\$SHLIB_PATH" >>${AGENT_CFG}
	elif [ "$OS" = "AIX" ]; then
		echo "ENV   LIBPATH=/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:${DB2_HOME_LOC}/lib:$CAS_ENV_DB2_AGENT_HOME/lib:\$LIBPATH" >>${AGENT_CFG}
	fi
	echo "BROWSER casdb2br" >>${AGENT_CFG}
	echo "AGENT   casdb2agtd" >>${AGENT_CFG}
	cd ${DB2_PREFIX:-/opt/CA}/BABdb2agt
	${DB2_PREFIX:-/opt/CA}/BABdb2agt/userexitupdate -s >> ${LOG_FILE} 2>&1
	cd ${PKG_LOCATION}
}

Update_Ingcfg()
{
	ING_PREFIX=${ING_PKG_DIR}
	if [ "X${ING_PREFIX}" = "X" ]; then
		CA_ENV_INGRES_AGENT_HOME="/opt/CA/BABingagt"
	elif [ "X${ING_PREFIX}" = "X/" ]; then
		CA_ENV_INGRES_AGENT_HOME="/BABingagt"
	else
		CA_ENV_INGRES_AGENT_HOME="${ING_PREFIX}/BABingagt"
	fi
	cp -p ${ING_OLD_PKG_DIR}/${ING_OLD_PKG_DIR_SUB}/installation.cfg ${ING_PREFIX:-/opt/CA}/BABingagt/ 2>/dev/null
	cp -p ${ING_OLD_PKG_DIR}/${ING_OLD_PKG_DIR_SUB}/cktmpl.def ${ING_PREFIX:-/opt/CA}/BABingagt/cktmpl.def.v10 2>/dev/null
	if [ ! -d ${ING_PREFIX:-/opt/CA}/BABingagt/logs ]; then
		mkdir ${ING_PREFIX:-/opt/CA}/BABingagt/logs  >/dev/null 2>&1
	fi
	cp -Rp ${ING_OLD_PKG_DIR}/${ING_OLD_PKG_DIR_SUB}/logs/* ${ING_PREFIX:-/opt/CA}/BABingagt/logs/ 2>/dev/null
	echo "" >>${AGENT_CFG}
	echo "[19]" >>${AGENT_CFG}
	echo "# Ingres Agent" >>${AGENT_CFG}
	echo "NAME    Ingres Agent" >>${AGENT_CFG}
	echo "VERSION	12.5.0" >>${AGENT_CFG}
	echo "HOME   $CA_ENV_INGRES_AGENT_HOME" >>${AGENT_CFG}
	echo "#ENV    CA_ENV_DEBUG_LEVEL=4" >>${AGENT_CFG}
	echo "ENV    CA_ENV_INGRES_AGENT_HOME=$CA_ENV_INGRES_AGENT_HOME" >>${AGENT_CFG}
	echo "#ENV      CAS_HOME=${BEB_PKG_DIR:-/opt/CA}/BrightStorARCserve" >>${AGENT_CFG}
	echo "ENV     CAS_INITIATED=1" >>${AGENT_CFG}
	echo "ENV     NLS_LANG=american" >>${AGENT_CFG}
	echo "ENV     NLS_DATE_FORMAT=MM/DD/YYYY/HH24:MI:SS" >>${AGENT_CFG}
	if [ "$OS" = "SunOS" ]; then
		echo "ENV   LD_LIBRARY_PATH=$CA_ENV_INGRES_AGENT_HOME:/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:\$LD_LIBRARY_PATH" >>${AGENT_CFG}
	elif [ "$OS" = "HP-UX" ]; then
		echo "ENV   SHLIB_PATH=$CA_ENV_INGRES_AGENT_HOME:/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:\$SHLIB_PATH" >>${AGENT_CFG}
	elif [ "$OS" = "AIX" ]; then
		echo "ENV   LIBPATH=$CA_ENV_INGRES_AGENT_HOME:/opt/CA/CAlib:${CALIB}:/opt/CA/BABcmagt:\$LIBPATH" >>${AGENT_CFG}
	fi
	echo "BROWSER ingresbr" >>${AGENT_CFG}
	echo "AGENT   ingresd" >>${AGENT_CFG}
}

Update_Uagcfg()
{
	if [ -d ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB} ]; then
		cp -p ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB}/fs.cntl ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/ 2>/dev/null
		echo "
# new implementations
#
# * Linux *
#
usbdevfs
devpts
binfmt_misc
shm
sysfs
usbfs
subfs
nfsd
#
# * CDFS *
#
cdfs
cdrfs
cdrom
hsfs
iso9660
supermount
#
# * Solaris 10 *
#
ctfs
lofs
objfs
swap
" >> ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/fs.cntl
		cp -p ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB}/cabr.cfg ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/cabr.cfg.upg 2>/dev/null
		cp -p ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB}/groom.cntl ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/groom.cntl.upg 2>/dev/null
		cp -p ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB}/mergescan.cfg ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/mergescan.cfg.upg 2>/dev/null
		cp -p ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB}/uag.cfg ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cfg.upg 2>/dev/null
		cp -p ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB}/uag.cntl ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cntl.upg 2>/dev/null
		cp -p ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB}/uagres.cntl ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uagres.cntl.upg 2>/dev/null
		if [ ! -d ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/logs ]; then
			mkdir ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/logs  >/dev/null 2>&1
		fi
		cp -Rp ${UAGENT_OLD_PKG_DIR}/${UAGENT_OLD_PKG_DIR_SUB}/logs/* ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/logs/ 2>/dev/null
		for cfgfile in cabr.cfg groom.cntl mergescan.cfg uag.cfg uag.cntl uagres.cntl
		do 
			if [ -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile}.upg ];then
				merge_file ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile}.upg ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile} ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile}.new 2>/dev/null
				mv -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile}.new ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile}
			fi
		done
		if [ -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cfg.upg ]; then
			$GREP "^#" ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cfg > ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cfg.old
			$GREP -v "^#" ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cfg.upg >> ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cfg.old
			mv -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cfg.old ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cfg
		fi
		if [ -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cntl.upg ]; then
			$GREP "^#" ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cntl > ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cntl.old
			$GREP -v "^#" ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cntl.upg >> ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cntl.old
			mv -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cntl.old ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/uag.cntl
		fi
		if [ -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/mergescan.cfg.upg ]; then
			cp -p ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/mergescan.cfg.upg ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/mergescan.cfg		
		fi
	fi
}
merge_file ()
{
        if [ $# -ne 3 ]
        then
                return
        fi
        in_file1=$1
        in_file2=$2
        out_file=$3
        CAT=cat
        if [ "${OS}" = "SunOS" -o "${OS}" = "HP-UX" ]; then
        	THE_GREP="grep"
        else
        	THE_GREP="egrep"
        fi
        

        list_in_file2=`$CAT $in_file2 | $EGREP -v "(^#|^ *$)" | $AWK ' {if ( length(comon_list) > 0) {
                        comon_list=sprintf("%s|^%s" ,comon_list,$1)
                        }
                        else
                        {
                        comon_list=sprintf("^%s" ,$1)
                        }
                        }
                        END{
                        if ( length(comon_list) > 0 ) {
                        printf("%s", comon_list)
                        }
                        else
                        {
                        print
                        }
                        }

                        ' `

        if [  "${list_in_file2}" != "" ]
        then
                list_comm=` ${THE_GREP} -w "(${list_in_file2})" ${in_file1} 2>/dev/null |  $AWK ' {if ( length(comon_list) > 0) {
                        comon_list=sprintf("%s|^%s" ,comon_list,$1)
                        }
                        else
                        {
                        comon_list=sprintf("^%s" ,$1)
                        }
                        }
                        END{
                        if ( length(comon_list) > 0 ) {
                        printf("%s", comon_list)
                        }
                        else
                        {
                        print
                        }
                        }

                        ' `

        fi

        if [ "X${list_comm}" != "X" ]
        then
               grep_common="${THE_GREP} -w  ($list_comm) 2>/dev/null "
               grep_no_common="${THE_GREP} -w -v ($list_comm) 2>/dev/null "

               ${CAT} $in_file2 | ${EGREP} "^#" > $out_file
               #option in both files
               ${CAT} $in_file1 | ${EGREP} -v "(^#|^ *$)" | $grep_common >> $out_file
               #option only in file 1
               ${CAT}  $in_file1 | ${EGREP} -v "(^#|^ *$)" | $grep_no_common >> $out_file
               #option only in file 2
               ${CAT} $in_file2 | ${EGREP} -v "(^#|^ *$)" | $grep_no_common >> $out_file
        else


               ${CAT}  $in_file2 | ${EGREP}  "^#"  > $out_file
               #option only in file 1
               ${CAT}  $in_file1 | ${EGREP} -v "(^#|^ *$)" >> $out_file
               #option only in file 2
               ${CAT}  $in_file2 | ${EGREP} -v "(^#|^ *$)"  >> $out_file
        fi
}

Update_Agent()
{
	Agent_type=$1
	
	AGENT_CFG=/opt/CA/BABcmagt/agent.cfg
	OLD_AGENT_CFG=/opt/CA/BABcmagt/agent.cfg.v10
	if [ $Agent_type -eq 36 ]; then
		cp -p ${CAAGENT_OLD_PKG_DIR}/agent.cfg ${OLD_AGENT_CFG} 2>/dev/null
		cp -p ${CAAGENT_OLD_PKG_DIR}/nls/nls.cfg /opt/CA/BABcmagt/nls/nls.cfg.v10 2>/dev/null
		if [ ! -d /opt/CA/BABcmagt/logs ]; then
			mkdir /opt/CA/BABcmagt/logs  >/dev/null 2>&1
		fi
		cp -p ${CAAGENT_OLD_PKG_DIR}/logs/* /opt/CA/BABcmagt/logs/ 2>/dev/null
	fi
	if [ -f ${OLD_AGENT_CFG} ]; then
		grep "\[${Agent_type}\]" ${OLD_AGENT_CFG} >/dev/null 2>&1
		if [ $? -ne 0 -a $Agent_type -ne 100 ]; then
			return $?
		fi
	fi
	grep "^\[${Agent_type}\]" ${AGENT_CFG} >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		return 0
	fi

	if [ $EXEC_MODE -eq $SDO_MODE ]; then #
		if [ -f ${OLD_AGENT_CFG} ]; then
			TCP_PORT=`grep "TCP_PORT" ${OLD_AGENT_CFG} | grep -v "6051"`
			if [ "$TCP_PORT" != "" ]; then
				sed -e "s%#TCP_PORT  6051%${TCP_PORT}%" /opt/CA/BABcmagt/agent.cfg > /opt/CA/BABcmagt/agent.cfg.old
				cp /opt/CA/BABcmagt/agent.cfg.old /opt/CA/BABcmagt/agent.cfg >/dev/null 2>&1
			fi
			UDP_PORT=`grep "UDP_PORT" ${OLD_AGENT_CFG} | grep -v "6051"`
			if [ "$UDP_PORT" != "" ]; then
				sed -e "s%#UDP_PORT  6051%${UDP_PORT}%" /opt/CA/BABcmagt/agent.cfg > /opt/CA/BABcmagt/agent.cfg.old
				cp /opt/CA/BABcmagt/agent.cfg.old /opt/CA/BABcmagt/agent.cfg >/dev/null 2>&1
			fi
			ENABLE_FLAG_OLD=`grep "\[36\]" ${OLD_AGENT_CFG}`
			if [ "$ENABLE_FLAG_OLD" != "" ]; then
				sed -e s/"\[36\] DISABLED"/"${ENABLE_FLAG_OLD}"/ /opt/CA/BABcmagt/agent.cfg > /opt/CA/BABcmagt/agent.cfg.old
				cp /opt/CA/BABcmagt/agent.cfg.old /opt/CA/BABcmagt/agent.cfg >/dev/null 2>&1
			fi
		fi
	fi
	if [ $Agent_type -eq 22 ]; then #Oracle Agent
	  Update_Oracfg
	elif [ $Agent_type -eq 100 -a $EXEC_MODE -ne $SDO_MODE ]; then #
		if [ -f ${OLD_AGENT_CFG} ]; then
			TCP_PORT=`grep "TCP_PORT" ${OLD_AGENT_CFG} | grep -v "6051"`
			if [ "$TCP_PORT" != "" ]; then
				sed -e "s%#TCP_PORT  6051%${TCP_PORT}%" /opt/CA/BABcmagt/agent.cfg > /opt/CA/BABcmagt/agent.cfg.old
				cp /opt/CA/BABcmagt/agent.cfg.old /opt/CA/BABcmagt/agent.cfg >/dev/null 2>&1
			fi
			UDP_PORT=`grep "UDP_PORT" ${OLD_AGENT_CFG} | grep -v "6051"`
			if [ "$UDP_PORT" != "" ]; then
				sed -e "s%#UDP_PORT  6051%${UDP_PORT}%" /opt/CA/BABcmagt/agent.cfg > /opt/CA/BABcmagt/agent.cfg.old
				cp /opt/CA/BABcmagt/agent.cfg.old /opt/CA/BABcmagt/agent.cfg >/dev/null 2>&1
			fi
			ENABLE_FLAG_OLD=`grep "\[36\]" ${OLD_AGENT_CFG}`
			if [ "$ENABLE_FLAG_OLD" != "" ]; then
				sed -e s/"\[36\] DISABLED"/"${ENABLE_FLAG_OLD}"/ /opt/CA/BABcmagt/agent.cfg > /opt/CA/BABcmagt/agent.cfg.old
				cp /opt/CA/BABcmagt/agent.cfg.old /opt/CA/BABcmagt/agent.cfg >/dev/null 2>&1
			fi
			
		fi
	elif [ $Agent_type -eq 14 ]; then #Notes Agent
	  Update_Notescfg
	elif [ $Agent_type -eq 34 ]; then #Nas Agent
	  Update_Nascfg
	elif [ $Agent_type -eq 30 ]; then #Sybase Agent
	  Update_Sybcfg
	elif [ $Agent_type -eq 32 ]; then #Informix Agent
	  Update_Infcfg
	elif [ $Agent_type -eq 20 ]; then #Sap Agent
	  Update_Sapcfg
	elif [ $Agent_type -eq 37 ]; then #DB2 Agent
	  Update_Db2cfg
	elif [ $Agent_type -eq 19 ]; then #IngresII Agent
	  Update_Ingcfg
	fi
}
 
INSTALL_CMAGT()
{
if [ "$CAAGENT_INSTALLED_ALREADY" = "YES" ]; then
	echo >/dev/null
else
	    Install_License_Package
	    CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
	    if [ "$CA7CMAGTPKG" = "" -o $CAAGENT_NEED_UPGRADE -eq 1 ] # install BABcmagt package
	    then
	       if [ $EXEC_MODE -eq $SDO_MODE -a "$CMAGT_INSTALL" != "YES" ] ; then
		       echo "$BK_LINE_FLAG    Common Agent Module(BABcmagt)           ==> [ ${INST_MSG_203} ]"
		       exit 3
	       fi
	if [ $CAAGENT_NEED_UPGRADE -eq 1 ]; then
	        sed -e "s%11.1.0%12.5.0%" /opt/CA/BABcmagt/agent.cfg > /opt/CA/BABcmagt/agent.cfg.v11 2>/dev/null
	        echo "    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_216} ]\c"
	elif [ $ASAGENT_OLD_INSTALLED -ne 1 ]; then
	        echo "    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_62} ]\c"
	else
	        echo "    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_141} ]\c"
	fi
	        startDial &
	        DIALPID=$!
	        Untar_Package $CMAGT_PKG
	if [ $CAAGENT_NEED_UPGRADE -eq 1 ]; then
		if [ "$OS" = "SunOS" ]; then
		        Create_Package_Response $CMG_PKG ASAGENT_HOME /opt/CA BABcmagt
		        $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${CMG_PKG}.pkgask -a $TMPDIR/$PID/admin $CMG_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
		elif [ "$OS" = "HP-UX" ]; then
		        $PKGADD $TMPDIR/$PID/tmppkg.d -x reinstall=true $CMG_PKG >> ${LOG_FILE}  2>&1
		elif [ "$OS" = "AIX" ]; then
	                $PKGADD $TMPDIR/$PID/tmppkg.d -F $CMG_PKG >> ${LOG_FILE}  2>&1
		elif [ "$OS" = "OSF1" ]; then
		        $PKGADD $TMPDIR/$PID/tmppkg.d $CMG_PKG >> ${LOG_FILE}  2>&1
		elif [ "$OS" = "FreeBSD" ]; then
		        $PKGRM -f ${CMG_PKG} >> ${LOG_FILE}  2>&1
		        $PKGADD -f $TMPDIR/$PID/tmppkg.d/${CMG_PKG}.tgz >> ${LOG_FILE}  2>&1
		fi
	else
		if [ "$OS" = "SunOS" ]; then
		        Create_Package_Response $CMG_PKG ASAGENT_HOME /opt/CA BABcmagt
		        $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${CMG_PKG}.pkgask $CMG_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
		elif [ "$OS" = "HP-UX" ]; then
		        $PKGADD $TMPDIR/$PID/tmppkg.d $CMG_PKG >> ${LOG_FILE}  2>&1
		elif [ "$OS" = "AIX" ]; then
		        $PKGADD $TMPDIR/$PID/tmppkg.d $CMG_PKG >> ${LOG_FILE}  2>&1
		elif [ "$OS" = "OSF1" ]; then
		        $PKGADD $TMPDIR/$PID/tmppkg.d $CMG_PKG >> ${LOG_FILE}  2>&1
		elif [ "$OS" = "FreeBSD" ]; then
		        $PKGADD -f $TMPDIR/$PID/tmppkg.d/${CMG_PKG}.tgz >> ${LOG_FILE}  2>&1
		fi
	fi
	                  install_status=$?
		$NLS_UTILITY_FILE -u /opt/CA/BABcmagt/nls/nls.cfg CA_NLS_LANG $NLS_LANG $NLS_LOCALE
		/opt/CA/BABcmagt/caagentsetup > /dev/null 2>&1
	        cd $HOMEDIR
	        rm -rf $TMPDIR/$PID/tmppkg.d
	        if [ $install_status -eq 0 ]
	                  then
	           if [ ${CFGAGTAUTOSTRTSTOP} -eq 1 ]
	                then
	              if [ -x /opt/CA/BABcmagt/caagent_autostrtstop ]
	                        then
	                           /opt/CA/BABcmagt/caagent_autostrtstop y
	              fi
	           fi
	                     stopDial
	if [ $CAAGENT_NEED_UPGRADE -eq 1 ]; then
	           cp /opt/CA/BABcmagt/agent.cfg.v11 /opt/CA/BABcmagt/agent.cfg >/dev/null 2>&1
	           rm -f /opt/CA/BABcmagt/agent.cfg.v11 >/dev/null 2>&1
	           Update_Agent_36
	           echo "$BK_LINE_FLAG    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_217} ]   "
	elif [ $ASAGENT_OLD_INSTALLED -ne 1 ]; then
	           echo "$BK_LINE_FLAG    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_63} ]   "
	else
	           Update_Agent 36
	           Update_Agent_36
	           echo "$BK_LINE_FLAG    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_142} ]   "
	fi
	           CAAGENT_NEED_UPGRADE=0
		if [ ! -r ${DSPKG_LST} ]; then
			/opt/CA/BABcmagt/dsCheckPkgs >/dev/null 2>&1
		fi
	        else
	                     stopDial
	if [ $CAAGENT_NEED_UPGRADE -eq 1 ]; then
	           echo "$BK_LINE_FLAG    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_218} ]"
	elif [ $ASAGENT_OLD_INSTALLED -ne 1 ]; then
	           echo "$BK_LINE_FLAG    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_64} ]"
	else
	           echo "$BK_LINE_FLAG    Common Agent Module                      ($CMG_PKG)       ==> [ ${INST_MSG_168} ]"
	fi
	        fi
	   else
	       if [ $EXEC_MODE -eq $SDO_MODE -a "$CMAGT_INSTALL" = "YES" ] ; then
		       echo "$BK_LINE_FLAG    Common Agent Module($CMG_PKG)           ==> [ ${INST_MSG_100} ]"
		       CLEANUP 4
	
	       fi
	   fi
	if [ "${OS}" = "AIX" ]; then
	    Modify_Nls_Cfg
	fi
	CAAGENT_INSTALLED_ALREADY="YES"
fi
}

startDial ()
{
    if [ $EXEC_MODE -ne $REGR_MODE ]
    then
        return
    fi
   echo "| \c"
   while [ 1 ]
   do
      sleep 1
      echo "\b\b/ \c"
      sleep 1
      echo "\b\b- \c"
      sleep 1
      echo "\b\b\\ \c"
      sleep 1
      echo "\b\b| \c"
                if [ -f ${DIALTMPFILE} ]
                then
                        rm -f ${DIALTMPFILE}
                        break
                fi
   done
}

stopDial ()
{
    if [ $EXEC_MODE -ne $REGR_MODE ]
    then
        return
    fi
        touch ${DIALTMPFILE}

        sleep 1
        count=0
        rc=1

        while [ ${count} -le 3 ]
        do
           if [ -f ${DIALTMPFILE} ]
                then
                        sleep 2
                else
                        rc=0
                        break
                fi
                count=`expr ${count} + 1`
        done

        if [ ${rc} -ne 0 ]
        then
                kill -9 ${DIALPID} >/dev/null 2>&1
                rm -f ${DIALTMPFILE}
        fi
}

dialCleanup ()
{
   kill -9 ${DIALPID} >/dev/null 2>&1
        rm -f ${DIALTMPFILE}
}

displayLogLocation()
{ 
        if [ "X${INSTALL_CHOICE}" != "X" ]; then
    		num_choices=`echo $INSTALL_CHOICE | awk -F, '{print NF}'`
        else
        	num_choices=0
        fi
        if [ $num_choices -ge 1 -o $BEB_COMPONENTS_MIGRATION -eq 1 -o $BAB_COMPONENTS_UPGRADE -eq 1 ]; 
    then
        echo
        echo "${INST_MSG_65}                    ==> [ ${LOG_FILE} ]"
        echo
    fi
}

cfgAgtStrtStop ()
{
	if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ] ; then
	        if [ "${AGENTS_AUTO_START}" = "YES" ] ; then
	        	CFGAGTAUTOSTRTSTOP=1
	        else
	        	CFGAGTAUTOSTRTSTOP=0
	        fi
	else
	    echo "${INST_MSG_66}"
	        echo "${INST_MSG_67}" 
	    getyn "${INST_MSG_68}" 1
	    if [ $? -eq 1 ]
	    then
	        if [ $EXEC_MODE -eq $RESP_MODE ]
	        then
	            AGENTS_AUTO_START="YES"
	        fi
	        CFGAGTAUTOSTRTSTOP=1
	    else
	        if [ $EXEC_MODE -eq $RESP_MODE ]
	        then
	            AGENTS_AUTO_START="NO"
	        fi
	        CFGAGTAUTOSTRTSTOP=0
	    fi
	fi
}

getyn ()
{
   if [ "$2" = 1 ] ; then
      default="y"
   else
      default="n"
   fi
   echo  "$1? [y|n]:(${INST_MSG_69}: $default) \c"
   while read answer
   do
      if [ -z "$answer" ] ; then
         answer=$default
      fi
      case "$answer" in
         y*|Y*) YES=1;break;;
         n*|N*) YES=0;break;;
         *) echo "$1? [y|n]:(${INST_MSG_69}: $default) \c"
      esac
   done
   return $YES
}

# function removed temporarily for aix
#
create_beb_group()
{
    BEB_GROUP_CREATED=1
}

create_group()
{
   #choice=0 means bab group
   #choice=1 means uagent group
   choice=$1

   if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ] ; then
	   if [ $choice -eq 0 ]
	   then
	      BEB_GROUP_CREATED=1
	      BEB_GROUP_ID=${SERVER_GROUP_ID}
	   else
	      UAGENT_GROUP_CREATED=1
	      UAGENT_GROUP_ID=${UAGENT_GROUP_ID}
	   fi
   else
	   if [ $choice -eq 0 ]
	   then
	      if [ $BEB_GROUP_CREATED -eq 1 ]
	      then
	         return
	      fi
	      grpName="bab"
	   else
	      if [ $UAGENT_GROUP_CREATED -eq 1 ]
	      then
	         return
	      fi
	      grpName="uagent"
	   fi
	
	   echo
	   printf "${INST_MSG_126}" "${grpName}"
	   getyn "${INST_MSG_127}" 0
	
	   if [ $? -eq 1 ]
	   then
	      #User wants to provide GID
	      while [ 1 ]
	      do
	         printf "${INST_MSG_128}" "${grpName}"
	         read VAL
	         expr "$VAL" + 1 >/dev/null 2>&1
	         if [ $? -ge 2 ]
	         then
	            echo ""
	            echo "${INST_MSG_129}"
	            echo ""
	            continue
	         fi
	        if [ $EXEC_MODE -eq $RESP_MODE ]
	        then
	            break
	        fi
#	         echo
#	         echo "$INST_MSG_179"
#	         echo
	         groupadd -g $VAL ${grpName} >/dev/null 2>&1
	         case $? in
	            1)
	               echo ""
	               printf "${INST_MSG_153}" "${grpName}"
	               echo ""
	               continue
	               ;;
	            4)
	               echo ""
	               echo "${INST_MSG_130}"
	               echo ""
	               continue
	               ;;
	            9)
	               echo ""
	               printf "${INST_MSG_133}" "${grpName}"
	               echo ""
	               break
	               ;;
	         esac
	         break
	      done
	   fi
	
	   #Note : If user does not want to provide GID
	   #Group would be created as part of pre-install
	   echo
	   if [ $choice -eq 0 ]
	   then
	      BEB_GROUP_CREATED=1
	      BEB_GROUP_ID=${grpName}
	   else
	      UAGENT_GROUP_CREATED=1
	      UAGENT_GROUP_ID=${grpName}
	   fi
   fi
}

Implicit_Requirements()
{
cmg_space=5
license_space=2
OPTDIR_NEW_CREATE=0

if [ "$OS" = "SunOS" -o "$OS" = "OSF1" -o "$OS" = "FreeBSD" ]; then
  available=`df -k / | $AWK '{ if (NR == 2){ print $4 } }'` 
elif [ "$OS" = "HP-UX" ]; then
  available=`df -b / | $AWK '{ if (NR == 1){ print $(NF-2) } }'` 
elif [ "$OS" = "AIX" ]; then
  available=`df -k / | $AWK '{ if (NR == 2){ print $3 } }'` 
fi
  available=`expr $available / 1024` ## break it down to megs
  if [ $available -lt $license_space ]
  then
#    printf "${INST_MSG_18}\n" "$license_space"
    printf "${INST_MSG_70}\n" "$license_space" "/"
    echo "         ${INST_MSG_23}"
    CLEANUP 11
  fi

if [ "$BEB_CMG_REQUESTED" = "1" ]; then
	if [ ! -d /opt/CA ]; then
		mkdir -p /opt/CA >/dev/null 2>&1
		OPTDIR_NEW_CREATE=1
	fi
	if [ "$OS" = "SunOS" -o "$OS" = "OSF1" -o "$OS" = "FreeBSD" ]; then
	  available=`df -k /opt/CA | $AWK '{ if (NR == 2){ print $4 } }'` 
	elif [ "$OS" = "HP-UX" ]; then
	  available=`df -b /opt/CA | $AWK '{ if (NR == 1){ print $(NF-2) } }'` 
	elif [ "$OS" = "AIX" ]; then
	  available=`df -k /opt/CA | $AWK '{ if (NR == 2){ print $3 } }'` 
	else
	  available=`df -k /opt/CA | $AWK '{ if (NR == 2){ print $4 } }'` 
	fi
	available=`expr $available / 1024` ## break it down to megs
	if [ $available -lt $cmg_space ]
	  then
	    echo "${INST_MSG_71}"
#	    printf "         ${INST_MSG_18}\n" "$cmg_space"
	    printf "${INST_MSG_72}\n" "$cmg_space" "/opt"
	    echo "         ${INST_MSG_23}"
		if [ $OPTDIR_NEW_CREATE -eq 1 ]; then
			rmdir /opt/CA >/dev/null 2>&1
		fi
	    CLEANUP 11
	fi
fi
}

INSTALL_PATCH()
{
 OLD_PATCH=`/usr/sbin/setld -i | egrep "CXXLIB|CXXREDIST" | grep install | grep -v "not installed" | cut -f1 -d' '`
 if [ "${OLD_PATCH}X" = "X" ]; then
  :
 else
  /usr/sbin/setld -d $OLD_PATCH
 fi
 
 cd $TMPDIR/$PID
 mkdir -p patch
 cd patch
 $UNTAR $CPATCH
 /usr/sbin/setld -l $CKIT CXXREDIST650
 cd ..
 rm -rf patch
 cd $HOMEDIR
}

version_compare()
{
	if [ $# -eq 2 ]
	then
		LEFT=$1
		RIGHT=$2
		
		LEFT_1=`echo $LEFT | cut -d"." -f1`
		LEFT_2=`echo $LEFT | cut -d"." -f2`
		LEFT_3=`echo $LEFT | cut -d"." -f3`
		
		RIGHT_1=`echo $RIGHT | cut -d"." -f1`
		RIGHT_2=`echo $RIGHT | cut -d"." -f2`
		RIGHT_3=`echo $RIGHT | cut -d"." -f3`	
		
		LEFT_1=${LEFT_1:-0}
		LEFT_2=${LEFT_2:-0}
		LEFT_3=${LEFT_3:-0}
		RIGHT_1=${RIGHT_1:-0}
		RIGHT_2=${RIGHT_2:-0}
		RIGHT_3=${RIGHT_3:-0}		

		if [ $LEFT_1 -eq $RIGHT_1  -a $LEFT_2 -eq $RIGHT_2 -a $LEFT_3 -eq $RIGHT_3 ] #=
		then
			echo 0
		elif  [ $LEFT_1 -lt $RIGHT_1  ] || [ $LEFT_1 -eq $RIGHT_1  -a $LEFT_2 -lt  $RIGHT_2  ] || [  $LEFT_1 -eq $RIGHT_1  -a $LEFT_2 -eq  $RIGHT_2  -a $LEFT_3 -lt $RIGHT_3 ] #left<right
		then
			echo 2
		else #left > right
			echo 1
		fi
	else
		echo 3
	fi
}

CHECK_PLATFORM()
{
  OS_TOO_NEW=0
  OS=`uname -s`

  case $OS in
  SunOS)
        THE_OSFLAG=".BrightStorARCserveSolaris"
        HW=`uname -m`
        case $HW in
        i86pc)
                if [ -d /kernel/amd64 ]; then
                	OSTYPE=`isainfo -b`
                	if [ $OSTYPE -eq 64 ]; then
                		THE_OSFLAG=".BrightStorARCserves86.amd64"
                		PLATFORM=s86-amd64
                	else
                		THE_OSFLAG=".BrightStorARCserves86.64"
                		PLATFORM=s86
                	fi
                else
                	THE_OSFLAG=".BrightStorARCserves86.64"
                	PLATFORM=s86
                fi
                ;;
        *)
                REL=`uname -r`
                case $REL in
                4*)
                        PLATFORM=sun4
                        ;;
                5.[6]*)
                        PLATFORM=sun5-6
                        ;;
                5.[789]*|5.1[0]*)
                        PLATFORM=sun5
                        ;;
                *)
        		rtn=$(version_compare $REL "5.9")
			if [ $rtn -eq 2 ]
			then
				OS_TOO_NEW=1
			fi

                esac
                ;;
        esac
        ;;

  AIX)
        THE_OSFLAG=".BrightStorARCserveAix"
        LEVEL=`oslevel`
        case $LEVEL in
        4.3.2.*|4.3.3.*|5.*.*.*)
          PLATFORM=aix
          ;;
        *)
		TMPREL=`echo $LEVEL | cut -d"." -f1`
		rtn=$(version_compare $TMPREL "5")
		if [ $rtn -eq 2 ]
		then
			OS_TOO_NEW=1
		fi
        esac
        ;;

  HP-UX)
        THE_OSFLAG=".BrightStorARCserveHP11"
        HW=`uname -r`
        case $HW in
        *.11.*)
                PLATFORM=hp11
                ;;
        *.10.*) 
                PLATFORM=hp10
                ;;
        *)
                
		TMPREL=`echo $HW | cut -d"." -f2`
		rtn=$(version_compare $TMPREL "11")
                if [ $rtn -eq 2 ]; then
                	OS_TOO_NEW=1
                else
	                HW=`uname -m`
	                case $HW in
	                9000/7*)        
	                        PLATFORM=hp9.7
	                        ;;
	                9000/8*)
	                        PLATFORM=hp9.8
	                        ;;
	                esac
                fi
        esac
        ;;

  OSF1)
    LEVEL=`uname -r`
    case $LEVEL in
      V4.0*|V5.*)
        PLATFORM=osf
        PATCH=""
        if [ "$FLAG" = "1" ]; then
          if [ $EXEC_MODE -ne $RESP_MODE ]
          then
            if [ -f /usr/lib/cmplrs/cxx/libcxx.so ]; then
              PATCH=`nm /usr/lib/cmplrs/cxx/libcxx.so | grep libcxx_V | grep __libcxx_V60500001`
            fi

            if [ "${PATCH}X" = "X" ]; then
             echo
             echo "${INST_MSG_154}"
             echo "${INST_MSG_155}"
             echo "${INST_MSG_156}"
             echo "${INST_MSG_157}"

             if [ $EXEC_MODE -eq $REGR_MODE ]
             then
         	    getyn "${INST_MSG_158}" 1

         	    if [ $? -eq 1 ]; then
           	    	INSTALL_PATCH
         	    else
           	    	echo
           	    	CLEANUP 20
        	    fi
             else
               	INSTALL_PATCH
             fi
            fi
          fi
        fi
       ;;
    esac
        ;;

  FreeBSD)
        THE_OSFLAG=".BrightStorARCserveFreeBSD"
        PLATFORM=freebsd
        ;;
  *)
        PLATFORM=""
        ;;
  esac

  if [ ${OS_TOO_NEW} -eq 1 ]; then
	echo "$INST_MSG_190"
	if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
		GET_INSTALL_FLAG2
	else
		INSTALL_FLAG=1
	fi
	if [ $INSTALL_FLAG -ne 1 ];then
		echo 
		echo "$INST_MSG_60"
		echo
		exit 0
	fi
  elif [ "${PLATFORM}" != "osf" -a "${PLATFORM}" != "sun5" -a "${PLATFORM}" != "sun5-6" -a "${PLATFORM}" != "hp11" -a "${PLATFORM}" != "aix" -a "${PLATFORM}" != "s86" -a "${PLATFORM}" != "s86-amd64" -a "${PLATFORM}" != "freebsd" ]; then
        echo "${INST_MSG_73}${NORM}"
        echo
        echo "         ${INST_MSG_60}"
        echo
        exit 1
  fi
}

Select_Env()
{
	if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
		echo
		echo "${INST_MSG_74}"
		echo "${INST_MSG_75}"
		echo
		getyn "${INST_MSG_76}" 1
		if [ $? -eq 1 ]; then
		    if [ $EXEC_MODE -eq $RESP_MODE ]
		    then
		        PROFILE_MODIFY="YES"
		    fi
		  AUTO_SET_ENV=1
		else
		    if [ $EXEC_MODE -eq $RESP_MODE ]
		    then
		        PROFILE_MODIFY="NO"
		    fi
		  AUTO_SET_ENV=0
		fi
		echo
		echo "${INST_MSG_77}"
		echo "${INST_MSG_78}"
		echo
		echo
	else
		if [ "$PROFILE_MODIFY" = "YES" ] ; then
			AUTO_SET_ENV=1
		else
			AUTO_SET_ENV=0
		fi
	fi
}
Export_Env()
{
 OS=`uname -s`

 case $OS in
  HP-UX)
        BAB_HOME=$BEB_PKG_DIR/BrightStorARCserve; export BAB_HOME
        PATH=$BAB_HOME/bin:$BAB_HOME/sbin:$BAB_HOME/reports:$PATH; export PATH
        SHLIB_PATH=$BAB_HOME/lib:$SHLIB_PATH; export SHLIB_PATH
        MANPATH=$BAB_HOME/man:/usr/man:$MANPATH; export MANPATH
        ;;
  SunOS|OSF1|FreeBSD)
        BAB_HOME=$BEB_PKG_DIR/BrightStorARCserve; export BAB_HOME
        PATH=$BAB_HOME/bin:$BAB_HOME/sbin:$BAB_HOME/reports:$PATH; export PATH
        LD_LIBRARY_PATH=$BAB_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
        MANPATH=$BAB_HOME/man:/usr/man:$MANPATH; export MANPATH
        ;;
  AIX)
        BAB_HOME=$BEB_PKG_DIR/BrightStorARCserve; export BAB_HOME
        PATH=$BAB_HOME/bin:$BAB_HOME/sbin:$BAB_HOME/reports:$PATH; export PATH
        LIBPATH=$BAB_HOME/lib:$BAB_HOME/httpd/lib:/usr/lib:$LIBPATH; export LIBPATH
        MANPATH=$BAB_HOME/man:/usr/man:$MANPATH; export MANPATH
        ;;
 esac

}
Create_Env()
{
 cd $TMPDIR/$PID
 OS=`uname -s`

 echo "#  Modifications made by BrightStor ARCserve Backup" > env.bab
 echo "${INST_MSG_80}" >> env.bab

 case $OS in
  HP-UX)
        echo "    BAB_HOME=$BEB_PKG_DIR/BrightStorARCserve; export BAB_HOME" >> env.bab
        echo "    PATH=\$BAB_HOME/bin:\$BAB_HOME/sbin:\$BAB_HOME/reports:\$PATH; export PATH" >> env.bab
        echo "    SHLIB_PATH=\$BAB_HOME/lib:\$SHLIB_PATH; export SHLIB_PATH" >> env.bab
        echo "    MANPATH=\$BAB_HOME/man:/usr/man:\$MANPATH; export MANPATH" >> env.bab
        ;;
  SunOS|OSF1|FreeBSD)
        echo "    BAB_HOME=$BEB_PKG_DIR/BrightStorARCserve; export BAB_HOME" >> env.bab
        echo "    PATH=\$BAB_HOME/bin:\$BAB_HOME/sbin:\$BAB_HOME/reports:\$PATH; export PATH" >> env.bab
        echo "    LD_LIBRARY_PATH=\$BAB_HOME/lib:\$LD_LIBRARY_PATH; export LD_LIBRARY_PATH" >> env.bab
        echo "    MANPATH=\$BAB_HOME/man:/usr/man:\$MANPATH; export MANPATH" >> env.bab
        ;;
  AIX)
        echo "    BAB_HOME=$BEB_PKG_DIR/BrightStorARCserve; export BAB_HOME" >> env.bab
        echo "    PATH=\$BAB_HOME/bin:\$BAB_HOME/sbin:\$BAB_HOME/reports:\$PATH; export PATH" >> env.bab
        echo "    LIBPATH=\$BAB_HOME/lib:\$BAB_HOME/httpd/lib:/usr/lib:\$LIBPATH; export LIBPATH" >> env.bab
        echo "    MANPATH=\$BAB_HOME/man:/usr/man:\$MANPATH; export MANPATH" >> env.bab
        ;;
 esac

 echo "#  End Modifications made by BrightStor ARCserve Backup" >> env.bab
}

Modify_Profile()
{
CFGFILE=/etc/profile
CFGFILETMP=/etc/profile.tmp.$$

            cat $CFGFILE |awk 'BEGIN{flag=0;}{
                if (( $0 ~ /^#.*Modifications made by BrightStor ARCserve Backup/ ))
                {
                   flag=1
                }
                if (( $0 ~ /^#.*End Modifications made by BrightStor ARCserve Backup/ ))
                {
                   flag=0
                   continue
                }
                if ( flag == 1 )
                {
                   #DO NOTHING
                }
                else
                {
                   printf("%s\n",$0);
                }
            }' >>$CFGFILETMP

cp $CFGFILETMP $CFGFILE
rm -f $CFGFILETMP >/dev/null 2>&1
}

Set_Env()
{
Create_Env
echo
if [ $AUTO_SET_ENV -eq 1 ]; then
  echo "${INST_MSG_135} /etc/profile ..."
  Modify_Profile
  cat $TMPDIR/$PID/env.bab >> /etc/profile
fi
  echo "${INST_MSG_136}"
  cp $TMPDIR/$PID/env.bab /etc/.
  chmod +x /etc/env.bab
  /etc/env.bab >/dev/null 2>&1
}

install_igateway()
{
if [ "$PLATFORM" != "sun5-6" ]; then
    echo "    iGateway                                 (iGateway)       ==> [ ${INST_MSG_62} ]\c"
    startDial &
    DIALPID=$!
    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
    	$IGATEWAY_FILE -s >> ${LOG_FILE} 2>&1 #in silent mode will cause redirection error.
    else
    	$IGATEWAY_FILE -s >/dev/null 2>&1 
    fi
    install_status=$?
    stopDial
    if [ $install_status -eq 0 ]
    then
       echo "$BK_LINE_FLAG    iGateway                                 (iGateway)       ==> [ ${INST_MSG_63} ]   "
    elif [ $install_status -eq 1 ]
    then
        echo "$BK_LINE_FLAG    iGateway                                 (iGateway)       ==> [ ${INST_MSG_100} ]   "
    else
       echo "$BK_LINE_FLAG    iGateway                                 (iGateway)       ==> [ ${INST_MSG_64} ]"
    fi
fi
}

install_isponsor()
{
if [ "$PLATFORM" != "sun5-6" ]; then
    echo "    iSponsor                                 (iSponsor)       ==> [ ${INST_MSG_62} ]\c"
    startDial &
    DIALPID=$!
    if [ "$Portal_Server_Name" != "" ]; then
	    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
	      $ISPONSOR_FILE -s -P $Portal_Server_Name -f >> ${LOG_FILE} 2>&1 #in silent mode will cause redirection error.
	    else
	      $ISPONSOR_FILE -s -P $Portal_Server_Name -f >/dev/null 2>&1
	    fi
    else
	    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
		$ISPONSOR_FILE -s -f >> ${LOG_FILE} 2>&1 #in silent mode will cause redirection error.
	    else
	        $ISPONSOR_FILE -s -f >/dev/null 2>&1
	    fi
    fi
    install_status=$?
    stopDial
    if [ $install_status -eq 0 ]
    then
       echo "$BK_LINE_FLAG    iSponsor                                 (iSponsor)       ==> [ ${INST_MSG_63} ]   "
    elif [ $install_status -eq 9 ]
    then
        echo "$BK_LINE_FLAG    iSponsor                                 (iSponsor)       ==> [ ${INST_MSG_100} ]   "
    else
       echo "$BK_LINE_FLAG    iSponsor                                 (iSponsor)       ==> [ ${INST_MSG_64} ]"
    fi
fi
}

verify_license()
{
license_verified=0

echo
more $THE_LIC_FILE
for i in 1 2 3
do
  echo "\n${INST_MSG_82} \c"
  read ANS
  if [ "X${ANS}" = "X" ] ; then
  	ANS="N"
  fi
  case $ANS in
      Y|YES|y|yes)
        license_verified=1
        echo "\n${INST_MSG_83}\n"
        echo "${INST_MSG_84}\n"
        break
        ;;
      N|NO|n|no)
        echo "\n${INST_MSG_85}\n"
        echo "${INST_MSG_86}\n"
        break
        ;;
      *)
        echo "\n ${INST_MSG_16}"
        ;;
  esac
done

if [ "$license_verified" = "1" ]
then
        return 1;       
else 
        exit 1;
fi
}

check_patch()
{
# On HP UX, check if the gethrtime() system call is defined in libc.sl.
# This function is not part of the base OS and is installed by HP UX patches.
if [ `nm -op /lib/libc.sl | grep pwrite64 | grep T | wc -l` -eq 0 ]
then
  echo
  echo "${INST_MSG_137}"
  echo "${INST_MSG_138}"
  echo "${INST_MSG_139}"
  echo
  echo "\n${INST_MSG_140}\n"
  exit 1
fi
}

dskSpaceMsg ()
{
	 echo "${BOLD}${INST_MSG_87}" 
	 echo "${INST_MSG_88}"
	 echo "${INST_MSG_89}"
	 echo "${INST_MSG_90}${NORM}" 
         echo ""
    echo "${INST_MSG_91}\c"
    read junk
}

view_notes()
{
#if [ $EXEC_MODE -ne $RESP_MODE ]
#then
    getyn "${INST_MSG_92}" 1
    if [ $? -eq 1 ]
    then
	echo
	if [ ! -f ${INSTALL_NOTES} ]; then
		INSTALL_NOTES=${PKG_LOCATION}/install.txt
       	fi
       	more $INSTALL_NOTES
        echo "${INST_MSG_91}\c"
        read dummy
    fi
#else
#    getyn "${INST_MSG_93}" 1
#    if [ $? -eq 1 ]
#    then
#    	echo
#       	more $SILENT_INSTALL_NOTES
#        echo "${INST_MSG_91}\c"
#        read dummy
#    fi
#fi
echo
}


addOptionsToCprocess()
{
 CFGFILE=$NEW_HOME/config/cprocess.cfg
 if [ -f $CFGFILE ]
 then
   OPTION_CHECK=`grep "USE_BARCODE_SERNO_AS_MEDIA_NAME" $CFGFILE`
   if [ "$OPTION_CHECK" = "" ]
   then
     echo "# USE_BARCODE_SERNO_AS_MEDIA_NAME = TRUE" >> $CFGFILE
     echo "# This parameter allows the user to format the media using the barcode as the" >> $CFGFILE
     echo "# media name. If this parameter is commented out, the default media naming" >> $CFGFILE
     echo "# conventions will be used" >> $CFGFILE
     echo "" >> $CFGFILE
   fi
   OPTION_CHECK=`grep "ENHANCED_ENCRYPTION" $CFGFILE`
   if [ "$OPTION_CHECK" = "" ]
   then
     echo "ENHANCED_ENCRYPTION = TRUE" >> $CFGFILE
     echo "# This parameter allows the user to encrypt data using enhanced encryption" >> $CFGFILE
     echo "# methods" >> $CFGFILE
     echo "" >> $CFGFILE
   fi
   OPTION_CHECK=`grep "DEBUG_CPROCESS" $CFGFILE`
   if [ "$OPTION_CHECK" = "" ]
   then
     echo "DEBUG_CPROCESS = TRUE" >> $CFGFILE
     echo "# This parameter enables the cprocess in debug mode" >> $CFGFILE
     echo "" >> $CFGFILE
   else
     OPTION_EXIST_COMMENTED=`grep "DEBUG_CPROCESS" $CFGFILE | grep "^#"`
     if [ "$OPTION_EXIST_COMMENTED" != "" ]
     then
       TMPFILE=${BEB_HOME}/config/cprocess.cfg.$$
       sed -e "s/^#.*DEBUG_CPROCESS/DEBUG_CPROCESS/" $CFGFILE > $TMPFILE
       if [ -f $TMPFILE ]
       then
         mv $TMPFILE $CFGFILE > /dev/null 2>&1
       fi
     fi
   fi
   OPTION_CHECK=`grep "GET_FIRST_AVAILABLE_GROUP" $CFGFILE`
   if [ "$OPTION_CHECK" = "" ]
   then
     echo "# GET_FIRST_AVAILABLE_GROUP = TRUE" >> $CFGFILE
     echo "# This parameter forces backup jobs with ANY GROUP(*) as the destination to" >> $CFGFILE
     echo "# connect to the first available group. If this parameter is commented out," >> $CFGFILE
     echo "# the backup job with ANY GROUP (*) selected as the destination will search all" >> $CFGFILE
     echo "# groups for the appropriate media. This applies to non-NAS jobs." >> $CFGFILE
     echo "" >> $CFGFILE
   fi
   OPTION_CHECK=`grep "SINGLE_SEQUENCE_RESTORE_SPANNED_FILE_ONLY" $CFGFILE`
   if [ "$OPTION_CHECK" = "" ]
   then
     echo "# SINGLE_SEQUENCE_RESTORE_SPANNED_FILE_ONLY = FALSE" >> $CFGFILE
     echo "# When set to FALSE, if a restore job using the SINGLE SEQUENCE Option" >> $CFGFILE
     echo "# spans to the next sequence of tape, the restore job will continue" >> $CFGFILE
     echo "# to restore files until it reaches the end of the session, rather than" >> $CFGFILE
     echo "# stopping immediately after the file which has spanned has been restored," >> $CFGFILE
     echo "# skipping the restore of the remaining files in the session." >> $CFGFILE
     echo "" >> $CFGFILE
   fi
   OPTION_CHECK=`grep "APPEND_MEDIA_FORMATTED_WITHIN" $CFGFILE`
   if [ "$OPTION_CHECK" = "" ]
   then
     echo "# APPEND_MEDIA_FORMATTED_WITHIN = DAYS = 1" >> $CFGFILE
     echo "# For a custom backup append job with mediapool, data is appended to media" >> $CFGFILE
     echo "# in the save set. We can use this parameter to only append to media in" >> $CFGFILE
     echo "# the save set based on the format time. The following values can be set" >> $CFGFILE
     echo "# for this parameter." >> $CFGFILE
     echo "# 1. DAYS : Media formatted within days specified for this parameter will be" >> $CFGFILE
     echo "# used by the job." >> $CFGFILE
     echo "# 2. HOURS: Media formatted within elapsed hours specified for this parameter" >> $CFGFILE
     echo "# will be used by the job." >> $CFGFILE
     echo "" >> $CFGFILE
   else
     OPTION_EXIST_UNCOMMENTED=`grep "APPEND_MEDIA_FORMATTED_WITHIN" $CFGFILE | grep -v "^#" | grep -v "DAYS" | grep -v "HOURS"`
     if [ "$OPTION_EXIST_UNCOMMENTED" != "" ]
     then
       TMPFILE=${BEB_HOME}/config/cprocess.cfg.$$
       sed -e "s/APPEND_MEDIA_FORMATTED_WITHIN/APPEND_MEDIA_FORMATTED_WITHIN = DAYS/" $CFGFILE > $TMPFILE
       if [ -f $TMPFILE ]
       then
         mv $CFGFILE ${BEB_HOME}/config/cprocess.cfg.old > /dev/null 2>&1
         mv $TMPFILE $CFGFILE > /dev/null 2>&1
       fi
     fi
   fi
   OPTION_CHECK=`grep "NUMBER_OF_MISSED_FILES_ALLOWED" $CFGFILE`
   if [ "$OPTION_CHECK" = "" ]
   then
     echo "NUMBER_OF_MISSED_FILES_ALLOWED = JOB = 0" >> $CFGFILE
     echo "# This paramter specifies the number of missed files allowed for a complete" >> $CFGFILE
     echo "# backup job. All backup jobs are reported INCOMPLETE if the number of files" >> $CFGFILE
     echo "# missed is greater than or equal to the value set for this parameter. If this" >> $CFGFILE
     echo "# parameter is commented out, all backup jobs will be reported INCOMPLETE if" >> $CFGFILE
     echo "# the entire session is missed" >> $CFGFILE
     echo "" >> $CFGFILE
   else
     OPTION_EXIST_UNCOMMENTED=`grep "NUMBER_OF_MISSED_FILES_ALLOWED" $CFGFILE | grep -v "^#" | grep -v "JOB"`
     if [ "$OPTION_EXIST_UNCOMMENTED" != "" ]
     then
       TMPFILE=${BEB_HOME}/config/cprocess.cfg.$$
       sed -e "s/NUMBER_OF_MISSED_FILES_ALLOWED/NUMBER_OF_MISSED_FILES_ALLOWED = JOB/" $CFGFILE > $TMPFILE
       if [ -f $TMPFILE ]
       then
         mv $TMPFILE $CFGFILE > /dev/null 2>&1
       fi
     fi
   fi
 fi
}


addMMOOptionsToDiscovery()
{
    CFG_FILE=$NEW_HOME/config/discovery.cfg
    if [ -f $CFG_FILE ] 
    then
        CFG_DOMAIN_PRIMARY=`awk '/^[ \t]*PRIMARY/  { print $2 }' $CFG_FILE`
        CFG_MMO_PRIMARY=`awk '/^[ \t]*MMO_PRIMARY/ { print $2 }' $CFG_FILE`
        if [ -z "$CFG_MMO_PRIMARY" ]
        then
            echo "\nMMO_PRIMARY $CFG_DOMAIN_PRIMARY" >> $CFG_FILE
        fi
    fi
}


addOptionsToCadbd()
{
   CFGFILE=cadbd.cfg
   if [ -f $NEW_HOME/config/cadbd.cfg ]
   then
   	cp $NEW_HOME/config/cadbd.cfg $NEW_HOME/config/cadbd.cfg.orig
	if [ ! -r $NEW_HOME/dbase/ingres ]; then
	     OPTION_CHECK=`grep "^INGRES_HOME_PATH" $NEW_HOME/config/$CFGFILE|awk -F"=" '{print $2}'`
	     if	[ "$OPTION_CHECK" != "" ]
	     then
	     	ING_HOME_PATH=`dirname $OPTION_CHECK`
	     	ln -s $ING_HOME_PATH $NEW_HOME/dbase/ingres
		if [ "$OS" = "HP-UX" ]; then
			DLL_ADD="sl"
		elif [ "$OS" = "SunOS" ]; then
			DLL_ADD="so"
		elif [ "$OS" = "AIX" ]; then
			DLL_ADD="a"
		fi
		for linkfile in libcompat.1.${DLL_ADD} libframe.1.${DLL_ADD} libiiapi.1.${DLL_ADD} libinterp.1.${DLL_ADD} libq.1.${DLL_ADD}
		do
			if [ -h $NEW_HOME/lib/${linkfile} -o -f $NEW_HOME/lib/${linkfile} ]; then
			   rm $NEW_HOME/lib/${linkfile}
			fi
			ln -sf $ING_HOME_PATH/ingres/lib/${linkfile} $NEW_HOME/lib/ 
		done
	     fi
   	fi
   	if [ -f $NEW_HOME/newconfig/cadbd.cfg ]; then
        	cp $NEW_HOME/newconfig/cadbd.cfg $NEW_HOME/config/cadbd.cfg
   	fi

	# Change the value for INGRES_HOME_PATH and INGRES_CADBASE_PATH
	# in cadbd.cfg

	mv $NEW_HOME/config/cadbd.cfg $NEW_HOME/config/cadbd.old

	rm -f /tmp/tmp.sed

	${ECHO} "/INGRES_HOME_PATH/c\\" > /tmp/tmp.sed
	${ECHO} "INGRES_HOME_PATH = $ING_HOME_PATH/ingres" >> /tmp/tmp.sed
	${ECHO} "" >> /tmp/tmp.sed
	${ECHO} "/INGRES_CADBASE_PATH/c\\" >> /tmp/tmp.sed
	${ECHO} "INGRES_CADBASE_PATH = $ING_HOME_PATH/ingres/data" >> /tmp/tmp.sed

	cat $NEW_HOME/config/cadbd.old | sed -f /tmp/tmp.sed > $NEW_HOME/config/cadbd.cfg
	chmod 644 $NEW_HOME/config/cadbd.cfg
	rm -f $NEW_HOME/config/cadbd.old
	rm -f /tmp/tmp.sed
	  II_SYSTEM=$ING_HOME_PATH
	  export II_SYSTEM
	
	  CALL_ING_START=0
	  echo "$INST_MSG_40"   #"Running alterDB ..."
	  $II_SYSTEM/ingres/bin/infodb iidbdb > /dev/null 2>&1
	  if [ "$?" -ne "0" ]; then
	    $NEW_HOME/sbin/startingres
	    CALL_ING_START=1
	  fi
	  Export_Env 
	  $NEW_HOME/bin/alterDB | tee $NEW_HOME/dbase/alterDB.log.$$
	  if [ -f $NEW_HOME/dbase/alterDB.log.$$ ]; then
	    cat $NEW_HOME/dbase/alterDB.log.$$ >> $NEW_HOME/dbase/alterDB.log
	    rm -f $NEW_HOME/dbase/alterDB.log.$$ > /dev/null 2>&1
	  fi
	  if [ "$CALL_ING_START" = "1" ]; then
	    $NEW_HOME/sbin/stopingres
	  fi
   fi
   if [ ! -r $NEW_HOME/dbase/MMOBackup ]
   then
   	mkdir -p $NEW_HOME/dbase/MMOBackup > /dev/null 2>&1
   fi
   Replace_Str $NEW_HOME/config/cadbd.cfg
}

addSerialToCamediad()
{
	CFGFILE=$NEW_HOME/config/camediad.cfg
#	AWK=/usr/bin/awk
	TMPFILE=/tmp/serial.tmp.$$
	CFGTMPFILE=$NEW_HOME/config/camediad.cfg.tmp.$$
	PATH=$NEW_HOME/sbin:$NEW_HOME/bin:$PATH
	export TMPFILE PATH
	
	if [ -f $CFGFILE ]; then
	cat $CFGFILE | $AWK '
	BEGIN{
	        tmpfile=ENVIRON["TMPFILE"]
	}{
	              if ( $1 ~ /^DEVICE/ )
	              {
	                if ( NF == 5 )
	                {
	                  device_name = $3
	                  command = sprintf("ioctl_cmd %s 2 | grep -v Failed >> %s", device_name, tmpfile)
	                  system(command)
	                  if ( ( getline serial < tmpfile ) > 0 )
	                  {
	                   printf("%s \"%s\"\n", $0, serial)
	                  }
	                  else
	                  {
	                   printf("%s \"\"\n", $0)
	                  }
	                }
	                else
	                {
	                  device_name = $3
	                  command = sprintf("ioctl_cmd %s 2 | grep -v Failed >> %s", device_name, tmpfile)
	                  system(command)
	                  if ( ( getline serial < tmpfile ) > 0 )
	                  {
	                    printf("%s %s %s %s %s \"%s\"\n", $1, $2, $3, $4, $5, serial)
	                  }
	                  else
	                  {
	                    printf("%s\n", $0)
	                  }
	                }
	              }
	              else
	              {
	               print $0
	              }
	
	        }' >> $CFGTMPFILE
	
	mv $CFGTMPFILE $CFGFILE > /dev/null 2>&1
	rm -f $CFGTMPFILE > /dev/null 2>&1
	rm -f $TMPFILE > /dev/null 2>&1
	fi
}

Update_Httpd()
{
	BAB_HOME=${NEW_HOME}
	export BAB_HOME
	HT_CONF=${BAB_HOME}/httpd/conf/httpd.conf
	if [ -f ${HT_CONF} ]; then
		Servername=`hostname 2>/dev/null`
		sed -e "s/CAS_SERVERNAME/$Servername/g" ${HT_CONF} >${BAB_HOME}/httpd/conf/httpd.conf.tmp
		if [ "X${BEB_GROUP_ID}" = "X" ]; then
			sed -e "s/CAS_GROUPNAME/bab/g" ${BAB_HOME}/httpd/conf/httpd.conf.tmp >${HT_CONF}
		else
			sed -e "s/CAS_GROUPNAME/${BEB_GROUP_ID}/g" ${BAB_HOME}/httpd/conf/httpd.conf.tmp >${HT_CONF}
		fi
		sed -e "s%CAS_HOME%${BAB_HOME}%g" ${HT_CONF} > ${BAB_HOME}/httpd/conf/httpd.conf.tmp
		if [ "${OS}" = "HP-UX" ]; then
			sed -e "s/User\ nobody/User\ www/g" ${BAB_HOME}/httpd/conf/httpd.conf.tmp >${HT_CONF}
			rm -f ${BAB_HOME}/httpd/conf/httpd.conf.tmp
		else
			mv ${BAB_HOME}/httpd/conf/httpd.conf.tmp ${HT_CONF}
		fi
	fi
	echo >/tmp/.YESFILE
	${NEW_HOME}/bin/cahttpd_configure < /tmp/.YESFILE
	rm -fr /tmp/.YESFILE
	Replace_Str $HT_CONF
}
addOptionsToCaloggerd()
{
    CFGFILE=$NEW_HOME/config/caloggerd.cfg
    if [ -f $CFGFILE ]; then
     OPTION_CHECK=`grep "ACTIVITY_LOG_MAXFILE_SIZE" $CFGFILE`
     if [ "$OPTION_CHECK" = "" ]
     then
       echo "" >> $CFGFILE
       echo "###  ACTIVITY_LOG_MAXFILE_SIZE parameter sets a limit for the maximum size of" >> $CFGFILE
       echo "###  the Activity log file (in kilobytes) and OTHER_LOG_MAXFILE_SIZE sets a" >> $CFGFILE
       echo "###  size limit on all other logs, i.e. a log file will be purged at some" >> $CFGFILE
       echo "###  some point after it reaches that size.  The default is 32 MBs for the" >> $CFGFILE
       echo "###  main activity log and 1 MB for all other log files." >> $CFGFILE
       echo "#ACTIVITY_LOG_MAXFILE_SIZE = 32000" >> $CFGFILE
     fi
     OPTION_CHECK=`grep "OTHER_LOG_MAXFILE_SIZE" $CFGFILE`
     if [ "$OPTION_CHECK" = "" ]
     then
       echo "" >> $CFGFILE
       echo "#OTHER_LOG_MAXFILE_SIZE = 32000" >> $CFGFILE
     fi
     OPTION_CHECK=`grep "UNICENTER_NSM_NODES" $CFGFILE`
     if [ "$OPTION_CHECK" = "" ]
     then
       echo "" >> $CFGFILE
       echo "###  Enable Unicenter NSM alert here." >> $CFGFILE
       echo "###  List hosts that have Unicenter NSM or CA Common Services running." >> $CFGFILE
       echo "###" >> $CFGFILE
       echo "#UNICENTER_NSM_NODES = jeffntws" >> $CFGFILE
     fi
     OPTION_CHECK=`grep "EMAIL_ALERT" $CFGFILE`
     if [ "$OPTION_CHECK" = "" ]
     then
       echo "" >> $CFGFILE
       echo "###  Enable critical events to be forwarded as emails." >> $CFGFILE
       echo "###  List email accounts that will receive critical event notifications." >> $CFGFILE
       echo "###" >> $CFGFILE
       echo "#EMAIL_ALERT = user1@company.com user2@yahoo.com" >> $CFGFILE
     fi
    fi
    Replace_Str $CFGFILE
}

Update_Camediad()
{
	CFGFILE=$NEW_HOME/config/camediad.cfg
	TMPCFGFILE=$NEW_HOME/config/camediad.cfg.tmp.$$
	if [ "$BEBSVR_OLD_VERSION" = "10.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0.0" ]; then
		$AWK '{
		if (/^DEVICE /) { printf "%s  \"\"\n",$0 ; }
		else if (/MAX_VALUES_END/) { printf ";MAX_ASMS_CLEAN_SLOTS=8\n%s",$0 ;}
		else  { print $0 }
		}' $CFGFILE > $TMPCFGFILE
		mv $TMPCFGFILE $CFGFILE
	fi
	$AWK '{
	if (/ENABLE_S_CHANGER/) { printf ";ENABLE_DYNAMIC_RWSHOTS=0\n%s\n",$0 ;}
	else  { print $0 }
	}' $CFGFILE > $TMPCFGFILE
	mv $TMPCFGFILE $CFGFILE
	Replace_Str $CFGFILE
}

Replace_Str()
{
	TMPCFGFILE=$1.$$.tmp
	sed -e 's/BrightStor\ EB/BrightStor\ ARCserve\ Backup/g' $1 > $TMPCFGFILE
	sed -e 's/BrightStor\ Enterprise\ Backup/BrightStor\ ARCserve\ Backup/g' $TMPCFGFILE > $1
	sed -e 's/BEB_HOME/BAB_HOME/g' $1 > $TMPCFGFILE
	sed -e 's/CAS_HOME/BAB_HOME/g' $TMPCFGFILE > $1	
	rm -f $TMPCFGFILE
}

check_RELVERSION()
{
if [ -f $BEB_OLD_PKG_DIR/BrightStorEB/data/RELVERSION ]; then
  sp_check=`cat $BEB_OLD_PKG_DIR/BrightStorEB/data/RELVERSION | egrep "SP4|SP5"`
  if [ "$sp_check" != "" ]; then
    IS_SP=1
  fi 
fi
}

fix_ibm3494()
{
CFGFILE=$NEW_HOME/config/camediad.cfg
CFGTMPFILE=$NEW_HOME/config/camediad.cfg.tmp.$$
has_adapter1=0

has_adapter1=`cat $CFGFILE | grep "ADAPTER 1"`

if [ "$has_adapter1" != "" ]; then
rm -f $CFGTMPFILE > /dev/null 2>&1
if [ -f $CFGFILE ]; then
cat $CFGFILE | $AWK '
BEGIN{
}{
              if ( $1 ~ /^ADAPTER/ )
              {
                if ( $2 != 0 )
                {
                 print $0
                }
              }
              else
              {
               print $0
              }
        }' >> $CFGTMPFILE

  cp $CFGTMPFILE $CFGFILE > /dev/null 2>&1
  rm -f $CFGTMPFILE > /dev/null 2>&1
fi
fi

IBMFILE=`ls -a $NEW_HOME/data | grep "drv.cfg"`
IBMCOUNT=`ls -a $NEW_HOME/data | grep "drv.cfg" | wc -l`
if [ "$IBMFILE" != "" -a $IBMCOUNT -eq 1 ]; then
  IBMFILE=$NEW_HOME/data/$IBMFILE
  IBMFILETMP=$IBMFILE.tmp.$$
  cat $IBMFILE | $AWK '
  BEGIN{
  }{
              if ( $1 ~ /^\(.*\)/ )
              {
               split($1, TUPLE, "(")
               split(TUPLE[2], number, ",")
               number[1] = number[1] - 1
               printf("(%s,%s,%s ", number[1], number[2], number[3]);
               for (i=2; i<=NF; i++ )
               {
                printf("%s ", $i)
               }
               printf("\n")
              }
              else
              {
               print $0
              }
        }' >> $IBMFILETMP

  cp $IBMFILETMP $IBMFILE > /dev/null 2>&1
  rm -f $IBMFILETMP > /dev/null 2>&1
fi
}

fix_camediad()
{
CFGFILE=$NEW_HOME/config/camediad.cfg
CFGTMPFILE=$NEW_HOME/config/camediad.cfg.tmp.$$

rm -f $CFGTMPFILE > /dev/null 2>&1
if [ -f $CFGFILE ]; then
cat $CFGFILE | $AWK '
BEGIN{
}{
              if ( $1 ~ /^ADAPTER/ )
              {
                 for (i=1; i<=NF; i++ )
                 {
                  if (( i == 2 ) && ( $i != 0 ))
                  {
                   printf("%d ", $i-1)
                  }
                  else
                  {
                   printf("%s ", $i)
                  }
                 }
                 printf("\n")
              }
              else if ( $1 ~ /^GROUP/ )
              {
               split($NF, TUPLE, "(")
               split(TUPLE[2], number, ",")
               for (i=1; i<=NF-1; i++ )
               {
                printf("%s ", $i)
               }
               number[1] = number[1] - 1
               printf("(%s,%s,%s\n", number[1], number[2], number[3]);
              }
              else if ( $1 ~ /^CHANGER_NAME/ )
              {
               split($NF, TUPLE, "(")
               split(TUPLE[2], number, ",")
               for (i=1; i<=NF-1; i++ )
               {
                printf("%s ", $i)
               }
               if ( number[1] != 0 )
               {
               number[1] = number[1] - 1
               }
               printf("(%s,%s,%s\n", number[1], number[2], number[3]);
              }
              else if ( $1 ~ /^CHANGER_GROUP/ )
              {
               split($4, TUPLE, "(")
               split(TUPLE[2], number, ",")
               for (i=1; i<=3; i++ )
               {
                printf("%s ", $i)
               }
               number[1] = number[1] - 1
               printf("(%s,%s,%s ", number[1], number[2], number[3]);
               for (i=5; i<=NF; i++ )
               {
                printf("%s ", $i)
               }
               printf("\n")
              }
              else if ( $1 ~ /^CHANGER_DEVICES/ )
              {
               for (i=1; i<=2; i++ )
               {
                printf("%s ", $i)
               }
               for (i=3; i<=NF; i++ )
               {
                split($i, TUPLE, "(")
                split(TUPLE[2], number, ",")
                number[1] = number[1] - 1
                printf("(%s,%s,%s ", number[1], number[2], number[3]);
               }
               printf("\n")
              }
              else if ( $1 ~ /^DEVICE/ )
              {
               if ( $4 ~ /^FS/ )
               {
                printf("%s %s %s\t%s\t", $1, $2, $3, $4)
                split($5, TUPLE, "(")
                split(TUPLE[2], number, ",")
                number[1] = number[1] - 1
                printf("(%s,%s,%s ", number[1], number[2], number[3]);
                for (i=6; i<=NF; i++ )
                {
                printf("%s ", $i)
                }
                printf("\n")
               }
               else
               {
               print $0
               }
              }
              else
              {
               print $0
              }

        }' >> $CFGTMPFILE

  cp $CFGTMPFILE $CFGFILE > /dev/null 2>&1
  rm -f $CFGTMPFILE > /dev/null 2>&1
fi
}

fix_camediad_nlo()
{
CFGFILE=$NEW_HOME/config/camediad.cfg
CFGTMPFILE=$NEW_HOME/config/camediad.cfg.tmp.$$

rm -f $CFGTMPFILE > /dev/null 2>&1
if [ -f $CFGFILE ]; then
cat $CFGFILE | $AWK '
BEGIN{
}{
              if ( $1 ~ /^ADAPTER/ )
              {
                 for (i=1; i<=NF; i++ )
                 {
                  if (( i == 2 ) && ( $i != 0 ))
                  {
                   printf("%d ", $i-1)
                  }
                  else
                  {
                   printf("%s ", $i)
                  }
                 }
                 printf("\n")
              }
              else if ( $1 ~ /^S_CHANGER_NAME/ )
              {
               split($NF, TUPLE, "(")
               split(TUPLE[2], number, ",")
               for (i=1; i<=NF-1; i++ )
               {
                printf("%s ", $i)
               }
               if ( number[1] != 0 )
               {
               number[1] = number[1] - 1
               }
               printf("(%s,%s,%s\n", number[1], number[2], number[3]);
              }
              else if ( $1 ~ /^S_CHANGER_GROUP/ )
              {
               split($4, TUPLE, "(")
               split(TUPLE[2], number, ",")
               for (i=1; i<=3; i++ )
               {
                printf("%s ", $i)
               }
               number[1] = number[1] - 1
               printf("(%s,%s,%s ", number[1], number[2], number[3]);
               for (i=5; i<=NF; i++ )
               {
                printf("%s ", $i)
               }
               printf("\n")
              }
              else if ( $1 ~ /^S_CHANGER_DEVICES/ )
              {
               for (i=1; i<=2; i++ )
               {
                printf("%s ", $i)
               }
               for (i=3; i<=NF; i++ )
               {
                split($i, TUPLE, "(")
                split(TUPLE[2], number, ",")
                number[1] = number[1] - 1
                printf("(%s,%s,%s ", number[1], number[2], number[3]);
               }
               printf("\n")
              }
              else if ( $1 ~ /^DEVICE/ )
              {
               if ( $4 ~ /^FS/ )
               {
                printf("%s %s %s\t%s\t", $1, $2, $3, $4)
                split($5, TUPLE, "(")
                split(TUPLE[2], number, ",")
                number[1] = number[1] - 1
                printf("(%s,%s,%s ", number[1], number[2], number[3]);
                for (i=6; i<=NF; i++ )
                {
                printf("%s ", $i)
                }
                printf("\n")
               }
               else
               {
               print $0
               }
              }
              else
              {
               print $0
              }

        }' >> $CFGTMPFILE

  cp $CFGTMPFILE $CFGFILE > /dev/null 2>&1
  rm -f $CFGTMPFILE > /dev/null 2>&1
fi
}

Update_Svr_Config()
{
	NEW_HOME=${ARC_PREFIX:-/opt/CA}/BrightStorARCserve
        addOptionsToCprocess
        addOptionsToCadbd
        addMMOOptionsToDiscovery
        Update_Camediad
if [ "$OS" = "AIX" ]; then
	if [ "$BEBSVR_OLD_VERSION" = "10.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0.0" ]; then
        	addSerialToCamediad >> ${LOG_FILE} 2>&1
        fi
        if [ "$BEBSVR_OLD_VERSION" = "10.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0.0" ] && [ "$IBM_OLD_INSTALLED" = "1" ] && [ "X${IBM_SUC_INST}" != "XNO" ]; then
          if [ "$IS_SP" = "1" ]; then
            fix_ibm3494  >> ${LOG_FILE} 2>&1
          fi
        fi
        if [ "$BEBSVR_OLD_VERSION" = "10.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0.0" ] && [ "$NLO_OLD_INSTALLED" != "1" ]; then
          if [ "$IS_SP" = "1" ]; then
            fix_camediad  >> ${LOG_FILE} 2>&1
            ${NEW_HOME}/sbin/camediad.pre  >> ${LOG_FILE} 2>&1
          fi
        fi
        if [ "$BEBSVR_OLD_VERSION" = "10.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0.0" ] && [ "$NLO_OLD_INSTALLED" = "1" ]; then
          if [ "$IS_SP" = "1" ]; then
            fix_camediad_nlo  >> ${LOG_FILE} 2>&1
            ${NEW_HOME}/sbin/camediad.pre  >> ${LOG_FILE} 2>&1
          fi
        fi
fi
        addOptionsToCaloggerd
        Update_Httpd
        touch ${NEW_HOME}/data/.setupcomplete >> ${LOG_FILE} 2>&1
        chmod 644 ${NEW_HOME}/data/.setupcomplete >> ${LOG_FILE} 2>&1
        if [ -f ${NEW_HOME}/lib/nls/C/newconfig/.devlist.dat ]; then
        	cp ${NEW_HOME}/lib/nls/C/newconfig/.devlist.dat ${NEW_HOME}/config/.devlist.dat >> ${LOG_FILE} 2>&1
        fi
}
Upgrade_Server()
{
	INSTALLED_PREFIX=${BEB_OLD_PKG_DIR}
	ARC_PREFIX=${BEB_PKG_DIR}
	if [ -r ${INSTALLED_PREFIX:-/opt/CA}/BrightStorEB/config ]; then
		cp -R ${INSTALLED_PREFIX}/BrightStorEB/config ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/ 2>/dev/null
		cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/httpd/newconf/* ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/httpd/conf/ 2>/dev/null
		cp -R ${INSTALLED_PREFIX}/BrightStorEB/httpd/logs ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/httpd/ 2>/dev/null
		cp ${INSTALLED_PREFIX}/BrightStorEB/lib/nls/nls.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/nls.cfg.v9 2>/dev/null
		cp -R ${INSTALLED_PREFIX}/BrightStorEB/logs ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/ 2>/dev/null
		cp -R ${INSTALLED_PREFIX}/BrightStorEB/jobscripts ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/ 2>/dev/null
		cp -R ${INSTALLED_PREFIX}/BrightStorEB/queue/job* ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/queue/ 2>/dev/null
		cp ${INSTALLED_PREFIX}/BrightStorEB/dbase/*.log ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/dbase/ 2>/dev/null
		cp ${INSTALLED_PREFIX}/BrightStorEB/dbase/tmpcat/* ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/dbase/tmpcat/ 2>/dev/null
		cp -R ${INSTALLED_PREFIX}/BrightStorEB/data/barCodeDB ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/data/ 2>/dev/null
		cp -R ${INSTALLED_PREFIX}/BrightStorEB/data/discovery ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/data/ 2>/dev/null
		cp ${INSTALLED_PREFIX}/BrightStorEB/data/*.slots ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/data/ 2>/dev/null
		cp ${INSTALLED_PREFIX}/BrightStorEB/data/*.dtstat ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/data/ 2>/dev/null
		cp ${INSTALLED_PREFIX}/BrightStorEB/data/*.dtscsi ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/data/ 2>/dev/null
		cp ${INSTALLED_PREFIX}/BrightStorEB/data/.*.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/data/ 2>/dev/null
		cp ${INSTALLED_PREFIX}/BrightStorEB/data/*.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/data/ 2>/dev/null
		if [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStorEB.log ]; then
			mv ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStorEB.log ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStor.log 2>/dev/null
		fi
		if [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStorEB.log.dix ]; then
			mv ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStorEB.log.dix ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStor.log.dix 2>/dev/null
		fi
		if [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStorEB.log.jix ]; then
			mv ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStorEB.log.jix ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStor.log.jix 2>/dev/null
		fi
		if [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStorEB.log.lix ]; then
			mv ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStorEB.log.lix ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/logs/BrightStor.log.lix 2>/dev/null
		fi
		if [ ! -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/queue.cfg ]; then
			if [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/newconfig/queue.cfg ]; then
				cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/newconfig/queue.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/queue.cfg
			elif [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/${NLS_LOCALE}/newconfig/queue.cfg ]; then
				cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/${NLS_LOCALE}/newconfig/queue.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/queue.cfg
			else
				cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/C/newconfig/queue.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/queue.cfg
			fi
			
		fi
		if [ ! -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/rpc.cfg ]; then
			if [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/newconfig/rpc.cfg ]; then
				cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/newconfig/rpc.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/rpc.cfg
			elif [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/${NLS_LOCALE}/newconfig/rpc.cfg ]; then
				cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/${NLS_LOCALE}/newconfig/rpc.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/rpc.cfg
			else
				cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/C/newconfig/rpc.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/rpc.cfg
			fi
			
		else
			${GREP} "sanpeer" ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/rpc.cfg >/dev/null 2>&1
			if [ $? -ne 0 ]; then
				if [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/newconfig/rpc.cfg ]; then
					cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/newconfig/rpc.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/rpc.cfg
				elif [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/${NLS_LOCALE}/newconfig/rpc.cfg ]; then
					cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/${NLS_LOCALE}/newconfig/rpc.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/rpc.cfg
				else
					cp ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/nls/C/newconfig/rpc.cfg ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/config/rpc.cfg
				fi
			fi
		fi
		Update_Svr_Config
	fi
}
create_lib_links()
{
	cd ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib
	LIB_LIST=$(ls lib* 2>/dev/null)
	if [ "${CALIB}" = "" ] ;then
	        CALIB=/opt/CA/SharedComponents/lib
	        if [ ! -d ${CALIB} ]; then
	        	mkdir -p ${CALIB}
	        fi
	fi
	for L in ${LIB_LIST}
	do
	   if [ -h ${CALIB}/$L -a "$L" != "liblic98.so" -a "$L" != "liblic98.sl" -a "$L" != "liblic98.o" -a "$L" != "liblic98.a" ]
	   then
	   	rm -f ${CALIB}/$L
	   fi
	   if [ ! -f ${CALIB}/$L -a ! -h ${CALIB}/$L ]; then
		ln -sf ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/$L ${CALIB}/
	   fi
	
	done
	if [ -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/bin/lang_setup ]; then
		BAB_HOME=${ARC_PREFIX:-/opt/CA}/BrightStorARCserve
		export BAB_HOME
		${BAB_HOME}/bin/lang_setup -l
	fi
}
create_caagent_links()
{
	if [ -f /opt/CA/BABcmagt/caagent ]; then
		ln -sf /opt/CA/BABcmagt/caagent /usr/bin/caagent
	fi
}
create_uagent_links()
{
	if [ -f ${AGNTUX_PKG_DIR}/BABuagent/uagent ]; then
		ln -sf ${AGNTUX_PKG_DIR}/BABuagent/uagent /usr/bin/uagent
	fi
}
install_base()
{
                        Install_License_Package
                        CA7SPKG=`$PKGINFO | grep $SVR_PKG` 
                        CA7GPKG=`$PKGINFO | grep $MGR_PKG` 
                        if [ "$CA7SPKG" = "" -a "$CA7GPKG" = "" ] || [ $SERVER_NEED_UPGRADE -eq 1 ]
                        then
if [ $BEBSVR_OLD_INSTALLED -eq 1 ]; then
                            echo "    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_141} ]\c"
elif [ $SERVER_NEED_UPGRADE -eq 1 ]; then
                            echo "    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_216} ]\c"
else
                            echo "    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_62} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $SERVER_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $SVR_PKG CAS_HOME $BEB_PKG_DIR BrightStorARCserve
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $SVR_PKG < ${YES_FILE} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/SVR_PKG -x reinstall=true $SVR_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${BEB_PKG_DIR}/BrightStorARCserve 2> /dev/null
	                            if [ "${BEB_PKG_DIR}" != "/opt/CA" -a "${BEB_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${BEB_PKG_DIR}/BrightStorARCserve /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD  $TMPDIR/$PID/tmppkg.d -F $SVR_PKG >> ${LOG_FILE} 2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $SVR_PKG CAS_HOME $BEB_PKG_DIR BrightStorARCserve
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $SVR_PKG < ${YES_FILE} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/SVR_PKG $SVR_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${BEB_PKG_DIR}/BrightStorARCserve 2> /dev/null
	                            if [ "${BEB_PKG_DIR}" != "/opt/CA" -a "${BEB_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${BEB_PKG_DIR}/BrightStorARCserve /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $SVR_PKG >> ${LOG_FILE} 2>&1
	fi
fi
                         install_status=$?
			 $NLS_UTILITY_FILE -u ${BEB_PKG_DIR}/BrightStorARCserve/lib/nls/nls.cfg CA_NLS_LANG $NLS_LANG $NLS_LOCALE
                         if [ $install_status -eq 0 ]
                         then
if [ $SERVER_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                               $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $MGR_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                              $PKGADD $TMPDIR/$PID/tmppkg.d/MGR_PKG -x reinstall=true $MGR_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                               $PKGADD $TMPDIR/$PID/tmppkg.d -F $MGR_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                               $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $MGR_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                              $PKGADD $TMPDIR/$PID/tmppkg.d/MGR_PKG $MGR_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                               $PKGADD $TMPDIR/$PID/tmppkg.d $MGR_PKG >> ${LOG_FILE}  2>&1
	fi
fi
                               install_status=$?
                               cd $HOMEDIR
                               rm -rf $TMPDIR/$PID/tmppkg.d
                            if [ $install_status -eq 0 -a $BEBSVR_OLD_INSTALLED -eq 1 ]; then
				  Upgrade_Server >> ${LOG_FILE} 2>&1
                            fi
                               stopDial
                                                                            if [ $install_status -eq 0 ]
                                                                            then
if [ $BEBSVR_OLD_INSTALLED -eq 1 ]; then
                                  echo "$BK_LINE_FLAG    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_142} ]   "
elif [ $SERVER_NEED_UPGRADE -eq 1 ]; then
                                  echo "$BK_LINE_FLAG    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_217} ]   "
else
                                  echo "$BK_LINE_FLAG    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_63} ]   "
fi
                                  BEB_NEW_INSTALLED=1
if [ "$OS" = "SunOS" -o "$OS" = "AIX" -o "$OS" = "HP-UX" ]; then
                                  install_igateway
fi
if [ "$OS" = "SunOS" -o "$OS" = "AIX" -o "$OS" = "HP-UX" ]; then
                                  install_isponsor
fi
                               else
                                  echo "$BK_LINE_FLAG    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_64} ]"
                            	BASE_SUC_INST="NO"
                                                                                 fi
                            else
                               cd $HOMEDIR
                               rm -rf $TMPDIR/$PID/tmppkg.d
                               stopDial
                               echo "$BK_LINE_FLAG    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_64} ]"
                            	BASE_SUC_INST="NO"
                                                                         fi

                        elif [ "$CA7SPKG" = "" -a "$CA7GPKG" != "" ]
                        then
if [ $BEBSVR_OLD_INSTALLED -eq 1 ]; then
                            echo "    Server                            (BABsvr)         ==> [ ${INST_MSG_141} ]\c"
elif [ $SERVER_NEED_UPGRADE -eq 1 ]; then
                            echo "    Server                            (BABsvr)         ==> [ ${INST_MSG_216} ]\c"
else
                            echo "    Server                            (BABsvr)         ==> [ ${INST_MSG_62} ]\c"
fi
                            startDial &
                            DIALPID=$!
#                            Install_License_Package
                            Untar_Package $PKG
                            rm -rf $MGR_PKG
if [ $SERVER_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $SVR_PKG CAS_HOME $BEB_PKG_DIR BrightStorARCserve
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $SVR_PKG < ${YES_FILE} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/SVR_PKG -x reinstall=true $SVR_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${BEB_PKG_DIR}/BrightStorARCserve 2> /dev/null
	                            if [ "${BEB_PKG_DIR}" != "/opt/CA" -a "${BEB_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${BEB_PKG_DIR}/BrightStorARCserve /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $SVR_PKG >> ${LOG_FILE} 2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $MGR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $SVR_PKG < ${YES_FILE} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/SVR_PKG $SVR_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "AIX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $SVR_PKG >> ${LOG_FILE} 2>&1
	fi
fi
                            install_status=$?

			    $NLS_UTILITY_FILE -u ${BEB_PKG_DIR}/BrightStorARCserve/lib/nls/nls.cfg CA_NLS_LANG $NLS_LANG $NLS_LOCALE
                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            if [ $install_status -eq 0 -a $BEBSVR_OLD_INSTALLED -eq 1 ]; then
				  Upgrade_Server >> ${LOG_FILE} 2>&1
                            fi
                            stopDial
                                                                         if [ $install_status -eq 0 ]
                                                                         then
if [ $BEBSVR_OLD_INSTALLED -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Server                            (BABsvr)         ==> [ ${INST_MSG_142} ]   "
elif [ $SERVER_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Server                            (BABsvr)         ==> [ ${INST_MSG_217} ]   "
else
                               echo "$BK_LINE_FLAG    Server                            (BABsvr)         ==> [ ${INST_MSG_63} ]   "
fi
                               BEB_NEW_INSTALLED=1
if [ "$OS" = "SunOS" -o "$OS" = "AIX" -o "$OS" = "HP-UX" ]; then
                               install_igateway
fi
if [ "$OS" = "SunOS" -o "$OS" = "AIX" -o "$OS" = "HP-UX" ]; then
                               install_isponsor
fi
                            else
                               echo "$BK_LINE_FLAG    Server                            (BABsvr)         ==> [ ${INST_MSG_64} ]"
                            	BASE_SUC_INST="NO"
                                                                         fi
                        elif [ "$CA7SPKG" != "" -a "$CA7GPKG" = "" ]
                        then                            
                            echo "    Manager                            (BABmgr)         ==> [ ${INST_MSG_62} ]\c"
                            startDial &
                            DIALPID=$!
#                            Install_License_Package
                            Untar_Package $PKG
                            rm -rf BABsvr
if [ $SERVER_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                               $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $MGR_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                              $PKGADD $TMPDIR/$PID/tmppkg.d/MGR_PKG -x reinstall=true $MGR_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                               $PKGADD $TMPDIR/$PID/tmppkg.d -F $MGR_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $MGR_PKG < ${YES_FILE} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/MGR_PKG $MGR_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "AIX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $MGR_PKG >> ${LOG_FILE} 2>&1
	fi
fi
                            install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                         if [ $install_status -eq 0 ]
                                                                         then
                               echo "$BK_LINE_FLAG    Manager                            (BABmgr)         ==> [ ${INST_MSG_63} ]   "
                               BEB_NEW_INSTALLED=1
if [ "$OS" = "SunOS" -o "$OS" = "AIX" -o "$OS" = "HP-UX" ]; then
                               install_igateway
fi
if [ "$OS" = "SunOS" -o "$OS" = "AIX" -o "$OS" = "HP-UX" ]; then
                               install_isponsor
fi
                            else
                               echo "$BK_LINE_FLAG    Manager                            (BABmgr)         ==> [ ${INST_MSG_64} ]"
                            	BASE_SUC_INST="NO"
                                                                         fi
                        else
                            echo "$BK_LINE_FLAG    Server & Manager                         (BABsvr & BABmgr)==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	
                            	CLEANUP 4
                            else
                            	BASE_SUC_INST="NO"
                            	continue
                            fi

                        fi

}

install_agntux()
{
                        CA7AGNTUXPKG=`$PKGINFO | grep $AGT_PKG`
                        if [ "$CA7AGNTUXPKG" = "" -o $UAG_NEED_UPGRADE -eq 1 ] # install package
                        then
	                        CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
	                        if [ "$CA7CMAGTPKG" = "" ]
	                        then
	                            INSTALL_CMAGT
	                        fi
	                            Test_Link /opt/CA/BABuagent
if [ "$OS" = "AIX" ]; then
	                            create_beb_group
fi
if [ $UAGENT_OLD_INSTALLED -eq 1 ]; then
                                echo "    Client Agent for UNIX                    ($AGT_PKG)      ==> [ ${INST_MSG_141} ]\c"
elif [ $UAG_NEED_UPGRADE -eq 1 ]; then
                                echo "    Client Agent for UNIX                    ($AGT_PKG)      ==> [ ${INST_MSG_216} ]\c"
				for cfgfile in cabr.cfg groom.cntl mergescan.cfg uag.cfg uag.cntl uagres.cntl fs.cntl
				do 
					if [ -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile} ];then
						cp ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile} ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile}.upg >/dev/null 2>&1
					fi
				done
else
                                echo "    Client Agent for UNIX                    ($AGT_PKG)      ==> [ ${INST_MSG_62} ]\c"
fi
                                startDial &
                                DIALPID=$!
                                Untar_Package $PKG
if [ $UAG_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                                Create_Package_Response $AGT_PKG UAGENT_HOME $AGNTUX_PKG_DIR BABuagent
	                                $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${AGT_PKG}.pkgask -a $TMPDIR/$PID/admin $AGT_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                                $PKGADD $TMPDIR/$PID/tmppkg.d -x reinstall=true $AGT_PKG,l=${AGNTUX_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
		                            mkdir -p ${AGNTUX_PKG_DIR}/BABuagent 2> /dev/null
		                            if [ "${AGNTUX_PKG_DIR}" != "/opt/CA" -a "${AGNTUX_PKG_DIR}" != "/opt/CA/" ]; then
		                                ln -sf ${AGNTUX_PKG_DIR}/BABuagent /opt/CA/.
		                                if [ $? -ne 0 ]; then
		                                    CLEANUP 16
		                                fi
		                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $AGT_PKG >> ${LOG_FILE} 2>&1
	elif [ "$OS" = "FreeBSD" ]; then
	                                $PKGRM -f ${AGT_PKG} >> ${LOG_FILE}  2>&1
	                                $PKGADD -f -p ${AGNTUX_PKG_DIR} $TMPDIR/$PID/tmppkg.d/${AGT_PKG}.tgz >> ${LOG_FILE}  2>&1
	else
		                            mkdir -p ${AGNTUX_PKG_DIR}/BABuagent 2> /dev/null
		                            if [ "${AGNTUX_PKG_DIR}" != "/opt/CA" -a "${AGNTUX_PKG_DIR}" != "/opt/CA/" ]; then
		                                ln -sf ${AGNTUX_PKG_DIR}/BABuagent /opt/CA/.
		                                if [ $? -ne 0 ]; then
		                                    CLEANUP 16
		                                fi
		                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $AGT_PKG >> ${LOG_FILE} 2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                                Create_Package_Response $AGT_PKG UAGENT_HOME $AGNTUX_PKG_DIR BABuagent
	                                $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${AGT_PKG}.pkgask $AGT_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                                $PKGADD $TMPDIR/$PID/tmppkg.d $AGT_PKG,l=${AGNTUX_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" -o "$OS" = "OSF1" ]; then
		                            mkdir -p ${AGNTUX_PKG_DIR}/BABuagent 2> /dev/null
		                            if [ "${AGNTUX_PKG_DIR}" != "/opt/CA" -a "${AGNTUX_PKG_DIR}" != "/opt/CA/" ]; then
		                                ln -sf ${AGNTUX_PKG_DIR}/BABuagent /opt/CA/.
		                                if [ $? -ne 0 ]; then
		                                    CLEANUP 16
		                                fi
		                            fi
	                                $PKGADD $TMPDIR/$PID/tmppkg.d $AGT_PKG >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "FreeBSD" ]; then
	                                $PKGADD -f -p ${AGNTUX_PKG_DIR} $TMPDIR/$PID/tmppkg.d/${AGT_PKG}.tgz >> ${LOG_FILE}  2>&1
	fi
fi
                                install_status=$?
                                cd $HOMEDIR
                                rm -rf $TMPDIR/$PID/tmppkg.d
                                stopDial
	                            if [ $install_status -eq 0 ]
	                            then
if [ $UAG_NEED_UPGRADE -eq 1 ]; then
					for cfgfile in cabr.cfg groom.cntl mergescan.cfg uag.cfg uag.cntl uagres.cntl fs.cntl
					do 
						if [ -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile}.upg ];then
							mv -f ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile}.upg ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile} >/dev/null 2>&1
							if [ "$cfgfile" = "fs.cntl" ]; then
								space_flag=0
								for update_item in sysfs usbfs subfs nfsd ctfs lofs objfs swap
								do
								 grep $update_item ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile} >/dev/null 2>&1
								 if [ $? -ne 0 ]; then
								 	if [ $space_flag -eq 0 ]; then
								 		echo "" >> ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile} 2>/dev/null
								 		space_flag=1
								 	fi
								 	echo "$update_item" >> ${AGNTUX_PKG_DIR:-/opt/CA}/BABuagent/${cfgfile} 2>/dev/null
								 fi
								done
							fi
						fi
					done
	                                   echo "$BK_LINE_FLAG    Client Agent for UNIX                    ($AGT_PKG)      ==> [ ${INST_MSG_217} ]     "
elif [ $UAGENT_OLD_INSTALLED -ne 1 ]; then
	                                   echo "$BK_LINE_FLAG    Client Agent for UNIX                    ($AGT_PKG)      ==> [ ${INST_MSG_63} ]     "
else
	                                   echo "$BK_LINE_FLAG    Client Agent for UNIX                    ($AGT_PKG)      ==> [ ${INST_MSG_142} ]     "
#	                                   Update_Agent 0
						Update_Uagcfg
fi
	                                   ${AGNTUX_PKG_DIR}/BABuagent/uagent start >/dev/null 2>&1
	                            else
	                                   echo "$BK_LINE_FLAG    Client Agent for UNIX                    ($AGT_PKG)      ==> [ ${INST_MSG_64} ]"
                            UAG_SUC_INST="NO"
	                            fi
                            else            # BABagntux must be installed already
                                echo "$BK_LINE_FLAG    Client Agent for UNIX                    ($AGT_PKG)      ==> [ ${INST_MSG_100} ]"
	                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
	                            	CLEANUP 4
	                            fi
                            UAG_SUC_INST="NO"
                            fi
}

install_dro()
{
                        CA7SPKG=`$PKGINFO | grep $SVR_PKG`
                        CA7GPKG=`$PKGINFO | grep $MGR_PKG`

                        if [ "$CA7SPKG" = "" -o "$CA7GPKG" = "" ]
                        then
#                           echo
                            echo "${INST_MSG_101}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_145}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_103}" >> ${LOG_FILE}  2>&1
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	exit 3
                            else
                            DRO_SUC_INST="NO"
                               echo "    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_64} ]"
                            return
                            fi
                        fi

                        CA7DROPKG=`$PKGINFO | grep $DRO_N_PKG`
                        if [ "$CA7DROPKG" = "" -o $DRO_NEED_UPGRADE -eq 1 ] # install package
                        then
if [ $DRO_NEED_UPGRADE -eq 1 ]; then
                            echo "    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_216} ]\c"
elif [ $DRO_OLD_INSTALLED -ne 1 ]; then
                            echo "    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
                            Create_Server_Package_Response $SVR_PKG
if [ $DRO_NEED_UPGRADE -eq 1 ]; then
                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $DRO_N_PKG  < ${YES_FILE} >> ${LOG_FILE} 2>&1
else
                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $DRO_N_PKG  < ${YES_FILE} >> ${LOG_FILE} 2>&1
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $DRO_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_217} ]    "
elif [ $DRO_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_63} ]    "
else
                               cp ${BEB_OLD_PKG_DIR}/BrightStorEB/DR/cadro.cfg ${BEB_PKG_DIR}/BrightStorARCserve/DR/ >/dev/null 2>&1
                               echo "$BK_LINE_FLAG    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_142} ]    "
fi
                            else   
                               echo "$BK_LINE_FLAG    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_64} ]"
                               DRO_SUC_INST="NO"
                            fi 
                        else            # BABdr must be installed already
                            echo "$BK_LINE_FLAG    Disaster Recovery Option                 (BABdr)          ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            DRO_SUC_INST="NO"
                        fi

}

install_nas()
{
                        CA7SPKG=`$PKGINFO | grep $SVR_PKG`
                        CA7GPKG=`$PKGINFO | grep $MGR_PKG`

                        if [ "$CA7SPKG" = "" -o "$CA7GPKG" = "" ]
                        then
#                           echo
                            echo "${INST_MSG_101}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_145}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_103}" >> ${LOG_FILE}  2>&1
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	exit 3
                            else
                            NAS_SUC_INST="NO"
                               echo "    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_64} ]"
                            return
                            fi
                        fi

                        CA7NASPKG=`$PKGINFO | grep $NAS_N_PKG`
                        if [ "$CA7NASPKG" = "" -o $NAS_NEED_UPGRADE -eq 1 ] # install package
                        then
if [ $NAS_NEED_UPGRADE -eq 1 ]; then
                            echo "    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_216} ]\c"
elif [ $NAS_OLD_INSTALLED -ne 1 ]; then
                            echo "    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $NAS_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $NAS_N_PKG  < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -x reinstall=true $NAS_N_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $NAS_N_PKG  < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $NAS_N_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $NAS_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_217} ]   "
elif [ $NAS_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_142} ]   "
fi
                            else 
                               echo "$BK_LINE_FLAG    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_64} ]"
                            NAS_SUC_INST="NO"
                            fi
                        else            # BABnas must be installed already
                            echo "$BK_LINE_FLAG    NDMP NAS Option                          (BABnas)         ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            NAS_SUC_INST="NO"

                        fi

}

install_ora8agt()
{
if [ "$OS" != "OSF1" ]; then
  ORA8_SPACE="  "
else
  ORA8_SPACE=""
fi
                        CA7ORAPKG=`$PKGINFO | grep $ORA8_PKG`
                        if [ "$CA7ORAPKG" = "" -o $ORA_NEED_UPGRADE -eq 1 ] # install package
                        then
	                        CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
	                        if [ "$CA7CMAGTPKG" = "" ]
	                        then
	                            INSTALL_CMAGT
	                        fi
                            Test_Link /opt/CA/BABoraagt
if [ $ORA_NEED_UPGRADE -eq 1 ]; then
                            echo "    Backup Agent for Oracle                  ($ORA8_PKG)$ORA8_SPACE       ==> [ ${INST_MSG_216} ]\c"
elif [ $ORA_OLD_INSTALLED -ne 1 -a $ORA8_OLD_INSTALLED -ne 1 -a $ORA8SL_OLD_INSTALLED -ne 1 -a $TIMEFINDER_OLD_INSTALLED -ne 1 ]; then
                            echo "    Backup Agent for Oracle                  ($ORA8_PKG)$ORA8_SPACE       ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Backup Agent for Oracle                  ($ORA8_PKG)$ORA8_SPACE       ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $ORA_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $ORA8_PKG CAORA_HOME $ORA8_PKG_DIR BABoraagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${ORA8_PKG}.pkgask -a $TMPDIR/$PID/admin $ORA8_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${ORA8_PKG} -x reinstall=true ${ORA8_PKG},l=${ORA8_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${ORA8_PKG_DIR}/BABoraagt 2> /dev/null
	                            if [ "${ORA8_PKG_DIR}" != "/opt/CA" ]; then
	                                ln -sf ${ORA8_PKG_DIR}/BABoraagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $ORA8_PKG >> ${LOG_FILE}  2>&1
	else
	                            mkdir -p ${ORA8_PKG_DIR}/BABoraagt 2> /dev/null
	                            if [ "${ORA8_PKG_DIR}" != "/opt/CA" ]; then
	                                ln -sf ${ORA8_PKG_DIR}/BABoraagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/BABORA $ORA8_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $ORA8_PKG CAORA_HOME $ORA8_PKG_DIR BABoraagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${ORA8_PKG}.pkgask $ORA8_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${ORA8_PKG} ${ORA8_PKG},l=${ORA8_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${ORA8_PKG_DIR}/BABoraagt 2> /dev/null
	                            if [ "${ORA8_PKG_DIR}" != "/opt/CA" ]; then
	                                ln -sf ${ORA8_PKG_DIR}/BABoraagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $ORA8_PKG >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "OSF1" ]; then
	                            mkdir -p ${ORA8_PKG_DIR}/BABoraagt 2> /dev/null
	                            if [ "${ORA8_PKG_DIR}" != "/opt/CA" ]; then
	                                ln -sf ${ORA8_PKG_DIR}/BABoraagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/BABORA $ORA8_PKG >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $ORA_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Backup Agent for Oracle                  ($ORA8_PKG)$ORA8_SPACE       ==> [ ${INST_MSG_217} ]   "
                               Update_Agent_22
elif [ $ORA_OLD_INSTALLED -ne 1 -a $ORA8_OLD_INSTALLED -ne 1 -a $ORA8SL_OLD_INSTALLED -ne 1 -a $TIMEFINDER_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Backup Agent for Oracle                  ($ORA8_PKG)$ORA8_SPACE       ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Backup Agent for Oracle                  ($ORA8_PKG)$ORA8_SPACE       ==> [ ${INST_MSG_142} ]   "
                               Update_Agent 22
                               Update_Agent_22
fi
                            else 
                               echo "$BK_LINE_FLAG    Backup Agent for Oracle                  ($ORA8_PKG)$ORA8_SPACE       ==> [ ${INST_MSG_64} ]"
                            ORA_SUC_INST="NO"
                                 fi
                        else            # BEBora8 must be installed already
                            echo "$BK_LINE_FLAG    Backup Agent for Oracle                  ($ORA8_PKG)$ORA8_SPACE       ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            ORA_SUC_INST="NO"
                        fi

}

install_notesagt()
{
                        CA7NOTEPKG=`$PKGINFO | grep $NOTES_PKG`
                        if [ "$CA7NOTEPKG" = "" -o $NOTES_NEED_UPGRADE -eq 1 ] # install package
                        then
	                        CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
	                        if [ "$CA7CMAGTPKG" = "" ]
	                        then
	                            INSTALL_CMAGT
	                        fi
                            Test_Link /opt/CA/BABlotusagt
                            CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
                            if [ "$CA7CMAGTPKG" = "" ]
                            then
                                INSTALL_CMAGT
                            fi
if [ $NOTES_NEED_UPGRADE -eq 1 ]; then
                            echo "    Backup Agent for Lotus Domino            (BABlotus)       ==> [ ${INST_MSG_216} ]\c"
elif [ $NOTES_OLD_INSTALLED -ne 1 ]; then
                            echo "    Backup Agent for Lotus Domino            (BABlotus)       ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Backup Agent for Lotus Domino            (BABlotus)       ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $NOTES_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $NOTES_PKG CALOTUS_HOME $NOTES_PKG_DIR BABlotusagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${NOTES_PKG}.pkgask -a $TMPDIR/$PID/admin $NOTES_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${NOTES_PKG} -x reinstall=true ${NOTES_PKG},l=${NOTES_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${NOTES_PKG_DIR}/BABlotusagt 2> /dev/null
	                            if [ "${NOTES_PKG_DIR}" != "/opt/CA" -a "${NOTES_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${NOTES_PKG_DIR}/BABlotusagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $NOTES_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $NOTES_PKG CALOTUS_HOME $NOTES_PKG_DIR BABlotusagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${NOTES_PKG}.pkgask $NOTES_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${NOTES_PKG} ${NOTES_PKG},l=${NOTES_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${NOTES_PKG_DIR}/BABlotusagt 2> /dev/null
	                            if [ "${NOTES_PKG_DIR}" != "/opt/CA" -a "${NOTES_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${NOTES_PKG_DIR}/BABlotusagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $NOTES_PKG >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $NOTES_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Backup Agent for Lotus Domino            (BABlotus)       ==> [ ${INST_MSG_217} ]   "
elif [ $NOTES_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Backup Agent for Lotus Domino            (BABlotus)       ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Backup Agent for Lotus Domino            (BABlotus)       ==> [ ${INST_MSG_142} ]   "
                               Update_Agent 14 
fi
                            else 
                               echo "$BK_LINE_FLAG    Backup Agent for Lotus Domino            (BABlotus)       ==> [ ${INST_MSG_64} ]"
                            NOTE_SUC_INST="NO"
                                 fi
                        else            # BABlotus must be installed already
                            echo "$BK_LINE_FLAG    Backup Agent for Lotus Domino            (BABlotus)       ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            NOTE_SUC_INST="NO"
                        fi

}

install_sapagt()
{
                        CA7SAPPKG=`$PKGINFO | grep $SAP_PKG`
                        if [ "$CA7SAPPKG" = "" -o $SAP_NEED_UPGRADE -eq 1 ] # install package
                        then
	                        CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
	                        if [ "$CA7CMAGTPKG" = "" ]
	                        then
	                            INSTALL_CMAGT
	                        fi
                            Test_Link /opt/CA/BABsapagt
                            CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
                            if [ "$CA7CMAGTPKG" = "" ]
                            then
                                INSTALL_CMAGT
                            fi
if [ $SAP_NEED_UPGRADE -eq 1 ]; then
                            echo "    Enterprise Option for SAP R/3 for Oracle (BABsap)         ==> [ ${INST_MSG_216} ]\c"
elif [ $SAP_OLD_INSTALLED -ne 1 ]; then
                            echo "    Enterprise Option for SAP R/3 for Oracle (BABsap)         ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Enterprise Option for SAP R/3 for Oracle (BABsap)         ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $SAP_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $SAP_PKG CASAP_HOME $SAP_PKG_DIR BABsapagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SAP_PKG}.pkgask -a $TMPDIR/$PID/admin $SAP_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${SAP_PKG} -x reinstall=true ${SAP_PKG},l=${SAP_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${SAP_PKG_DIR}/BABsapagt 2> /dev/null
	                            if [ "${SAP_PKG_DIR}" != "/opt/CA" -a "${SAP_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${SAP_PKG_DIR}/BABsapagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $SAP_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $SAP_PKG CASAP_HOME $SAP_PKG_DIR BABsapagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SAP_PKG}.pkgask $SAP_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${SAP_PKG} ${SAP_PKG},l=${SAP_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${SAP_PKG_DIR}/BABsapagt 2> /dev/null
	                            if [ "${SAP_PKG_DIR}" != "/opt/CA" -a "${SAP_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${SAP_PKG_DIR}/BABsapagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $SAP_PKG >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $SAP_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for SAP R/3 for Oracle (BABsap)         ==> [ ${INST_MSG_217} ]   "
elif [ $SAP_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for SAP R/3 for Oracle (BABsap)         ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Enterprise Option for SAP R/3 for Oracle (BABsap)         ==> [ ${INST_MSG_142} ]   "
                               Update_Agent 20
fi
                            else 
                               echo "$BK_LINE_FLAG    Enterprise Option for SAP R/3 for Oracle (BABsap)         ==> [ ${INST_MSG_64} ]"
                            SAP_SUC_INST="NO"
                                 fi
                        else            # BABsap must be installed already
                            echo "$BK_LINE_FLAG    Enterprise Option for SAP R/3 for Oracle (BABsap)         ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            SAP_SUC_INST="NO"
                        fi

}

install_baimagt()
{
                        CA7BAIMPKG=`$PKGINFO | grep $BAIM_PKG`
                        if [ "$CA7BAIMPKG" = "" -o $SAP_NEED_UPGRADE -eq 1 ] # install package
                        then
                            #Test_Link /opt/CA/BABsapagt
                            CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
                            if [ "$CA7CMAGTPKG" = "" ]
                            then
                                INSTALL_CMAGT
                            fi
                            echo "    Backup Agent Integration Module          (BABbaim)        ==> [ ${INST_MSG_62} ]\c"
                            startDial &
                            DIALPID=$!
                            Untar_Package $BAIM_AGENT_PKG
if [ $SAP_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $BAIM_PKG CASAP_HOME $SAP_PKG_DIR BABsapagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${BAIM_PKG}.pkgask -a $TMPDIR/$PID/admin $BAIM_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${BAIM_PKG} -x reinstall=true ${BAIM_PKG},l=${SAP_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${SAP_PKG_DIR}/BABsapagt 2> /dev/null
	                            if [ "${SAP_PKG_DIR}" != "/opt/CA" -a "${SAP_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${SAP_PKG_DIR}/BABsapagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $BAIM_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $BAIM_PKG CASAP_HOME $SAP_PKG_DIR BABsapagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${BAIM_PKG}.pkgask $BAIM_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${BAIM_PKG} ${BAIM_PKG},l=${SAP_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${SAP_PKG_DIR}/BABsapagt 2> /dev/null
	                            if [ "${SAP_PKG_DIR}" != "/opt/CA" -a "${SAP_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${SAP_PKG_DIR}/BABsapagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $BAIM_PKG >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
                               echo "$BK_LINE_FLAG    Backup Agent Integration Module          (BABbaim)        ==> [ ${INST_MSG_63} ]   "
                            else 
                               echo "$BK_LINE_FLAG    Backup Agent Integration Module          (BABbaim)        ==> [ ${INST_MSG_64} ]"
                            SAP_SUC_INST="NO"
                                 fi
                        else            # BABsap must be installed already
                            echo "$BK_LINE_FLAG    Backup Agent Integration Module          (BABbaim)        ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
#                            SAP_SUC_INST="NO"
                        fi

}
install_sybase()
{
                        CA7SYBASEPKG=`$PKGINFO | grep $SYBASE_PKG`
                        if [ "$CA7SYBASEPKG" = "" -o $SYB_NEED_UPGRADE -eq 1 ] # install package
                        then
                            CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
                            if [ "$CA7CMAGTPKG" = "" ]
                            then
                                INSTALL_CMAGT
                            fi
if [ $SYB_NEED_UPGRADE -eq 1 ]; then
                            echo "    Backup Agent for Sybase                  (BABsybase)      ==> [ ${INST_MSG_216} ]\c"
elif [ $SYBASE_OLD_INSTALLED -ne 1 ]; then
                            echo "    Backup Agent for Sybase                  (BABsybase)      ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Backup Agent for Sybase                  (BABsybase)      ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $SYB_NEED_UPGRADE -eq 1 ]; then
	if [ -f ${SYBASE_PKG_DIR}/BABsybagt/installation.cfg ]; then
		cp ${SYBASE_PKG_DIR}/BABsybagt/installation.cfg ${SYBASE_PKG_DIR}/BABsybagt/installation.cfg.upg >/dev/null 2>&1
	fi
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $SYBASE_PKG CASYBASE_HOME $SYBASE_PKG_DIR BABsybagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SYBASE_PKG}.pkgask -a $TMPDIR/$PID/admin $SYBASE_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -x reinstall=true $SYBASE_PKG,l=${SYBASE_PKG_DIR} >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $SYBASE_PKG CASYBASE_HOME $SYBASE_PKG_DIR BABsybagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SYBASE_PKG}.pkgask $SYBASE_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $SYBASE_PKG,l=${SYBASE_PKG_DIR} >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $SYB_NEED_UPGRADE -eq 1 ]; then
				if [ -f ${SYBASE_PKG_DIR}/BABsybagt/installation.cfg.upg ]; then
					rm -f ${SYBASE_PKG_DIR}/BABsybagt/installation.cfg >/dev/null 2>&1
					mv ${SYBASE_PKG_DIR}/BABsybagt/installation.cfg.upg ${SYBASE_PKG_DIR}/BABsybagt/installation.cfg >/dev/null 2>&1
				fi
                               echo "$BK_LINE_FLAG    Backup Agent for Sybase                  (BABsybase)      ==> [ ${INST_MSG_217} ]   "
elif [ $SYBASE_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Backup Agent for Sybase                  (BABsybase)      ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Backup Agent for Sybase                  (BABsybase)      ==> [ ${INST_MSG_142} ]   "
                               Update_Agent 30
fi
                                                                    else
                               echo "$BK_LINE_FLAG    Backup Agent for Sybase                  (BABsybase)      ==> [ ${INST_MSG_64} ]"
                            SYB_SUC_INST="NO"
                            fi
                        else            # BABsybase must be installed already
                            echo "$BK_LINE_FLAG    Backup Agent for Sybase                  (BABsybase)      ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            SYB_SUC_INST="NO"
                        fi

}

install_infomix()
{
                        CA7INFMXPKG=`$PKGINFO | grep $INFMX_PKG`
                        if [ "$CA7INFMXPKG" = "" -o $INFMX_NEED_UPGRADE -eq 1 ] # install package
                        then
                            Test_Link /opt/CA/BABinfmx
                            CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
                            if [ "$CA7CMAGTPKG" = "" ]
                            then
                                INSTALL_CMAGT
                            fi
if [ $INFMX_NEED_UPGRADE -eq 1 ]; then
                            echo "    Backup Agent for Informix                (BABinfmx)       ==> [ ${INST_MSG_216} ]\c"
elif [ $INFMX_OLD_INSTALLED -ne 1 ]; then
                            echo "    Backup Agent for Informix                (BABinfmx)       ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Backup Agent for Informix                (BABinfmx)       ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $INFMX_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $INFMX_PKG CAINFMX_HOME $INFMX_PKG_DIR BABinfmx
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${INFMX_PKG}.pkgask -a $TMPDIR/$PID/admin $INFMX_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -x reinstall=true $INFMX_PKG,l=${INFMX_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" -o "$OS" = "OSF1" ]; then
	                            mkdir -p ${INFMX_PKG_DIR}/BABinfmx 2> /dev/null
	                            if [ "${INFMX_PKG_DIR}" != "/opt/CA" ]; then
	                                ln -sf ${INFMX_PKG_DIR}/BABinfmx /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $INFMX_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $INFMX_PKG CAINFMX_HOME $INFMX_PKG_DIR BABinfmx
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${INFMX_PKG}.pkgask $INFMX_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $INFMX_PKG,l=${INFMX_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" -o "$OS" = "OSF1" ]; then
	                            mkdir -p ${INFMX_PKG_DIR}/BABinfmx 2> /dev/null
	                            if [ "${INFMX_PKG_DIR}" != "/opt/CA" ]; then
	                                ln -sf ${INFMX_PKG_DIR}/BABinfmx /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $INFMX_PKG >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $INFMX_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Backup Agent for Informix                (BABinfmx)       ==> [ ${INST_MSG_217} ]   "
elif [ $INFMX_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Backup Agent for Informix                (BABinfmx)       ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Backup Agent for Informix                (BABinfmx)       ==> [ ${INST_MSG_142} ]   "
                               Update_Agent 32
fi
                                                                    else
                               echo "$BK_LINE_FLAG    Backup Agent for Informix                (BABinfmx)       ==> [ ${INST_MSG_64} ]"
                            INF_SUC_INST="NO"
                            fi
                        else            # BABinfmx must be installed already
                            echo "$BK_LINE_FLAG    Backup Agent for Informix                (BABinfmx)       ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            INF_SUC_INST="NO"
                        fi

}

install_db2agt()
{
                        CA7DB2PKG=`$PKGINFO | grep $DB2_PKG`
                        if [ "$CA7DB2PKG" = "" -o $DB2_NEED_UPGRADE -eq 1 ] # install package
                        then
                            Test_Link /opt/CA/BABdb2agt
                            CA7DB2PKG=`$PKGINFO | grep $CMG_PKG`
                            if [ "$CA7CMAGTPKG" = "" ]
                            then
                                INSTALL_CMAGT
                            fi
if [ $DB2_NEED_UPGRADE -eq 1 ]; then
                            echo "    Enterprise Option for DB2 UDB            (BABdb2)         ==> [ ${INST_MSG_216} ]\c"
elif [ $DB2_OLD_INSTALLED -ne 1 ]; then
                            echo "    Enterprise Option for DB2 UDB            (BABdb2)         ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Enterprise Option for DB2 UDB            (BABdb2)         ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $DB2_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $DB2_PKG CADB2_HOME $DB2_PKG_DIR BABdb2agt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${DB2_PKG}.pkgask -a $TMPDIR/$PID/admin $DB2_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${DB2_PKG_DIR}/BABdb2agt 2> /dev/null
	                            if [ "${DB2_PKG_DIR}" != "/opt/CA" -a "${DB2_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${DB2_PKG_DIR}/BABdb2agt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $DB2_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $DB2_PKG CADB2_HOME $DB2_PKG_DIR BABdb2agt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${DB2_PKG}.pkgask $DB2_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then 
	                            mkdir -p ${DB2_PKG_DIR}/BABdb2agt 2> /dev/null
	                            if [ "${DB2_PKG_DIR}" != "/opt/CA" -a "${DB2_PKG_DIR}" != "/opt/CA/" ]; then
	                                ln -sf ${DB2_PKG_DIR}/BABdb2agt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d  $DB2_PKG >> ${LOG_FILE}  2>&1
	fi
fi
                            install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $DB2_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for DB2 UDB            (BABdb2)         ==> [ ${INST_MSG_217} ]   "
elif [ $DB2_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for DB2 UDB            (BABdb2)         ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Enterprise Option for DB2 UDB            (BABdb2)         ==> [ ${INST_MSG_142} ]   "
                               Update_Agent 37
fi
                                                                    else
                               echo "$BK_LINE_FLAG    Enterprise Option for DB2 UDB            (BABdb2)         ==> [ ${INST_MSG_64} ]"
                            DB2_SUC_INST="NO"
                            fi
                        else            # BABdb2 must be installed already
                            echo "$BK_LINE_FLAG    Enterprise Option for DB2 UDB            (BABdb2)         ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            DB2_SUC_INST="NO"
                        fi

}

install_ingresagt()
{
                        CA7INGPKG=`$PKGINFO | grep $ING_PKG`
                        if [ "$CA7INGPKG" = "" -o $ING_NEED_UPGRADE -eq 1 ] # install package
                        then
                            CA7CMAGTPKG=`$PKGINFO | grep $CMG_PKG`
                            if [ "$CA7CMAGTPKG" = "" ]
                            then
                                INSTALL_CMAGT
                            fi
if [ $ING_NEED_UPGRADE -eq 1 ]; then
                            echo "    Enterprise Option for Advantage Ingres   (BABing)         ==> [ ${INST_MSG_216} ]\c"
elif [ $ING_OLD_INSTALLED -ne 1 ]; then
                            echo "    Enterprise Option for Advantage Ingres   (BABing)         ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Enterprise Option for Advantage Ingres   (BABing)         ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $ING_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $ING_PKG CAING_HOME $ING_PKG_DIR BABingagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${ING_PKG}.pkgask -a $TMPDIR/$PID/admin $ING_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${ING_PKG} -x reinstall=true ${ING_PKG},l=${ING_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${ING_PKG_DIR}/BABingagt 2> /dev/null
	                            if [ "${ING_PKG_DIR}" != "/opt/CA" ]; then
	                                ln -sf ${ING_PKG_DIR}/BABingagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $ING_PKG >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Package_Response $ING_PKG CAING_HOME $ING_PKG_DIR BABingagt
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${ING_PKG}.pkgask $ING_PKG < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d/${ING_PKG} ${ING_PKG},l=${ING_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            mkdir -p ${ING_PKG_DIR}/BABingagt 2> /dev/null
	                            if [ "${ING_PKG_DIR}" != "/opt/CA" ]; then
	                                ln -sf ${ING_PKG_DIR}/BABingagt /opt/CA/.
	                                if [ $? -ne 0 ]; then
	                                    CLEANUP 16
	                                fi
	                            fi
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $ING_PKG >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $ING_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for Advantage Ingres   (BABing)         ==> [ ${INST_MSG_217} ]   "
elif [ $ING_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for Advantage Ingres   (BABing)         ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Enterprise Option for Advantage Ingres   (BABing)         ==> [ ${INST_MSG_142} ]   "
                               Update_Agent 19
fi
                                                                    else
                               echo "$BK_LINE_FLAG    Enterprise Option for Advantage Ingres   (BABing)         ==> [ ${INST_MSG_64} ]"
                            ING_SUC_INST="NO"
                            fi
                        else            # BABing must be installed already
                            echo "$BK_LINE_FLAG    Enterprise Option for Advantage Ingres   (BABing)         ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            ING_SUC_INST="NO"
                        fi

}

install_sanopt()
{
                        CA7SPKG=`$PKGINFO | grep $SVR_PKG`
                        CA7GPKG=`$PKGINFO | grep $MGR_PKG`

                        if [ "$CA7SPKG" = "" -o "$CA7GPKG" = "" ]
                        then
#                           echo
                            echo "${INST_MSG_101}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_145}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_103}" >> ${LOG_FILE}  2>&1
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	exit 3
                            else
                            SAN_SUC_INST="NO"
                            echo "    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_64} ]"
                            return
                            fi
                        fi

                        CA7SANPKG=`$PKGINFO | grep $SAN_N_PKG`
                        if [ "$CA7SANPKG" = "" -o $SAN_NEED_UPGRADE -eq 1 ] # install package
                        then
if [ $SAN_NEED_UPGRADE -eq 1 ]; then
                            echo "    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_216} ]\c"
elif [ $SAN_OLD_INSTALLED -ne 1 ]; then
                            echo "    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $SAN_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $SAN_N_PKG  < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -x reinstall=true $SAN_N_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $SAN_N_PKG  >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $SAN_N_PKG  < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $SAN_N_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $SAN_N_PKG  >> ${LOG_FILE}  2>&1
	fi
fi
                                                                    install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $SAN_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_217} ]   "
elif [ $SAN_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_142} ]   "
fi
                                                                    else
                               echo "$BK_LINE_FLAG    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_64} ]"
                            SAN_SUC_INST="NO"
                            fi
                        else            # BABsan must be installed already
                            echo "$BK_LINE_FLAG    Storage Area Network (SAN) Option        (BABsan)         ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            SAN_SUC_INST="NO"
                        fi

}

install_ibmopt()
{
                        CA7SPKG=`$PKGINFO | grep $SVR_PKG`
                        CA7GPKG=`$PKGINFO | grep $MGR_PKG`

                        if [ "$CA7SPKG" = "" -o "$CA7GPKG" = "" ]
                        then
#                           echo
                            echo "${INST_MSG_101}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_145}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_103}" >> ${LOG_FILE}  2>&1
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	exit 3
                            else
                            IBM_SUC_INST="NO"
                               echo "    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_64} ]"
                            return
                            fi
                        fi


                        CA7IBMPKG=`$PKGINFO | grep $IBM_N_PKG`
                        if [ "$CA7IBMPKG" = "" -o $IBM_NEED_UPGRADE -eq 1 ] # install package
                        then
if [ $IBM_NEED_UPGRADE -eq 1 ]; then
                            echo "    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_216} ]\c"
elif [ $IBM_OLD_INSTALLED -ne 1 ]; then
                            echo "    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $IBM_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $IBM_N_PKG  < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -x reinstall=true $IBM_N_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $IBM_N_PKG  >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $IBM_N_PKG  < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $IBM_N_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $IBM_N_PKG  >> ${LOG_FILE}  2>&1
	fi
fi
				install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                                                                    if [ $install_status -eq 0 ]
                                                                    then
if [ $IBM_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_217} ]   "
elif [ $IBM_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_142} ]   "
fi
                                                                    else
                               echo "$BK_LINE_FLAG    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_64} ]"
                            IBM_SUC_INST="NO"
                            fi
                        else            # BABibmlib must be installed already
                            echo "$BK_LINE_FLAG    Enterprise Option for IBM3494            (BABibmlib)      ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            IBM_SUC_INST="NO"
                        fi

}

install_nloopt()
{
                        CA7SPKG=`$PKGINFO | grep $SVR_PKG`
                        CA7GPKG=`$PKGINFO | grep $MGR_PKG`

                        if [ "$CA7SPKG" = "" -o "$CA7GPKG" = "" ]
                        then
#                           echo
                            echo "${INST_MSG_101}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_145}" >> ${LOG_FILE}  2>&1
                            echo "${INST_MSG_103}" >> ${LOG_FILE}  2>&1
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	exit 3
                            else
                            NLO_SUC_INST="NO"
                               echo "    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_64} ]"
                            return
                            fi
                        fi

                        CA7NLOPKG=`$PKGINFO | grep $NLO_N_PKG`
                        if [ "$CA7NLOPKG" = "" -o $NLO_NEED_UPGRADE -eq 1 ] # install package
                        then
if [ $NLO_NEED_UPGRADE -eq 1 ]; then
                            echo "    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_216} ]\c"
elif [ $NLO_OLD_INSTALLED -ne 1 ]; then
                            echo "    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_62} ]\c"
else
                            echo "    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_141} ]\c"
fi
                            startDial &
                            DIALPID=$!
                            Untar_Package $PKG
if [ $NLO_NEED_UPGRADE -eq 1 ]; then
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask -a $TMPDIR/$PID/admin $NLO_N_PKG  < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -x reinstall=true $NLO_N_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -F $NLO_N_PKG  >> ${LOG_FILE}  2>&1
	fi
else
	if [ "$OS" = "SunOS" ]; then
	                            Create_Server_Package_Response $SVR_PKG
	                            $PKGADD $TMPDIR/$PID/tmppkg.d -r ${TMPDIR}/${PID}/${SVR_PKG}.pkgask $NLO_N_PKG  < ${YES_FILE} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "HP-UX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $NLO_N_PKG,l=${BEB_PKG_DIR} >> ${LOG_FILE}  2>&1
	elif [ "$OS" = "AIX" ]; then
	                            $PKGADD $TMPDIR/$PID/tmppkg.d $NLO_N_PKG  >> ${LOG_FILE}  2>&1
	fi
fi
                            install_status=$?

                            cd $HOMEDIR
                            rm -rf $TMPDIR/$PID/tmppkg.d
                            stopDial
                            if [ $install_status -eq 0 ] ; then
if [ $NLO_NEED_UPGRADE -eq 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_217} ]   "
elif [ $NLO_OLD_INSTALLED -ne 1 ]; then
                               echo "$BK_LINE_FLAG    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_63} ]   "
else
                               echo "$BK_LINE_FLAG    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_142} ]   "
fi
                                                                    else
                               echo "$BK_LINE_FLAG    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_64} ]"
	                       NLO_SUC_INST="NO"
                            fi
                        else            # BABstklib must be installed already
                            echo "$BK_LINE_FLAG    Enterprise Option for StorageTek ACSLS   (BABstklib)      ==> [ ${INST_MSG_100} ]"
                            if [ $EXEC_MODE -eq $SDO_MODE ] ; then
                            	CLEANUP 4
                            fi
                            NLO_SUC_INST="NO"
                        fi
}

check_root_account()
{
    ROOT=`id | cut -c5- | cut -d"(" -f1`
    if [ "$ROOT" != "0" ]
    then
        echo "${INST_MSG_94}"
        printf "${INST_MSG_95}" "$THISSCRIPT"
        CLEANUP 1
    fi
}

create_response_file()
{
    if [ -f $RESPONSE_FILE ] ; then
    	rm -fr $RESPONSE_FILE
    fi
    touch $RESPONSE_FILE
    if [ $? -ne 0 ] ; then
    	exit 1
    fi
	echo "#################################################################" >>$RESPONSE_FILE
	echo "$INST_MSG_176" >>$RESPONSE_FILE
	echo "#                                                               #" >>$RESPONSE_FILE
	echo "$INST_MSG_177" >>$RESPONSE_FILE
	echo "PROFILE_MODIFY=${PROFILE_MODIFY}" >>$RESPONSE_FILE
	echo "AGENTS_AUTO_START=${AGENTS_AUTO_START}" >>$RESPONSE_FILE
	echo "NLS_LANG=${NLS_LANG}" >>$RESPONSE_FILE
	echo "NLS_LOCALE=${NLS_LOCALE}" >>$RESPONSE_FILE
	echo "">>$RESPONSE_FILE
if [ "$OS" = "SunOS" ]; then
  if [ "$PLATFORM" = "s86" ]; then
	PKG_LIST="$AGT_PKG $ORA8_PKG "
  else
	PKG_LIST="$SVR_PKG $AGT_PKG $DRO_N_PKG $NAS_N_PKG $NLO_N_PKG $SAN_N_PKG $ORA8_PKG $IBM_N_PKG $INFMX_PKG $SAP_PKG $SYBASE_PKG $NOTES_PKG $DB2_PKG $ING_PKG"
  fi
elif [ "$OS" = "HP-UX" ]; then
PKG_LIST="$SVR_PKG $AGT_PKG $NAS_N_PKG $NLO_N_PKG $SAN_N_PKG $ORA8_PKG $IBM_N_PKG $INFMX_PKG $SAP_PKG $SYBASE_PKG $NOTES_PKG $ING_PKG"
elif [ "$OS" = "AIX" ]; then
PKG_LIST="$SVR_PKG $AGT_PKG $NLO_N_PKG $SAN_N_PKG $ORA8_PKG $IBM_N_PKG $INFMX_PKG $SAP_PKG $NOTES_PKG $DB2_PKG $ING_PKG"
elif [ "$OS" = "OSF1" ]; then
PKG_LIST="$AGT_PKG $ORA8_PKG $INFMX_PKG"
elif [ "$OS" = "FreeBSD" ]; then
PKG_LIST="$AGT_PKG"
fi
    for pkg_selected in $PKG_LIST
    do
        case $pkg_selected in
        $SVR_PKG)
            	if [ $SVR_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Server & Manager                                          #" >>$RESPONSE_FILE
			echo "SERVER_INSTALL=YES">>$RESPONSE_FILE
			echo "SERVER_INSTALL_PATH=${BEB_PKG_DIR}">>$RESPONSE_FILE
			echo "SERVER_GROUP_ID=${BEB_GROUP_ID}">>$RESPONSE_FILE
			echo "Portal_Server_Name=${Portal_Server_Name}">>$RESPONSE_FILE
			echo "INSTALL_DOC=${INSTALL_DOC}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $DRO_N_PKG)
            	if [ $DRO_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Disaster Recovery Option                                  #" >>$RESPONSE_FILE
			echo "DRO_INSTALL=YES">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $NAS_N_PKG)
            	if [ $NAS_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     NDMP NAS Option                                           #" >>$RESPONSE_FILE
			echo "NAS_INSTALL=YES">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $NLO_N_PKG)
            	if [ $NLO_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     StorageTek ACSLS Option                                   #" >>$RESPONSE_FILE
			echo "NLO_INSTALL=YES">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $SAN_N_PKG)
            	if [ $SAN_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Storage Area Network Option                               #" >>$RESPONSE_FILE
			echo "SAN_INSTALL=YES">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $IBM_N_PKG)
            	if [ $IBM_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     IBM3494 Library Option                                    #" >>$RESPONSE_FILE
			echo "IBM_INSTALL=YES">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $AGT_PKG)
            	if [ $AGT_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Backup Agent for UNIX                                     #" >>$RESPONSE_FILE
			echo "UAGENT_INSTALL=YES">>$RESPONSE_FILE
			echo "UAGENT_INSTALL_PATH=${AGNTUX_PKG_DIR}">>$RESPONSE_FILE
			echo "UAGENT_GROUP_ID=${UAGENT_GROUP_ID}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $ORA8_PKG)
            	if [ $ORA8_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Backup Agent for Oracle                                   #" >>$RESPONSE_FILE
			echo "ORA8_INSTALL=YES">>$RESPONSE_FILE
			echo "ORA8_INSTALL_PATH=${ORA8_PKG_DIR}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $NOTES_PKG)
            	if [ $NOTES_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Backup Agent for Lotus Notes                              #" >>$RESPONSE_FILE
			echo "NOTES_INSTALL=YES">>$RESPONSE_FILE
			echo "NOTES_INSTALL_PATH=${NOTES_PKG_DIR}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $SAP_PKG)
            	if [ $SAP_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Backup Agent for SAP R/3                                  #" >>$RESPONSE_FILE
			echo "SAP_INSTALL=YES">>$RESPONSE_FILE
			echo "SAP_INSTALL_PATH=${SAP_PKG_DIR}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $SYBASE_PKG)
            	if [ $SYBASE_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Backup Agent for SYBASE                                   #" >>$RESPONSE_FILE
			echo "SYBASE_INSTALL=YES">>$RESPONSE_FILE
			echo "SYBASE_INSTALL_PATH=${SYBASE_PKG_DIR}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $INFMX_PKG)
            	if [ $INFMX_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Backup Agent for Informix                                 #" >>$RESPONSE_FILE
			echo "INFMX_INSTALL=YES">>$RESPONSE_FILE
			echo "INFMX_INSTALL_PATH=${INFMX_PKG_DIR}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $DB2_PKG)
            	if [ $DB2_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Backup Agent for DB2                                      #" >>$RESPONSE_FILE
			echo "DB2_INSTALL=YES">>$RESPONSE_FILE
			echo "DB2_INSTALL_PATH=${DB2_PKG_DIR}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
        $ING_PKG)
            	if [ $ING_SELECTED -eq 1 ] ; then
	            	echo "#################################################################" >>$RESPONSE_FILE
			echo "#     Backup Agent for IngresII                                 #" >>$RESPONSE_FILE
			echo "ING_INSTALL=YES">>$RESPONSE_FILE
			echo "ING_INSTALL_PATH=${ING_PKG_DIR}">>$RESPONSE_FILE
			echo "">>$RESPONSE_FILE
		fi
            ;;
    	esac
    done
	echo "#                                                               #" >>$RESPONSE_FILE
	echo "$INST_MSG_178" >>$RESPONSE_FILE
	echo "#################################################################" >>$RESPONSE_FILE
	return 0
}
silent_prepare()
{
	if [ "$SERVER_INSTALL" != "YES" ]; then
		BEB_BASE_REQUESTED=0
	fi
	if [ "$DRO_INSTALL" != "YES" ]; then
		DRO_N_PKG=""
	fi
	if [ "$NAS_INSTALL" != "YES" ]; then
		NAS_N_PKG=""
	fi
	if [ "$NLO_INSTALL" != "YES" ]; then
		NLO_N_PKG=""
	fi
	if [ "$SAN_INSTALL" != "YES" ]; then
		SAN_N_PKG=""
	fi
	if [ "$IBM_INSTALL" != "YES" ]; then
		IBM_N_PKG=""
	fi
	if [ "$UAGENT_INSTALL" != "YES" ]; then
		AGT_PKG=""
	fi
	if [ "$ORA8_INSTALL" != "YES" ]; then
		ORA8_PKG=""
	fi
	if [ "$NOTES_INSTALL" != "YES" ]; then
		NOTES_PKG=""
	fi
	if [ "$SAP_INSTALL" != "YES" ]; then
		SAP_PKG=""
	fi
	if [ "$SYBASE_INSTALL" != "YES" ]; then
		SYBASE_PKG=""
	fi
	if [ "$INFMX_INSTALL" != "YES" ]; then
		INFMX_PKG=""
	fi
	if [ "$DB2_INSTALL" != "YES" ]; then
		DB2_PKG=""
	fi
	if [ "$ING_INSTALL" != "YES" ]; then
		ING_PKG=""
	fi
}
Install_Packages()
{
${ECHO} $INST_MSG_236
${ECHO}

if [ "$OS" = "SunOS" ]; then
	    Create_Admin
	if [ "$PLATFORM" = "s86" ]; then
	    PKG_LIST="$CMAGT_PKG $AGNTUX_PKG $ORA8_AGENT_PKG"
	else
            PKG_LIST="$BEB_PKG $CMAGT_PKG $AGNTUX_PKG $DRO_PKG $NAS_PKG $SAN_PKG $IBM_PKG $NLO_PKG $ORA8_AGENT_PKG $NOTES_AGENT_PKG $SAP_AGENT_PKG $SYBASE_AGENT_PKG $INFMX_AGENT_PKG $DB2_AGENT_PKG $ING_AGENT_PKG"
        fi
elif [ "$OS" = "HP-UX" ]; then
            PKG_LIST="$BEB_PKG $CMAGT_PKG $AGNTUX_PKG $NAS_PKG $SAN_PKG $IBM_PKG $NLO_PKG $ORA8_AGENT_PKG $NOTES_AGENT_PKG $SAP_AGENT_PKG $SYBASE_AGENT_PKG $INFMX_AGENT_PKG $ING_AGENT_PKG"
elif [ "$OS" = "AIX" ]; then
            PKG_LIST="$BEB_PKG $CMAGT_PKG $AGNTUX_PKG $SAN_PKG $IBM_PKG $ORA8_AGENT_PKG $NOTES_AGENT_PKG $SAP_AGENT_PKG $INFMX_AGENT_PKG $NLO_PKG $DB2_AGENT_PKG $ING_AGENT_PKG"
elif [ "$OS" = "OSF1" ]; then
            PKG_LIST="$CMAGT_PKG $AGNTUX_PKG $ORA8_AGENT_PKG $INFMX_AGENT_PKG"
elif [ "$OS" = "FreeBSD" ]; then
        PKG_LIST="$CMAGT_PKG $AGNTUX_PKG"

############# choji01 FreeBSD 6.x support
#
#	uname -r|grep '6..' > /dev/null 2>&1
#	if [ $? -eq 0 ]; then
#        	OS_FREEBSD_6="YES"
#	fi
#	if [ "X${OS_FREEBSD_6}" = "XYES" ]; then
#	       	ln -s /lib/libcrypt.so.3 /lib/libcrypt.so.2 > /dev/null 2>&1
#        	ln -s /usr/lib/librpcsvc.so.3 /usr/lib/librpcsvc.so.2 > /dev/null 2>&1
#	        ln -s  /usr/lib/libstdc++.so.5  /usr/lib/libstdc++.so.4 > /dev/null 2>&1
#	        ln -s /lib/libpthread.so.2 /usr/lib/libpthread.so.1 > /dev/null 2>&1
#
#	        if [ ! -f /usr/lib/compat/libc.so.4 ]; then
#        	         cp ${PKG_LOCATION}/libs/libc.so.4 /usr/lib/compat/
#	        fi
#
#	        if [ ! -f /usr/lib/compat/libc.so.5 ]; then
#        	          cp ${PKG_LOCATION}/libs/libc.so.5 /usr/lib/compat/
#	        fi
#	fi
#############
fi
	    for PKG in $PKG_LIST
            do
                if [ "$PKG" = "$BEB_PKG" -a $BEB_BASE_REQUESTED -eq 1 -a -f $BEB_PKG ]
                then
                        install_base
                elif [ "$PKG" = "$CMAGT_PKG" -a -f $CMAGT_PKG -a $CAAGENT_NEED_UPGRADE -eq 1 ]
                then
                        INSTALL_CMAGT
                elif [ "$PKG" = "$AGNTUX_PKG" -a "$AGT_PKG" != "" -a -f $AGNTUX_PKG ]
                then
                        install_agntux
                elif [ "$PKG" = "$DRO_PKG" -a "$DRO_N_PKG" != "" -a -f $DRO_PKG ]
                then
                        install_dro
                elif [ "$PKG" = "$NAS_PKG" -a "$NAS_N_PKG" != "" -a -f $NAS_PKG ]
                then
                        install_nas
                elif [ "$PKG" = "$ORA8_AGENT_PKG" -a "$ORA8_PKG" != "" -a -f $ORA8_AGENT_PKG ]
                then
                        install_ora8agt
                elif [ "$PKG" = "$NOTES_AGENT_PKG" -a "$NOTES_PKG" != "" -a -f $NOTES_AGENT_PKG ]
                then
                        install_notesagt
                elif [ "$PKG" = "$SAP_AGENT_PKG" -a "$SAP_PKG" != "" -a -f $SAP_AGENT_PKG ]
                then
                        install_sapagt
                        install_baimagt
                elif [ "$PKG" = "$SYBASE_AGENT_PKG" -a "$SYBASE_PKG" != "" -a -f $SYBASE_AGENT_PKG ]
                then
                        install_sybase
                elif [ "$PKG" = "$INFMX_AGENT_PKG" -a "$INFMX_PKG" != "" -a -f $INFMX_AGENT_PKG ]
                then
                        install_infomix
                elif [ "$PKG" = "$DB2_AGENT_PKG" -a "$DB2_PKG" != "" -a -f $DB2_AGENT_PKG ]
                then
                        install_db2agt
                elif [ "$PKG" = "$ING_AGENT_PKG" -a "$ING_PKG" != "" -a -f $ING_AGENT_PKG ]
                then
                        install_ingresagt
                elif [ "$PKG" = "$SAN_PKG" -a "$SAN_N_PKG" != "" -a -f $SAN_PKG ]
                then
                        install_sanopt
                elif [ "$PKG" = "$IBM_PKG" -a "$IBM_N_PKG" != "" -a -f $IBM_PKG ]
                then

                        install_ibmopt
                elif [ "$PKG" = "$NLO_PKG" -a "$NLO_N_PKG" != "" -a -f $NLO_PKG ]
                then
                        install_nloopt
                fi
        done
	if [ $BEB_NEW_INSTALLED -eq 1 -a $EXEC_MODE -ne $SDO_MODE ]; then
 	    	DOCUMENT_ROOT="$BEB_PKG_DIR/BrightStorARCserve"
		install_document
	fi
        if [ $EXEC_MODE -eq $SDO_MODE -a "$LICENSE_INSTALL" = "YES" ]; then
        	Install_License_Package 
        fi
        if [ $EXEC_MODE -eq $SDO_MODE ]; then
        	return
        fi
    	if [ $BEBSVR_OLD_INSTALLED -eq 1 -o $BEBMGR_OLD_INSTALLED -eq 1 -o $UAGENT_OLD_INSTALLED -eq 1 \
    		-o $ASAGENT_OLD_INSTALLED -eq 1 -o $DRO_OLD_INSTALLED -eq 1 -o $NAS_OLD_INSTALLED -eq 1 \
    		-o $NLO_OLD_INSTALLED -eq 1 -o $SAN_OLD_INSTALLED -eq 1 -o $ORA_OLD_INSTALLED -eq 1 \
    		-o $ORA8_OLD_INSTALLED -eq 1 -o $IBM_OLD_INSTALLED -eq 1 -o $INFMX_OLD_INSTALLED -eq 1 \
    		-o $SAP_OLD_INSTALLED -eq 1 -o $SYBASE_OLD_INSTALLED -eq 1 -o $ING_OLD_INSTALLED -eq 1 \
    		-o $DB2_OLD_INSTALLED -eq 1 -o $NOTES_OLD_INSTALLED -eq 1 -o $ORA8SL_OLD_INSTALLED -eq 1 \
    		-o $TIMEFINDER_OLD_INSTALLED -eq 1 ]; then
		echo
		echo "$INST_MSG_191"
		echo
		if [ $EXEC_MODE -ne $SLNT_MODE ]; then
			echo "${INST_MSG_91}\c"
			read
		fi
		echo
                echo "$INST_MSG_192"
                startDial &
            	DIALPID=$!
		remove_old_pkg >> ${LOG_FILE} 2>&1
		stopDial
		echo
    	fi
	if [ -x /usr/bin/caagent ]; then
		/usr/bin/caagent stop >/dev/null 2>&1
		/usr/bin/caagent start >/dev/null 2>&1
	fi
	if [ -x /usr/bin/uagent ]; then
		/usr/bin/uagent start >/dev/null 2>&1
	fi	
}
install_document()
{
	if [ "X${INSTALL_DOC}" = "XYES" ]; then
		if [ "X$DOCUMENT_ROOT" != "X" -a -r $DOCUMENT_ROOT ]; then
			if [ -d $PKG_LOCATION/doc/${NLS_LANG} ]; then
				echo
				printf "$INST_MSG_196" "${DOCUMENT_ROOT}/doc/"
				mkdir $DOCUMENT_ROOT/doc >/dev/null 2>&1
	                        cp -R $PKG_LOCATION/doc/${NLS_LANG}/* $DOCUMENT_ROOT/doc/ >>${LOG_FILE} 2>&1
	                        INST_DOCS_SUC_FLAG=$?
				if [ $INST_DOCS_SUC_FLAG -ne 0 ] ; then
					echo $INST_MSG_197
				else
					echo $INST_MSG_198
				fi
			else
				echo $INST_MSG_197
			fi	
		else
			echo $INST_MSG_197
		fi
	fi
}
remove_old_babagent()
{
	PKG_LIST="$AGT_PKG $CMG_PKG"
	/usr/CAagent/caagent stop >/dev/null 2>&1
	if [ "$OS" = "SunOS" ]; then
		echo > /tmp/admin
		echo "mail=" >> /tmp/admin
		echo "basedir=default" >> /tmp/admin
		echo "conflict=nocheck" >> /tmp/admin
		echo "setuid=nocheck" >> /tmp/admin
		echo "action=nocheck" >> /tmp/admin
		echo "partial=nocheck" >> /tmp/admin
		echo "instance=overwrite" >> /tmp/admin
		echo "idepend=quit" >> /tmp/admin
		echo "rdepend=quit" >> /tmp/admin
		echo "space=quit" >> /tmp/admin
		for old_pkg in $PKG_LIST
		do
			$PKGRM -a /tmp/admin $old_pkg <${YES_FILE} 2>/dev/null
		done
		rm -f /tmp/admin
	else
		for old_pkg in $PKG_LIST
		do
			$PKGRM $old_pkg 2>/dev/null
		done
	fi
}
remove_old_pkg()
{
	if [ $AGENTS_DIR -eq 1 ]; then
		PKG_LIST="$UAGENT_OLD $ASAGENT_OLD"
	else
		PKG_LIST="$UAGENT_OLD $DRO_OLD $NAS_OLD $NLO_OLD $SAN_OLD $ORA_OLD $ORA8_OLD $IBM_OLD $INFMX_OLD BEBbaim $SAP_OLD $SYBASE_OLD $ING_OLD $DB2_OLD $NOTES_OLD $ORA8SL_OLD $TIMEFINDER_OLD $BEBMGR_OLD $BEBSVR_OLD $ASAGENT_OLD"
	fi
	if [ "$OS" = "SunOS" ]; then
		Create_Admin
		for old_pkg in $PKG_LIST
		do
			$PKGRM -n -a $TMPDIR/$PID/admin $old_pkg 2>/dev/null
			if [ "$old_pkg" = "$BEBSVR_OLD" -a $BEBSVR_OLD_INSTALLED -eq 1 ]; then
				create_lib_links
			fi
			if [ "$old_pkg" = "$ASAGENT_OLD" ]; then
				create_caagent_links
				Update_Agent 100
			fi
			if [ "$old_pkg" = "$UAGENT_OLD" ]; then
				create_uagent_links
			fi
			if [ "$old_pkg" = "$INFMX_OLD" -a $INFMX_OLD_INSTALLED -eq 1 ]; then
				if [ "X${INF_PREFIX}" = "X" ]; then
					CAINFMX_HOME="/opt/CA/BABinfmx"
				elif [ "X${INF_PREFIX}" = "X/" ]; then
					CAINFMX_HOME="/BABinfmx"
				else
					CAINFMX_HOME="${INF_PREFIX}/BABinfmx"
				fi
				if [ -f ${INF_PREFIX:-/opt/CA}/BABinfmx/installation.cfg -a "X${INFO_DIR}" != "X" ]; then
				        cd ${INF_PREFIX:-/opt/CA}/BABinfmx >/dev/null 2>&1
				        ${INF_PREFIX:-/opt/CA}/BABinfmx/infmxsetup -s "$CAINFMX_HOME" "${INFO_DIR}" "2" >> ${LOG_FILE} 2>&1
			        fi
			fi        
		done
		rm -f $TMPDIR/$PID/admin
	else
		for old_pkg in $PKG_LIST
		do
			if [ "$old_pkg" = "$BEBSVR_OLD" -a "$OS" = "AIX" -a $BEBSVR_OLD_INSTALLED -eq 1 ]; then
				if [ "$BEBSVR_OLD_VERSION" = "10.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0.0" ]; then
					mkdir ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/libbak
					cp -R ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/lib* ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/libbak/ >/dev/null 2>&1
				fi
			fi
			$PKGRM $old_pkg 2>/dev/null
			if [ "$old_pkg" = "$BEBSVR_OLD" -a "$OS" = "AIX" -a $BEBSVR_OLD_INSTALLED -eq 1 ]; then
				if [ "$BEBSVR_OLD_VERSION" = "10.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0" -o "$BEBSVR_OLD_VERSION" = "10.0.0.0" ]; then
					rm -f ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/lib* >/dev/null 2>&1
					mv ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/libbak/lib* ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/lib/ >/dev/null 2>&1
					rm -fR ${ARC_PREFIX:-/opt/CA}/BrightStorARCserve/libbak >/dev/null 2>&1
				fi
			fi
			if [ "$old_pkg" = "$BEBSVR_OLD" -a $BEBSVR_OLD_INSTALLED -eq 1 ]; then
				create_lib_links
			fi
			if [ "$old_pkg" = "$ASAGENT_OLD" ]; then
				create_caagent_links
				Update_Agent 100
			fi
			if [ "$old_pkg" = "$UAGENT_OLD" ]; then
				create_uagent_links
			fi
			if [ "$old_pkg" = "$INFMX_OLD" -a $INFMX_OLD_INSTALLED -eq 1 ]; then
				if [ -f ${INF_PREFIX:-/opt/CA}/BABinfmx/installation.cfg -a "X${INFO_DIR}" != "X" ]; then
					if [ "X${INF_PREFIX}" = "X" ]; then
						CAINFMX_HOME="/opt/CA/BABinfmx"
					elif [ "X${INF_PREFIX}" = "X/" ]; then
						CAINFMX_HOME="/BABinfmx"
					else
						CAINFMX_HOME="${INF_PREFIX}/BABinfmx"
					fi
				        cd ${INF_PREFIX:-/opt/CA}/BABinfmx >/dev/null 2>&1
				        ${INF_PREFIX:-/opt/CA}/BABinfmx/infmxsetup -s "$CAINFMX_HOME" "${INFO_DIR}" "2" >> ${LOG_FILE} 2>&1
			        fi
			fi        
		done
	fi
}
Create_Admin()
{
	echo > $TMPDIR/$PID/admin
	echo "mail=" >> $TMPDIR/$PID/admin
	echo "basedir=default" >> $TMPDIR/$PID/admin
	echo "conflict=nocheck" >> $TMPDIR/$PID/admin
	echo "setuid=nocheck" >> $TMPDIR/$PID/admin
	echo "action=nocheck" >> $TMPDIR/$PID/admin
	echo "partial=nocheck" >> $TMPDIR/$PID/admin
	echo "instance=overwrite" >> $TMPDIR/$PID/admin
	echo "idepend=quit" >> $TMPDIR/$PID/admin
	echo "rdepend=quit" >> $TMPDIR/$PID/admin
	echo "space=quit" >> $TMPDIR/$PID/admin
}
Migration_ARC_Init()
{
	BEBSVR_OLD=BEBsvr
	BEBMGR_OLD=BEBmgr
	UAGENT_OLD=BEBagntux
	ASAGENT_OLD=BEBcmagt
	DRO_OLD=BEBdr
	NAS_OLD=BEBnas
	NLO_OLD=BEBstklib
	ORA_OLD=BEBora
	ORA8_OLD=BEBora8
	INFMX_OLD=BEBinfmx
	NOTES_OLD=BEBlotus
	SYBASE_OLD=BEBsybase
	SAP_OLD=BEBsap
	SAN_OLD=BEBsan
	IBM_OLD=BEBibmlib
	ING_OLD=BEBing
	DB2_OLD=BEBdb2
	ORA8SL_OLD=BEBora8sl
	TIMEFINDER_OLD=BEBora
	GATEWAY_OLD=iGateway
if [ "$OS" = "AIX" ]; then
	NLO_OLD=BEBnlo
	UAGENT_OLD=UAG
	ASAGENT_OLD=CAAG
	INFMX_OLD=CAinfmx
	NOTES_OLD=CAlotus
	ORA_OLD=CAora
	ORA8_OLD=CAora8
elif [ "$OS" = "OSF1" ]; then
	UAGENT_OLD=BEBAGNTUX10
	ASAGENT_OLD=BEBCMAGT10
	ORA_OLD=BEBORA10
	ORA8_OLD=BEBORA8
	INFMX_OLD=BEBINFMX
fi
	
	BEBSVR_OLD_INSTALLED=0
	BEBMGR_OLD_INSTALLED=0
	UAGENT_OLD_INSTALLED=0
	ASAGENT_OLD_INSTALLED=0
	DRO_OLD_INSTALLED=0
	NAS_OLD_INSTALLED=0
	NLO_OLD_INSTALLED=0
	SAN_OLD_INSTALLED=0
	ORA_OLD_INSTALLED=0
	ORA8_OLD_INSTALLED=0
	IBM_OLD_INSTALLED=0
	INFMX_OLD_INSTALLED=0
	SAP_OLD_INSTALLED=0
	SYBASE_OLD_INSTALLED=0
	ING_OLD_INSTALLED=0
	DB2_OLD_INSTALLED=0
	NOTES_OLD_INSTALLED=0
	ORA8SL_OLD_INSTALLED=0
	TIMEFINDER_OLD_INSTALLED=0
	GATEWAY_OLD_INSTALLED=0

	CAAGENT_HAVE_INSTALLED=0
	CAAGENT_NEED_UPGRADE=0
	SERVER_NEED_UPGRADE=0
	MANAGER_NEED_UPGRADE=0
	UAG_NEED_UPGRADE=0
	AGT_OLD_INSTALLED=0
	CMG_OLD_INSTALLED=0
	NAS_NEED_UPGRADE=0
	DRO_NEED_UPGRADE=0
	SAN_NEED_UPGRADE=0
	ING_NEED_UPGRADE=0
	SYB_NEED_UPGRADE=0
	INFMX_NEED_UPGRADE=0
	ORA_NEED_UPGRADE=0	
	NLO_NEED_UPGRADE=0	
	IBM_NEED_UPGRADE=0	
	SAP_NEED_UPGRADE=0	
	NOTES_NEED_UPGRADE=0	
	DB2_NEED_UPGRADE=0
	GATEWAY_NEED_UPGRADE=0	

	SERVER_ALREADY_INSTALLED=0
	UAG_ALREADY_INSTALLED=0
	ING_ALREADY_INSTALLED=0
	SYB_ALREADY_INSTALLED=0
	INFMX_ALREADY_INSTALLED=0
	ORA_ALREADY_INSTALLED=0	
	SAP_ALREADY_INSTALLED=0	
	NOTES_ALREADY_INSTALLED=0	
	DB2_ALREADY_INSTALLED=0

        BEB_CMG_REQUESTED=0
	SVR_SELECTED=0
	AGT_SELECTED=0
	SAN_SELECTED=0
	IBM_SELECTED=0
	DRO_SELECTED=0
	NAS_SELECTED=0
	NLO_SELECTED=0
	ORA8_SELECTED=0
	SYBASE_SELECTED=0
	INFMX_SELECTED=0
	SAP_SELECTED=0
	NOTES_SELECTED=0
	DB2_SELECTED=0
	ING_SELECTED=0
	IS_SP=0
}
Get_BuildNum()
{
	if [ -f $1 ]; then
		    TEMPSTR1=`cat $1|cut -d"(" -f2 2>/dev/null`
		    TEMPSTR2=`echo $TEMPSTR1|cut -d")" -f1 2>/dev/null`
		    echo "$TEMPSTR2"|cut -d" " -f2 2>/dev/null
	else
		echo 0
	fi
}

detect_old_pkg()
{
	echo
	echo "$INST_MSG_179"
	startDial &
	DIALPID=$!

	if [ -f ${PKG_LOCATION}/.RELVERSION ]; then
		CURRENT_BUILD=$(Get_BuildNum "${PKG_LOCATION}/.RELVERSION")
	elif [ -f ${PKG_LOCATION}/../../.RELVERSION ]; then
		CURRENT_BUILD=$(Get_BuildNum "${PKG_LOCATION}/../../.RELVERSION")
	else
		CURRENT_BUILD=0
	fi
	if [ "X${CURRENT_BUILD}" = "X" ]; then
		CURRENT_BUILD=0
	fi

	isInstalled $ASAGENT_OLD
	if [ $? -eq 0 ];then
		ASAGENT_OLD_INSTALLED=1
		if [ -d /usr/CAagent ]; then
		    CAAGENT_OLD_PKG_DIR=/usr/CAagent
		elif [ -d /opt/CA/BEBcmagt ]; then
		    CAAGENT_OLD_PKG_DIR=/opt/CA/BEBcmagt
		fi
		if [ "$CAAGENT_OLD_PKG_DIR" = "" ]
		then
			CAAGENT_OLD_INSTALLED=0
		fi
	fi
	isInstalled $CMG_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			CMG_VERSION=`pkgparam $CMG_PKG VERSION 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			CMG_VERSION=`${PKGINFO} -a revision $CMG_PKG | grep "$CMG_PKG" | grep -v "$CMG_PKG.$CMG_PKG" | ${AWK} '{ print $NF }'`
		elif [ "$OS" = "OSF1" ]; then
    			BUILD_1500=`setld -i | ${AWK} '/BAB/ && $2 == "installed" { print $0 }' | grep "$CMG_PKG" | grep "(Build 1500)"`
    			if [ "$BUILD_1500" != "" ]; then
    			  CMG_VERSION=10.0
    			fi
		elif [ "$OS" = "FreeBSD" ]; then
    			:
		fi
		if [ "X$CMG_VERSION" = "X10.0" ]; then
			CMG_OLD_INSTALLED=1
			if [ -d /usr/CAagent ]; then
			    CAAGENT_OLD_PKG_DIR=/usr/CAagent
			fi
			if [ "$CAAGENT_OLD_PKG_DIR" = "" ]
			then
				CMG_OLD_INSTALLED=0
			fi			
		else
			CAAGENT_OLD_PKG_DIR=/opt/CA/BABcmagt
	#		BUILDNUM_OLD_CAAGENT=$(Get_BuildNum "${CAAGENT_OLD_PKG_DIR}/RELVERSION")
	#		if [ $Pre_B_Num -lt $CURRENT_BUILD ]; then
	#			CAAGENT_NEED_UPGRADE=1
	#		fi
			CAAGENT_HAVE_INSTALLED=1
		fi
	fi

	isInstalled $UAGENT_OLD
	if [ $? -eq 0 ];then
		UAGENT_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			UAGENT_OLD_VERSION=`pkgparam $UAGENT_OLD VERSION 2> /dev/null`
			UAGENT_OLD_PKG_DIR=`pkgparam $UAGENT_OLD UAGENT_HOME 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			UAGENT_OLD_VERSION=`${PKGINFO} -a revision $UAGENT_OLD | grep "$UAGENT_OLD" | grep -v "$UAGENT_OLD.$UAGENT_OLD" | ${AWK} '{ print $NF }'`
    			UAGENT_OLD_PKG_DIR=`${PKGINFO} -a location $UAGENT_OLD | grep "$UAGENT_OLD" | grep -v "$UAGENT_OLD.$UAGENT_OLD" | ${AWK} '{ print $NF }'`
    			if [ -d $UAGENT_OLD_PKG_DIR/uagent ]; then
    				UAGENT_OLD_PKG_DIR="$UAGENT_OLD_PKG_DIR/uagent"
    			elif [ -d $UAGENT_OLD_PKG_DIR/BEBuagent ]; then
    				UAGENT_OLD_PKG_DIR="$UAGENT_OLD_PKG_DIR/BEBuagent"    				
    			fi
		elif [ "$OS" = "AIX" ]; then
		    if [ -h /opt/CA/BEBuagent ]; then
		      HOME_DIR=`ls -l /opt/CA/BEBuagent | sed 's/.*>//g'`
		      UAGENT_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /usr/uagent ]; then
		      HOME_DIR=`ls -l /usr/uagent | sed 's/.*>//g'`
		      UAGENT_OLD_PKG_DIR="${HOME_DIR}"
		    elif [ -d /opt/CA/BEBuagent ]; then
		      UAGENT_OLD_PKG_DIR="/opt/CA/BEBuagent"      
		    elif [ -d /usr/uagent ]; then
		      UAGENT_OLD_PKG_DIR=/usr/uagent
		    fi
		    ver=`$PKGINFO | grep $UAGENT_OLD`
		    UAGENT_OLD_VERSION=`echo $ver | cut -d" " -f2`
		else
		    if [ -h /opt/CA/BEBuagent ]; then
		      HOME_DIR=`ls -l /opt/CA/BEBuagent | sed 's/.*>//g'`
		      UAGENT_OLD_PKG_DIR=$HOME_DIR
		    elif [ -d /opt/CA/BEBuagent ]; then
		      HOME_DIR="/opt/CA/BEBuagent"
		      UAGENT_OLD_PKG_DIR=$HOME_DIR
		    elif [ -h /uagent ]; then
		      HOME_DIR=`ls -l /uagent | sed 's/.*>//g'`
		      UAGENT_OLD_PKG_DIR=`dirname $HOME_DIR`
		    elif [ -d /uagent ]; then
		      UAGENT_OLD_PKG_DIR="/"
		    fi
		fi
		if [ "$UAGENT_OLD_PKG_DIR" = "" ]
		then
			UAGENT_OLD_INSTALLED=0
		else
		    BUILDNUM_OLD_UAGENT=$(Get_BuildNum "${UAGENT_OLD_PKG_DIR}/RELVERSION")
		    UAGENT_OLD_PKG_DIR_SUB=`basename $UAGENT_OLD_PKG_DIR`
		    UAGENT_OLD_PKG_DIR=`dirname $UAGENT_OLD_PKG_DIR`
		fi
	fi
	isInstalled $AGT_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			AGT_VERSION=`pkgparam $AGT_PKG VERSION 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			AGT_VERSION=`${PKGINFO} -a revision $AGT_PKG | grep "$AGT_PKG" | grep -v "$AGT_PKG.$AGT_PKG" | ${AWK} '{ print $NF }'`
		elif [ "$OS" = "OSF1" ]; then
    			BUILD_1500=`setld -i | ${AWK} '/BAB/ && $2 == "installed" { print $0 }' | grep "$AGT_PKG" | grep "(Build 1500)"`
    			if [ "$BUILD_1500" != "" ]; then
    			  AGT_VERSION=10.0
    			fi
		elif [ "$OS" = "FreeBSD" ]; then
    			:
		fi
		if [ "X$AGT_VERSION" = "X10.0" ]; then
			UAG_NEED_UPGRADE=1
			AGT_OLD_INSTALLED=1
			if [ "$OS" = "SunOS" ]; then
				UAGENT_OLD_PKG_DIR=`pkgparam $AGT_PKG UAGENT_HOME 2> /dev/null`
				if [ -d $UAGENT_OLD_PKG_DIR ]; then
					UAGENT_OLD_PKG_DIR=`dirname $UAGENT_OLD_PKG_DIR`
				else
					UAGENT_OLD_PKG_DIR=""
					UAG_NEED_UPGRADE=0
				fi
			elif [ "$OS" = "HP-UX" ]; then
	    			UAGENT_OLD_PKG_DIR=`${PKGINFO} -a location $AGT_PKG | grep "$AGT_PKG" | grep -v "$AGT_PKG.$AGT_PKG" | ${AWK} '{ print $NF }'`
	    			if [ ! -d $UAGENT_OLD_PKG_DIR ]; then
					UAGENT_OLD_PKG_DIR=""
					UAG_NEED_UPGRADE=0
	    			fi
			elif [ "$OS" = "OSF1" ]; then
				if [ -d /uagent ]; then
					UAGENT_OLD_PKG_DIR=""
				fi
			fi
		else
			if [ "$OS" = "SunOS" ]; then
				UAGENT_OLD_PKG_DIR=`pkgparam $AGT_PKG|grep "BABuagent" |grep -v "^BABuagent"|grep -v "^/var/sadm/pkg/"`
			elif [ "$OS" = "HP-UX" ]; then
	    			UAGENT_OLD_PKG_DIR=`${PKGINFO} -a location $AGT_PKG | grep "$AGT_PKG" | grep -v "$AGT_PKG.$AGT_PKG" | ${AWK} '{ print $NF }'`
	    			UAGENT_OLD_PKG_DIR="${UAGENT_OLD_PKG_DIR}/BABuagent"
			elif [ "$OS" = "AIX" ]; then
			    UAGENT_OLD_PKG_DIR=`lslpp -f $AGT_PKG.obj|grep "BABuagent/uagentd"|sed -e "s/ //g" | ${AWK} -F"/BABuagent/uagentd" '{ print $1}'`
			    if [ -h $UAGENT_OLD_PKG_DIR/BABuagent ]; then
			      HOME_DIR=`ls -l $UAGENT_OLD_PKG_DIR/BABuagent | sed 's/.*>//g'`
			      UAGENT_OLD_PKG_DIR="$HOME_DIR"      
			    elif [ -d $UAGENT_OLD_PKG_DIR/BABuagent ]; then
			      UAGENT_OLD_PKG_DIR="$UAGENT_OLD_PKG_DIR/BABuagent"      
			    elif [ -h /opt/CA/BABuagent ]; then
			      HOME_DIR=`ls -l /opt/CA/BABuagent | sed 's/.*>//g'`
			      UAGENT_OLD_PKG_DIR="$HOME_DIR"      
			    elif [ -d /opt/CA/BABuagent ]; then
			      UAGENT_OLD_PKG_DIR=/opt/CA/BABuagent
			    fi
			elif [ "$OS" = "FreeBSD" ]; then
				UAGENT_OLD_PKG_DIR=`pkg_info -qp $AGT_PKG | head -n 1 | cut -d' ' -f2`
			        UAGENT_OLD_PKG_DIR=${UAGENT_OLD_PKG_DIR}/BABuagent
			else
			    if [ -h /opt/CA/BABuagent ]; then
			      HOME_DIR=`ls -l /opt/CA/BABuagent | sed 's/.*>//g'`
			      UAGENT_OLD_PKG_DIR=$HOME_DIR
			    elif [ -d /opt/CA/BABuagent ]; then
			      HOME_DIR="/opt/CA/BABuagent"
			      UAGENT_OLD_PKG_DIR=$HOME_DIR
			    fi
			fi
			if [ "$UAGENT_OLD_PKG_DIR" = "" ]
			then
			    UAG_NEED_UPGRADE=0
			else
			    BUILDNUM_OLD_UAGENT=$(Get_BuildNum "${UAGENT_OLD_PKG_DIR}/RELVERSION")
			    if [ $BUILDNUM_OLD_UAGENT -lt $CURRENT_BUILD ]; then
				UAG_NEED_UPGRADE=1
			    else
				UAG_ALREADY_INSTALLED=1
			    fi
			    UAGENT_OLD_PKG_DIR=`dirname $UAGENT_OLD_PKG_DIR`
			fi
		fi
	fi

if [ "$PLATFORM" != "s86-amd64" ]; then
	isInstalled $ORA8_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			ORA_OLD_PKG_DIR=`pkgparam $ORA8_PKG|grep "BABoraagt" |grep -v "^BABoraagt"|grep -v "^/var/sadm/pkg/"`
		elif [ "$OS" = "HP-UX" ]; then
    			ORA_OLD_PKG_DIR=`${PKGINFO} -a location $ORA8_PKG | grep "$ORA8_PKG" | grep -v "$ORA8_PKG.$ORA8_PKG" | ${AWK} '{ print $NF }'`
    			ORA_OLD_PKG_DIR="${ORA_OLD_PKG_DIR}/BABoraagt"
		elif [ "$OS" = "AIX" ]; then
		    ORA_OLD_PKG_DIR=`lslpp -f $ORA8_PKG.obj|grep "BABoraagt/oragentd"|sed -e "s/ //g" | ${AWK} -F"/BABoraagt/oragentd" '{ print $1}'`
		    if [ -h $ORA_OLD_PKG_DIR/BABoraagt ]; then
		      HOME_DIR=`ls -l $ORA_OLD_PKG_DIR/BABoraagt | sed 's/.*>//g'`
		      ORA_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d $ORA_OLD_PKG_DIR/BABoraagt ]; then
		      ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/BABoraagt"      
		    elif [ -h /opt/CA/BABoraagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BABoraagt | sed 's/.*>//g'`
		      ORA_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d /opt/CA/BABoraagt ]; then
		      ORA_OLD_PKG_DIR=/opt/CA/BABoraagt
		    fi
		else
		    if [ -h /opt/CA/BABoraagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BABoraagt | sed 's/.*>//g'`
		      ORA_OLD_PKG_DIR=$HOME_DIR
		    elif [ -d /opt/CA/BABoraagt ]; then
		      HOME_DIR="/opt/CA/BABoraagt"
		      ORA_OLD_PKG_DIR=$HOME_DIR
		    fi
		fi
		if [ "$ORA_OLD_PKG_DIR" = "" ]
		then
		    ORA_NEED_UPGRADE=0
		else
		    BUILDNUM_OLD_ORA=$(Get_BuildNum "${ORA_OLD_PKG_DIR}/data/RELVERSION")
		    if [ $BUILDNUM_OLD_ORA -lt $CURRENT_BUILD ]; then
			ORA_NEED_UPGRADE=1
		    else
			ORA_ALREADY_INSTALLED=1
		    fi
		    ORA_OLD_PKG_DIR=`dirname $ORA_OLD_PKG_DIR`
		fi
	fi
	isInstalled $ORA_OLD
	if [ $? -eq 0 ];then
		ORA_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			ORA_OLD_VERSION=`pkgparam $ORA_OLD VERSION 2> /dev/null`
			ORA_OLD_PKG_DIR=`pkgparam $ORA_OLD CAORA_HOME 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			ORA_OLD_VERSION=`${PKGINFO} -a revision $ORA_OLD | grep "$ORA_OLD" | grep -v "$ORA_OLD.$ORA_OLD" | ${AWK} '{ print $NF }'`
    			ORA_OLD_PKG_DIR=`${PKGINFO} -a location $ORA_OLD | grep "$ORA_OLD" | grep -v "$ORA_OLD.$ORA_OLD" | ${AWK} '{ print $NF }'`
    			if [ -d $ORA_OLD_PKG_DIR/BEBoraagt ]; then
    				ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/BEBoraagt"
    			elif [ -d $ORA_OLD_PKG_DIR/CAora ]; then
    				ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/CAora"    				
    			fi
		elif [ "$OS" = "AIX" ]; then
		    if [ -h /opt/CA/BEBoraagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BEBoraagt | sed 's/.*>//g'`
		      ORA_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /usr/CAora ]; then
		      HOME_DIR=`ls -l /usr/CAora | sed 's/.*>//g'`
		      ORA_OLD_PKG_DIR="${HOME_DIR}"
		    elif [ -d /opt/CA/BEBoraagt ]; then
		      ORA_OLD_PKG_DIR="/opt/CA/BEBoraagt"      
		    elif [ -d /usr/CAora ]; then
		      ORA_OLD_PKG_DIR=/usr/CAora
		    fi
		    ver=`$PKGINFO | grep $ORA_OLD`
		    ORA_OLD_VERSION=`echo $ver | cut -d" " -f2`
		else
		    if [ -h /opt/CA/BEBoraagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BEBoraagt | sed 's/.*>//g'`
		      ORA_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /CAora ]; then
		      HOME_DIR=`ls -l /CAora | sed 's/.*>//g'`
		      ORA_OLD_PKG_DIR="${HOME_DIR}"
		    elif [ -d /opt/CA/BEBoraagt ]; then
		      ORA_OLD_PKG_DIR="/opt/CA/BEBoraagt"      
		    elif [ -d /CAora ]; then
		      ORA_OLD_PKG_DIR=/CAora
		    fi
		fi
		if [ "$ORA_OLD_PKG_DIR" = "" ]
		then
				ORA_OLD_INSTALLED=0
		else
		      BUILDNUM_OLD_ORA=$(Get_BuildNum "${ORA_OLD_PKG_DIR}/data/RELVERSION")
		      ORA_OLD_PKG_DIR_SUB=`basename $ORA_OLD_PKG_DIR`
		      ORA_OLD_PKG_DIR=`dirname $ORA_OLD_PKG_DIR`
		fi
	else
		isInstalled $ORA8_OLD
		if [ $? -eq 0 ];then
			ORA8_OLD_INSTALLED=1
			if [ "$OS" = "SunOS" ]; then
				ORA_OLD_VERSION=`pkgparam $ORA8_OLD VERSION 2> /dev/null`
				ORA_OLD_PKG_DIR=`pkgparam $ORA8_OLD CAORA8_HOME 2> /dev/null`
			elif [ "$OS" = "HP-UX" ]; then
	    			ORA_OLD_VERSION=`${PKGINFO} -a revision $ORA8_OLD | grep "$ORA8_OLD" | grep -v "$ORA8_OLD.$ORA8_OLD" | ${AWK} '{ print $NF }'`
	    			ORA_OLD_PKG_DIR=`${PKGINFO} -a location $ORA8_OLD | grep "$ORA8_OLD" | grep -v "$ORA8_OLD.$ORA8_OLD" | ${AWK} '{ print $NF }'`
	    			if [ -d $ORA_OLD_PKG_DIR/BEBoraagt ]; then
	    				ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/BEBoraagt"
	    			elif [ -d $ORA_OLD_PKG_DIR/CAora ]; then
	    				ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/CAora"    				
	    			fi
			elif [ "$OS" = "AIX" ]; then
			    if [ -h /opt/CA/BEBoraagt ]; then
			      HOME_DIR=`ls -l /opt/CA/BEBoraagt | sed 's/.*>//g'`
			      ORA_OLD_PKG_DIR="$HOME_DIR"      
			    elif [ -h /usr/CAora ]; then
			      HOME_DIR=`ls -l /usr/CAora | sed 's/.*>//g'`
			      ORA_OLD_PKG_DIR="${HOME_DIR}"
			    elif [ -d /opt/CA/BEBoraagt ]; then
			      ORA_OLD_PKG_DIR="/opt/CA/BEBoraagt"      
			    elif [ -d /usr/CAora ]; then
			      ORA_OLD_PKG_DIR=/usr/CAora
			    fi
			    ver=`$PKGINFO | grep $ORA8_OLD`
			    ORA_OLD_VERSION=`echo $ver | cut -d" " -f2`
			else
			    if [ -h /opt/CA/BEBoraagt ]; then
			      HOME_DIR=`ls -l /opt/CA/BEBoraagt | sed 's/.*>//g'`
			      ORA_OLD_PKG_DIR="$HOME_DIR"      
			    elif [ -h /CAora ]; then
			      HOME_DIR=`ls -l /CAora | sed 's/.*>//g'`
			      ORA_OLD_PKG_DIR="${HOME_DIR}"
			    elif [ -d /opt/CA/BEBoraagt ]; then
			      ORA_OLD_PKG_DIR="/opt/CA/BEBoraagt"      
			    elif [ -d /CAora ]; then
			      ORA_OLD_PKG_DIR=/CAora
			    fi
			fi
			if [ "$ORA_OLD_PKG_DIR" = "" ]
			then
					ORA8_OLD_INSTALLED=0
			else
			      BUILDNUM_OLD_ORA=$(Get_BuildNum "${ORA_OLD_PKG_DIR}/data/RELVERSION")
			      ORA_OLD_PKG_DIR_SUB=`basename $ORA8_OLD_PKG_DIR`
			      ORA_OLD_PKG_DIR=`dirname $ORA8_OLD_PKG_DIR`
			fi
		else
			isInstalled $ORA8SL_OLD
			if [ $? -eq 0 ];then
				ORA8SL_OLD_INSTALLED=1
				if [ "$OS" = "SunOS" ]; then
					ORA8SL_OLD_VERSION=`pkgparam $ORA8SL_OLD VERSION 2> /dev/null`
					ORA8SL_OLD_PKG_DIR=`pkgparam $ORA8SL_OLD CAORA8_HOME 2> /dev/null`
				fi
				if [ "$ORA8SL_OLD_PKG_DIR" = "" ]; then
					ORA8SL_OLD_INSTALLED=0
				else
				    	BUILDNUM_OLD_ORA8SL=$(Get_BuildNum "${ORA8SL_OLD_PKG_DIR}/data/RELVERSION")
					ORA8SL_OLD_PKG_DIR_SUB=`basename $ORA8SL_OLD_PKG_DIR`
					ORA8SL_OLD_PKG_DIR=`dirname $ORA8SL_OLD_PKG_DIR`
				fi
			else
				isInstalled $TIMEFINDER_OLD
				if [ $? -eq 0 ];then
					TIMEFINDER_OLD_INSTALLED=1
					if [ "$OS" = "SunOS" ]; then
						ORA_OLD_VERSION=`pkgparam $ORA_OLD VERSION 2> /dev/null`
						ORA_OLD_PKG_DIR=`pkgparam $ORA_OLD CAORA_HOME 2> /dev/null`
					elif [ "$OS" = "HP-UX" ]; then
			    			ORA_OLD_VERSION=`${PKGINFO} -a revision $ORA_OLD | grep "$ORA_OLD" | grep -v "$ORA_OLD.$ORA_OLD" | ${AWK} '{ print $NF }'`
			    			ORA_OLD_PKG_DIR=`${PKGINFO} -a location $ORA_OLD | grep "$ORA_OLD" | grep -v "$ORA_OLD.$ORA_OLD" | ${AWK} '{ print $NF }'`
			    			if [ -d $ORA_OLD_PKG_DIR/BEBoraagt ]; then
			    				ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/BEBoraagt"
			    			elif [ -d $ORA_OLD_PKG_DIR/BEBora ]; then
			    				ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/BEBora"    				
			    			fi
					fi
					if [ "$ORA_OLD_PKG_DIR" = "" ]
					then
						TIMEFINDER_OLD_INSTALLED=0
					else
					      BUILDNUM_OLD_ORA=$(Get_BuildNum "${ORA_OLD_PKG_DIR}/data/RELVERSION")
					      ORA_OLD_PKG_DIR_SUB=`basename $ORA_OLD_PKG_DIR`
					      ORA_OLD_PKG_DIR=`dirname $ORA_OLD_PKG_DIR`
					fi
				else
					ORA_OLD=CAora
					isInstalled $ORA_OLD
					if [ $? -eq 0 ];then
						ORA_OLD_INSTALLED=1
						if [ "$OS" = "SunOS" ]; then
							ORA_OLD_VERSION=`pkgparam $ORA_OLD VERSION 2> /dev/null`
							ORA_OLD_PKG_DIR=`pkgparam $ORA_OLD CAORA_HOME 2> /dev/null`
						elif [ "$OS" = "HP-UX" ]; then
				    			ORA_OLD_VERSION=`${PKGINFO} -a revision $ORA_OLD | grep "$ORA_OLD" | grep -v "$ORA_OLD.$ORA_OLD" | ${AWK} '{ print $NF }'`
				    			ORA_OLD_PKG_DIR=`${PKGINFO} -a location $ORA_OLD | grep "$ORA_OLD" | grep -v "$ORA_OLD.$ORA_OLD" | ${AWK} '{ print $NF }'`
				    			if [ -d $ORA_OLD_PKG_DIR/BEBoraagt ]; then
				    				ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/BEBoraagt"
				    			elif [ -d $ORA_OLD_PKG_DIR/CAora ]; then
				    				ORA_OLD_PKG_DIR="$ORA_OLD_PKG_DIR/CAora"    				
				    			fi
						elif [ "$OS" = "AIX" ]; then
						    if [ -h /opt/CA/BEBoraagt ]; then
						      HOME_DIR=`ls -l /opt/CA/BEBoraagt | sed 's/.*>//g'`
						      ORA_OLD_PKG_DIR="$HOME_DIR"      
						    elif [ -h /usr/CAora ]; then
						      HOME_DIR=`ls -l /usr/CAora | sed 's/.*>//g'`
						      ORA_OLD_PKG_DIR="${HOME_DIR}"
						    elif [ -d /opt/CA/BEBoraagt ]; then
						      ORA_OLD_PKG_DIR="/opt/CA/BEBoraagt"      
						    elif [ -d /usr/CAora ]; then
						      ORA_OLD_PKG_DIR=/usr/CAora
						    fi
						    ver=`$PKGINFO | grep $ORA_OLD`
						    ORA_OLD_VERSION=`echo $ver | cut -d" " -f2`
						fi
						if [ "$ORA_OLD_PKG_DIR" = "" ]
						then
								ORA_OLD_INSTALLED=0
						else
						      BUILDNUM_OLD_ORA=$(Get_BuildNum "${ORA_OLD_PKG_DIR}/data/RELVERSION")
						      ORA_OLD_PKG_DIR_SUB=`basename $ORA_OLD_PKG_DIR`
						      ORA_OLD_PKG_DIR=`dirname $ORA_OLD_PKG_DIR`
						fi
					fi
				fi	
			fi	
		fi
	fi	
fi

if [ $AGENTS_DIR -ne 1 -a "$PLATFORM" != "s86-amd64" ]; then
  if [ "$OS" != "OSF1" -a "$PLATFORM" != "s86" ]; then
	isInstalled $BEBSVR_OLD
	if [ $? -eq 0 ];then
		BEBSVR_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			BEBSVR_OLD_VERSION=`pkgparam $BEBSVR_OLD VERSION 2> /dev/null`
			BEB_OLD_PKG_DIR=`pkgparam $BEBSVR_OLD BEB_HOME 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			BEBSVR_OLD_VERSION=`${PKGINFO} -a revision $BEBSVR_OLD | grep "$BEBSVR_OLD" | grep -v "$BEBSVR_OLD.$BEBSVR_OLD" | ${AWK} '{ print $NF }'`
    			BEB_OLD_PKG_DIR=`${PKGINFO} -a location $BEBSVR_OLD | grep "$BEBSVR_OLD" | grep -v "$BEBSVR_OLD.$BEBSVR_OLD" | ${AWK} '{ print $NF }'`
    			BEB_OLD_PKG_DIR="${BEB_OLD_PKG_DIR}/BrightStorEB"
		elif [ "$OS" = "AIX" ]; then
		    BEB_OLD_PKG_DIR=`lslpp -f $BEBSVR_OLD.obj|grep "BrightStorEB/sbin/cstatus"|sed -e "s/ //g" | ${AWK} -F"/BrightStorEB/sbin" '{ print $1}'`
		    if [ -h $BEB_OLD_PKG_DIR/BrightStorEB ]; then
		      HOME_DIR=`ls -l $BEB_OLD_PKG_DIR/BrightStorEB | sed 's/.*>//g'`
		      BEB_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /opt/CA/BrightStorEB ]; then
		      HOME_DIR=`ls -l /opt/CA/BrightStorEB | sed 's/.*>//g'`
		      BEB_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /usr/BrightStorEB ]; then
		      HOME_DIR=`ls -l /usr/BrightStorEB | sed 's/.*>//g'`
		      BEB_OLD_PKG_DIR="${HOME_DIR}"
		    elif [ -d $BEB_OLD_PKG_DIR ]; then
		      BEB_OLD_PKG_DIR="$BEB_OLD_PKG_DIR/BrightStorEB"      
		    elif [ -d /opt/CA/BrightStorEB ]; then
		      BEB_OLD_PKG_DIR="/opt/CA/BrightStorEB"      
		    elif [ -d /usr/BrightStorEB ]; then
		      BEB_OLD_PKG_DIR=/usr/BrightStorEB
		    fi
		    ver=`$PKGINFO | grep $BEBSVR_OLD`
		    BEBSVR_OLD_VERSION=`echo $ver | cut -d" " -f2`
		fi
		if [ "$BEB_OLD_PKG_DIR" = "" ]
		then
		    SVR_OLD_PKG=
		    BEBSVR_OLD_INSTALLED=0
		else
		    BUILDNUM_OLD_BASE=$(Get_BuildNum "${BEB_OLD_PKG_DIR}/data/RELVERSION")
		    BEB_OLD_PKG_DIR=`dirname $BEB_OLD_PKG_DIR`
		fi

	fi
	isInstalled $SVR_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			BEB_OLD_PKG_DIR=`pkgparam $SVR_PKG|grep "BrightStorARCserve"`
		elif [ "$OS" = "HP-UX" ]; then
    			BEB_OLD_PKG_DIR=`${PKGINFO} -a location $SVR_PKG | grep "$SVR_PKG" | grep -v "$SVR_PKG.$SVR_PKG" | ${AWK} '{ print $NF }'`
    			BEB_OLD_PKG_DIR="${BEB_OLD_PKG_DIR}/BrightStorARCserve"
		elif [ "$OS" = "AIX" ]; then
		    BEB_OLD_PKG_DIR=`lslpp -f $SVR_PKG.obj|grep "BrightStorARCserve/sbin/cstatus"|sed -e "s/ //g" | ${AWK} -F"/BrightStorARCserve/sbin" '{ print $1}'`
		    if [ -h $BEB_OLD_PKG_DIR/BrightStorARCserve ]; then
		      BEB_OLD_PKG_DIR=`ls -l $BEB_OLD_PKG_DIR/BrightStorARCserve | sed 's/.*>//g'`
		    elif [ -d $BEB_OLD_PKG_DIR/BrightStorARCserve ]; then
		      BEB_OLD_PKG_DIR="$BEB_OLD_PKG_DIR/BrightStorARCserve"      
		    elif [ -d /opt/CA/BrightStorARCserve ]; then
		      BEB_OLD_PKG_DIR=/opt/CA/BrightStorARCserve
		    fi
		fi
		if [ "$BEB_OLD_PKG_DIR" = "" ]
		then
		    SERVER_NEED_UPGRADE=0
		else
		    BUILDNUM_OLD_BASE=$(Get_BuildNum "${BEB_OLD_PKG_DIR}/data/RELVERSION")
		    if [ $BUILDNUM_OLD_BASE -lt $CURRENT_BUILD ]; then
			SERVER_NEED_UPGRADE=1
		    else
			SERVER_ALREADY_INSTALLED=1
		    fi
		    BEB_OLD_PKG_DIR=`dirname $BEB_OLD_PKG_DIR`
		fi
	fi

	isInstalled $BEBMGR_OLD
	if [ $? -eq 0 ];then
		BEBMGR_OLD_INSTALLED=1
	fi

	isInstalled $MGR_PKG
	if [ $? -eq 0 ];then
		MANAGER_NEED_UPGRADE=1
	fi

	if [ ${BEBSVR_OLD_INSTALLED} -eq 1 ]; then			
		isInstalled $DRO_OLD
		if [ $? -eq 0 ];then
			DRO_OLD_INSTALLED=1
		fi	
	
		isInstalled $NAS_OLD
		if [ $? -eq 0 ];then
			NAS_OLD_INSTALLED=1
		fi	
	
if [ "X${NLS_LANG}" != "Xja_euc" -a "X${NLS_LANG}" != "Xja_sjis" -a "X${NLS_LANG}" != "Xtc" -a "X${NLS_LANG}" != "Xsc" -a "X${NLS_LANG}" != "Xsp" -a "X${NLS_LANG}" != "Xit" -a "X${NLS_LANG}" != "Xde" -a "X${NLS_LANG}" != "Xfr" ]; then
		isInstalled $NLO_OLD
		if [ $? -eq 0 ];then
			NLO_OLD_INSTALLED=1
		fi	
fi
	
		isInstalled $SAN_OLD
		if [ $? -eq 0 ];then
			SAN_OLD_INSTALLED=1
		fi	
		
if [ "X${NLS_LANG}" != "Xja_euc" -a "X${NLS_LANG}" != "Xja_sjis" -a "X${NLS_LANG}" != "Xtc" -a "X${NLS_LANG}" != "Xsc" -a "X${NLS_LANG}" != "Xsp" -a "X${NLS_LANG}" != "Xit" -a "X${NLS_LANG}" != "Xde" -a "X${NLS_LANG}" != "Xfr" ]; then
		isInstalled $IBM_OLD
		if [ $? -eq 0 ];then
			IBM_OLD_INSTALLED=1
		fi
fi
	
		isInstalled $GATEWAY_OLD
		if [ $? -eq 0 ];then
			GATEWAY_OLD_INSTALLED=1
		fi	
	fi
	if [ ${SERVER_NEED_UPGRADE} -eq 1 ]; then			
		isInstalled $DRO_N_PKG
		if [ $? -eq 0 ];then
			DRO_NEED_UPGRADE=1
		fi	
	
		isInstalled $NAS_N_PKG
		if [ $? -eq 0 ];then
			NAS_NEED_UPGRADE=1
		fi	
	
if [ "X${NLS_LANG}" != "Xja_euc" -a "X${NLS_LANG}" != "Xja_sjis" -a "X${NLS_LANG}" != "Xtc" -a "X${NLS_LANG}" != "Xsc" -a "X${NLS_LANG}" != "Xsp" -a "X${NLS_LANG}" != "Xit" -a "X${NLS_LANG}" != "Xde" -a "X${NLS_LANG}" != "Xfr" ]; then
		isInstalled $NLO_N_PKG
		if [ $? -eq 0 ];then
			NLO_NEED_UPGRADE=1
		fi	
fi
	
		isInstalled $SAN_N_PKG
		if [ $? -eq 0 ];then
			SAN_NEED_UPGRADE=1
		fi	
		
if [ "X${NLS_LANG}" != "Xja_euc" -a "X${NLS_LANG}" != "Xja_sjis" -a "X${NLS_LANG}" != "Xtc" -a "X${NLS_LANG}" != "Xsc" -a "X${NLS_LANG}" != "Xsp" -a "X${NLS_LANG}" != "Xit" -a "X${NLS_LANG}" != "Xde" -a "X${NLS_LANG}" != "Xfr" ]; then
		isInstalled $IBM_N_PKG
		if [ $? -eq 0 ];then
			IBM_NEED_UPGRADE=1
		fi
fi
	
		isInstalled $GATEWAY_N_PKG
		if [ $? -eq 0 ];then
			GATEWAY_NEED_UPGRADE=1
		fi	
	fi
  fi
		
if [ "X${NLS_LANG}" != "Xja_euc" -a "X${NLS_LANG}" != "Xja_sjis" -a "X${NLS_LANG}" != "Xtc" -a "X${NLS_LANG}" != "Xsc" -a "X${NLS_LANG}" != "Xsp" -a "X${NLS_LANG}" != "Xit" -a "X${NLS_LANG}" != "Xde" -a "X${NLS_LANG}" != "Xfr" ]; then
	isInstalled $INFMX_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			INFMX_OLD_PKG_DIR=`pkgparam $INFMX_PKG|grep "BABinfmx" |grep -v "^BABinfmx"|grep -v "^/var/sadm/pkg/"`
		elif [ "$OS" = "HP-UX" ]; then
    			INFMX_OLD_PKG_DIR=`${PKGINFO} -a location $INFMX_PKG | grep "$INFMX_PKG" | grep -v "$INFMX_PKG.$INFMX_PKG" | ${AWK} '{ print $NF }'`
    			INFMX_OLD_PKG_DIR="${INFMX_OLD_PKG_DIR}/BABinfmx"
		elif [ "$OS" = "AIX" ]; then
		    INFMX_OLD_PKG_DIR=`lslpp -f $INFMX_PKG.obj|grep "BABinfmx/infmxbr"|sed -e "s/ //g" | ${AWK} -F"/BABinfmx/infmxbr" '{ print $1}'`
		    if [ -h $INFMX_OLD_PKG_DIR/BABinfmx ]; then
		      HOME_DIR=`ls -l $INFMX_OLD_PKG_DIR/BABinfmx | sed 's/.*>//g'`
		      INFMX_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d $INFMX_OLD_PKG_DIR/BABinfmx ]; then
		      INFMX_OLD_PKG_DIR="$INFMX_OLD_PKG_DIR/BABinfmx"      
		    elif [ -h /opt/CA/BABinfmx ]; then
		      HOME_DIR=`ls -l /opt/CA/BABinfmx | sed 's/.*>//g'`
		      INFMX_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d /opt/CA/BABinfmx ]; then
		      INFMX_OLD_PKG_DIR=/opt/CA/BABinfmx
		    fi
		fi
		if [ "$INFMX_OLD_PKG_DIR" = "" ]
		then
		    INFMX_NEED_UPGRADE=0
		else
		    BUILDNUM_OLD_INFMX=$(Get_BuildNum "${INFMX_OLD_PKG_DIR}/data/RELVERSION")
		    if [ $BUILDNUM_OLD_INFMX -lt $CURRENT_BUILD ]; then
			INFMX_NEED_UPGRADE=1
		    else
			INFMX_ALREADY_INSTALLED=1
		    fi
		    INFMX_OLD_PKG_DIR=`dirname $INFMX_OLD_PKG_DIR`
		fi
	fi

	isInstalled $INFMX_OLD
	if [ $? -eq 0 ];then
		INFMX_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			INFMX_OLD_VERSION=`pkgparam $INFMX_OLD VERSION 2> /dev/null`
			INFMX_OLD_PKG_DIR=`pkgparam $INFMX_OLD CAINFMX_HOME 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			INFMX_OLD_VERSION=`${PKGINFO} -a revision $INFMX_OLD | grep "$INFMX_OLD" | grep -v "$INFMX_OLD.$INFMX_OLD" | ${AWK} '{ print $NF }'`
    			INFMX_OLD_PKG_DIR=`${PKGINFO} -a location $INFMX_OLD | grep "$INFMX_OLD" | grep -v "$INFMX_OLD.$INFMX_OLD" | ${AWK} '{ print $NF }'`
    			if [ -d $INFMX_OLD_PKG_DIR/BEBinfmxagt ]; then
    				INFMX_OLD_PKG_DIR="$INFMX_OLD_PKG_DIR/BEBinfmxagt"
    			elif [ -d $INFMX_OLD_PKG_DIR/CAinfmx ]; then
    				INFMX_OLD_PKG_DIR="$INFMX_OLD_PKG_DIR/CAinfmx"    				
    			fi
		elif [ "$OS" = "AIX" ]; then
		    if [ -h /opt/CA/BEBinfmxagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BEBinfmxagt | sed 's/.*>//g'`
		      INFMX_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /usr/CAinfmx ]; then
		      HOME_DIR=`ls -l /usr/CAinfmx | sed 's/.*>//g'`
		      INFMX_OLD_PKG_DIR="${HOME_DIR}"
		    elif [ -d /opt/CA/BEBinfmxagt ]; then
		      INFMX_OLD_PKG_DIR="/opt/CA/BEBinfmxagt"      
		    elif [ -d /usr/CAinfmx ]; then
		      INFMX_OLD_PKG_DIR=/usr/CAinfmx
		    fi
		    ver=`$PKGINFO | grep $INFMX_OLD`
		    INFMX_OLD_VERSION=`echo $ver | cut -d" " -f2`
		fi
		if [ "$INFMX_OLD_PKG_DIR" = "" ]
		then
		    INFMX_OLD_INSTALLED=0
		else
		    BUILDNUM_OLD_INFMX=$(Get_BuildNum "${INFMX_OLD_PKG_DIR}/data/RELVERSION")
		    INFMX_OLD_PKG_DIR_SUB=`basename $INFMX_OLD_PKG_DIR`
		    INFMX_OLD_PKG_DIR=`dirname $INFMX_OLD_PKG_DIR`
		fi
	fi
fi

if [ "X${NLS_LANG}" != "Xja_euc" -a "X${NLS_LANG}" != "Xja_sjis" -a "X${NLS_LANG}" != "Xtc" -a "X${NLS_LANG}" != "Xsc" -a "X${NLS_LANG}" != "Xsp" -a "X${NLS_LANG}" != "Xit" -a "X${NLS_LANG}" != "Xde" -a "X${NLS_LANG}" != "Xfr" ]; then
	isInstalled $SAP_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			SAP_OLD_PKG_DIR=`pkgparam $SAP_PKG|grep "BABsapagt" |grep -v "^BABsapagt"|grep -v "^/var/sadm/pkg/"`
		elif [ "$OS" = "HP-UX" ]; then
    			SAP_OLD_PKG_DIR=`${PKGINFO} -a location $SAP_PKG | grep "$SAP_PKG" | grep -v "$SAP_PKG.$SAP_PKG" | ${AWK} '{ print $NF }'`
    			SAP_OLD_PKG_DIR="${SAP_OLD_PKG_DIR}/BABsapagt"
		elif [ "$OS" = "AIX" ]; then
		    SAP_OLD_PKG_DIR=`lslpp -f $SAP_PKG.obj|grep "BABsapagt/sapagentd"|sed -e "s/ //g" | ${AWK} -F"/BABsapagt/sapagentd" '{ print $1}'`
		    if [ -h $SAP_OLD_PKG_DIR/BABsapagt ]; then
		      HOME_DIR=`ls -l $SAP_OLD_PKG_DIR/BABsapagt | sed 's/.*>//g'`
		      SAP_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d $SAP_OLD_PKG_DIR/BABsapagt ]; then
		      SAP_OLD_PKG_DIR="$SAP_OLD_PKG_DIR/BABsapagt"      
		    elif [ -h /opt/CA/BABsapagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BABsapagt | sed 's/.*>//g'`
		      SAP_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d /opt/CA/BABsapagt ]; then
		      SAP_OLD_PKG_DIR=/opt/CA/BABsapagt
		    fi
		fi
		if [ "$SAP_OLD_PKG_DIR" = "" ]
		then
		    SAP_NEED_UPGRADE=0
		else
		    BUILDNUM_OLD_SAP=$(Get_BuildNum "${SAP_OLD_PKG_DIR}/data/RELVERSION")
		    if [ $BUILDNUM_OLD_SAP -lt $CURRENT_BUILD ]; then
			SAP_NEED_UPGRADE=1
		    else
			SAP_ALREADY_INSTALLED=1
		    fi
		    SAP_OLD_PKG_DIR=`dirname $SAP_OLD_PKG_DIR`
		fi
	fi
	isInstalled $SAP_OLD
	if [ $? -eq 0 ];then
		SAP_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			SAP_OLD_VERSION=`pkgparam $SAP_OLD VERSION 2> /dev/null`
			SAP_OLD_PKG_DIR=`pkgparam $SAP_OLD CASAP_HOME 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			SAP_OLD_VERSION=`${PKGINFO} -a revision $SAP_OLD | grep "$SAP_OLD" | grep -v "$SAP_OLD.$SAP_OLD" | ${AWK} '{ print $NF }'`
    			SAP_OLD_PKG_DIR=`${PKGINFO} -a location $SAP_OLD | grep "$SAP_OLD" | grep -v "$SAP_OLD.$SAP_OLD" | ${AWK} '{ print $NF }'`
    			if [ -d $SAP_OLD_PKG_DIR/BEBsapagt ]; then
    				SAP_OLD_PKG_DIR="$SAP_OLD_PKG_DIR/BEBsapagt"
    			elif [ -d $SAP_OLD_PKG_DIR/CAsap ]; then
    				SAP_OLD_PKG_DIR="$SAP_OLD_PKG_DIR/CAsap"    				
    			fi
		elif [ "$OS" = "AIX" ]; then
		    if [ -h /opt/CA/BEBsapagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BEBsapagt | sed 's/.*>//g'`
		      SAP_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /usr/CAsap ]; then
		      HOME_DIR=`ls -l /usr/CAsap | sed 's/.*>//g'`
		      SAP_OLD_PKG_DIR="${HOME_DIR}"
		    elif [ -d /opt/CA/BEBsapagt ]; then
		      SAP_OLD_PKG_DIR="/opt/CA/BEBsapagt"      
		    elif [ -d /usr/CAsap ]; then
		      SAP_OLD_PKG_DIR=/usr/CAsap
		    fi
		    ver=`$PKGINFO | grep $INFMX_OLD`
		    SAP_OLD_VERSION=`echo $ver | cut -d" " -f2`
		fi
		if [ "$SAP_OLD_PKG_DIR" = "" ]
		then
		    SAP_OLD_INSTALLED=0
		else
		    BUILDNUM_OLD_SAP=$(Get_BuildNum "${SAP_OLD_PKG_DIR}/data/RELVERSION")
		    SAP_OLD_PKG_DIR_SUB=`basename $SAP_OLD_PKG_DIR`
		    SAP_OLD_PKG_DIR=`dirname $SAP_OLD_PKG_DIR`
		fi
	else
		SAP_OLD=CAsap
		isInstalled $SAP_OLD
		if [ $? -eq 0 ];then
			SAP_OLD_INSTALLED=1
			if [ "$OS" = "SunOS" ]; then
				SAP_OLD_VERSION=`pkgparam $SAP_OLD VERSION 2> /dev/null`
				SAP_OLD_PKG_DIR=`pkgparam $SAP_OLD CASAP_HOME 2> /dev/null`
			elif [ "$OS" = "HP-UX" ]; then
	    			SAP_OLD_VERSION=`${PKGINFO} -a revision $SAP_OLD | grep "$SAP_OLD" | grep -v "$SAP_OLD.$SAP_OLD" | ${AWK} '{ print $NF }'`
	    			SAP_OLD_PKG_DIR=`${PKGINFO} -a location $SAP_OLD | grep "$SAP_OLD" | grep -v "$SAP_OLD.$SAP_OLD" | ${AWK} '{ print $NF }'`
	    			if [ -d $SAP_OLD_PKG_DIR/BEBsapagt ]; then
	    				SAP_OLD_PKG_DIR="$SAP_OLD_PKG_DIR/BEBsapagt"
	    			elif [ -d $SAP_OLD_PKG_DIR/CAsap ]; then
	    				SAP_OLD_PKG_DIR="$SAP_OLD_PKG_DIR/CAsap"    				
	    			fi
			elif [ "$OS" = "AIX" ]; then
			    if [ -h /opt/CA/BEBsapagt ]; then
			      HOME_DIR=`ls -l /opt/CA/BEBsapagt | sed 's/.*>//g'`
			      SAP_OLD_PKG_DIR="$HOME_DIR"      
			    elif [ -h /usr/CAsap ]; then
			      HOME_DIR=`ls -l /usr/CAsap | sed 's/.*>//g'`
			      SAP_OLD_PKG_DIR="${HOME_DIR}"
			    elif [ -d /opt/CA/BEBsapagt ]; then
			      SAP_OLD_PKG_DIR="/opt/CA/BEBsapagt"      
			    elif [ -d /usr/CAsap ]; then
			      SAP_OLD_PKG_DIR=/usr/CAsap
			    fi
			    ver=`$PKGINFO | grep $INFMX_OLD`
			    SAP_OLD_VERSION=`echo $ver | cut -d" " -f2`
			fi
			if [ "$SAP_OLD_PKG_DIR" = "" ]
			then
			    SAP_OLD_INSTALLED=0
			else
			    BUILDNUM_OLD_SAP=$(Get_BuildNum "${SAP_OLD_PKG_DIR}/data/RELVERSION")
			    SAP_OLD_PKG_DIR_SUB=`basename $SAP_OLD_PKG_DIR`
			    SAP_OLD_PKG_DIR=`dirname $SAP_OLD_PKG_DIR`
			fi
		fi
	fi
fi

if [ "X${NLS_LANG}" != "Xja_euc" -a "X${NLS_LANG}" != "Xja_sjis" -a "X${NLS_LANG}" != "Xtc" -a "X${NLS_LANG}" != "Xsp" -a "X${NLS_LANG}" != "Xit" -a "X${NLS_LANG}" != "Xde" -a "X${NLS_LANG}" != "Xfr" ]; then
	isInstalled $SYBASE_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			SYBASE_OLD_PKG_DIR=`pkgparam $SYBASE_PKG|grep "BABsybagt" |grep -v "^BABsybagt"|grep -v "^/var/sadm/pkg/"`
		elif [ "$OS" = "HP-UX" ]; then
    			SYBASE_OLD_PKG_DIR=`${PKGINFO} -a location $SYBASE_PKG | grep "$SYBASE_PKG" | grep -v "$SYBASE_PKG.$SYBASE_PKG" | ${AWK} '{ print $NF }'`
    			SYBASE_OLD_PKG_DIR="${SYBASE_OLD_PKG_DIR}/BABsybagt"
		elif [ "$OS" = "AIX" ]; then
		    SYBASE_OLD_PKG_DIR=`lslpp -f $SYBASE_PKG.obj|grep "BABsybagt/sybagentd"|sed -e "s/ //g" | ${AWK} -F"/BABsybagt/sybagentd" '{ print $1}'`
		    if [ -h $SYBASE_OLD_PKG_DIR/BABsybagt ]; then
		      HOME_DIR=`ls -l $SYBASE_OLD_PKG_DIR/BABsybagt | sed 's/.*>//g'`
		      SYBASE_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /opt/CA/BABsybagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BABsybagt | sed 's/.*>//g'`
		      SYBASE_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d $SYBASE_OLD_PKG_DIR/BABsybagt ]; then
		      SYBASE_OLD_PKG_DIR="$SYBASE_OLD_PKG_DIR/BABsybagt"      
		    elif [ -d /opt/CA/BABsybagt ]; then
		      SYBASE_OLD_PKG_DIR=/opt/CA/BABsybagt
		    fi
		fi
		if [ "$SYBASE_OLD_PKG_DIR" = "" ]
		then
		    SYB_NEED_UPGRADE=0
		else
		    BUILDNUM_OLD_SYBASE=$(Get_BuildNum "${SYBASE_OLD_PKG_DIR}/data/RELVERSION")
		    if [ $BUILDNUM_OLD_SYBASE -lt $CURRENT_BUILD ]; then
			SYB_NEED_UPGRADE=1
		    else
			SYB_ALREADY_INSTALLED=1
		    fi
		    SYBASE_OLD_PKG_DIR=`dirname $SYBASE_OLD_PKG_DIR`
		fi
	fi
	isInstalled $SYBASE_OLD
	if [ $? -eq 0 ];then
		SYBASE_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			SYBASE_OLD_VERSION=`pkgparam $SYBASE_OLD VERSION 2> /dev/null`
			SYBASE_OLD_PKG_DIR=`pkgparam $SYBASE_OLD CASYBASE_HOME 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			SYBASE_OLD_VERSION=`${PKGINFO} -a revision $SYBASE_OLD | grep "$SYBASE_OLD" | grep -v "$SYBASE_OLD.$SYBASE_OLD" | ${AWK} '{ print $NF }'`
    			SYBASE_OLD_PKG_DIR=`${PKGINFO} -a location $SYBASE_OLD | grep "$SYBASE_OLD" | grep -v "$SYBASE_OLD.$SYBASE_OLD" | ${AWK} '{ print $NF }'`
			if [ -h $SYBASE_OLD_PKG_DIR/BEBsybagt ]; then
			      HOME_DIR=`ls -l $SYBASE_OLD_PKG_DIR/BEBsybagt | sed 's/.*>//g'`
			      SYBASE_OLD_PKG_DIR="$HOME_DIR"      
			elif [ -h /opt/CA/BEBsybagt ]; then
			      HOME_DIR=`ls -l /opt/CA/BEBsybagt | sed 's/.*>//g'`
			      SYBASE_OLD_PKG_DIR="$HOME_DIR"      
    			elif [ -d $SYBASE_OLD_PKG_DIR/BEBsybagt ]; then
    				SYBASE_OLD_PKG_DIR="$SYBASE_OLD_PKG_DIR/BEBsybagt"
    			elif [ -d $SYBASE_OLD_PKG_DIR/CAsybase ]; then
    				SYBASE_OLD_PKG_DIR="$SYBASE_OLD_PKG_DIR/CAsybase"    				
    			fi
		fi
		if [ "$SYBASE_OLD_PKG_DIR" = "" ]
		then
		    SYBASE_OLD_INSTALLED=0
		else
		    BUILDNUM_OLD_SYBASE=$(Get_BuildNum "${SYBASE_OLD_PKG_DIR}/data/RELVERSION")
		    SYBASE_OLD_PKG_DIR_SUB=`basename $SYBASE_OLD_PKG_DIR`
		    SYBASE_OLD_PKG_DIR=`dirname $SYBASE_OLD_PKG_DIR`
		fi
	fi
fi
			
if [ "X${NLS_LANG}" != "Xja_euc" -a "X${NLS_LANG}" != "Xja_sjis" -a "X${NLS_LANG}" != "Xtc" -a "X${NLS_LANG}" != "Xsc" ]; then
	isInstalled $ING_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			ING_OLD_PKG_DIR=`pkgparam $ING_PKG|grep "BABingagt" |grep -v "^BABingagt"|grep -v "^/var/sadm/pkg/"`
		elif [ "$OS" = "HP-UX" ]; then
    			ING_OLD_PKG_DIR=`${PKGINFO} -a location $ING_PKG | grep "$ING_PKG" | grep -v "$ING_PKG.$ING_PKG" | ${AWK} '{ print $NF }'`
    			ING_OLD_PKG_DIR="${ING_OLD_PKG_DIR}/BABingagt"
		elif [ "$OS" = "AIX" ]; then
		    ING_OLD_PKG_DIR=`lslpp -f $ING_PKG.obj|grep "BABingagt/ingresd"|sed -e "s/ //g" | ${AWK} -F"/BABingagt/ingresd" '{ print $1}'`
		    if [ -h $ING_OLD_PKG_DIR/BABingagt ]; then
		      HOME_DIR=`ls -l $ING_OLD_PKG_DIR/BABingagt | sed 's/.*>//g'`
		      ING_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d $ING_OLD_PKG_DIR/BABingagt ]; then
		      ING_OLD_PKG_DIR="$ING_OLD_PKG_DIR/BABingagt"      
		    elif [ -h /opt/CA/BABingagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BABingagt | sed 's/.*>//g'`
		      ING_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d /opt/CA/BABingagt ]; then
		      ING_OLD_PKG_DIR=/opt/CA/BABingagt
		    fi
		fi
		if [ "$ING_OLD_PKG_DIR" = "" ]
		then
		    ING_NEED_UPGRADE=0
		else
		    BUILDNUM_OLD_ING=$(Get_BuildNum "${ING_OLD_PKG_DIR}/data/RELVERSION")
		    if [ $BUILDNUM_OLD_ING -lt $CURRENT_BUILD ]; then
			ING_NEED_UPGRADE=1
		    else
			ING_ALREADY_INSTALLED=1
		    fi
		    ING_OLD_PKG_DIR=`dirname $ING_OLD_PKG_DIR`
		fi
	fi
	isInstalled $ING_OLD
	if [ $? -eq 0 ];then
		ING_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			ING_OLD_VERSION=`pkgparam $ING_OLD VERSION 2> /dev/null`
			ING_OLD_PKG_DIR=`pkgparam $ING_OLD CAING_HOME 2> /dev/null`
		fi
		if [ "$ING_OLD_PKG_DIR" = "" ]
		then
		    ING_OLD_INSTALLED=0
		else
		    BUILDNUM_OLD_ING=$(Get_BuildNum "${ING_OLD_PKG_DIR}/data/RELVERSION")
		    ING_OLD_PKG_DIR_SUB=`basename $ING_OLD_PKG_DIR`
		    ING_OLD_PKG_DIR=`dirname $ING_OLD_PKG_DIR`
		fi
	fi	
fi

	isInstalled $DB2_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			DB2_OLD_PKG_DIR=`pkgparam $DB2_PKG|grep "BABdb2agt" |grep -v "^BABdb2agt^"|grep -v "^/var/sadm/pkg/"`
		elif [ "$OS" = "HP-UX" ]; then
    			DB2_OLD_PKG_DIR=`${PKGINFO} -a location $DB2_PKG | grep "$DB2_PKG" | grep -v "$DB2_PKG.$DB2_PKG" | ${AWK} '{ print $NF }'`
    			DB2_OLD_PKG_DIR="${DB2_OLD_PKG_DIR}/BABdb2agt"
		elif [ "$OS" = "AIX" ]; then
		    DB2_OLD_PKG_DIR=`lslpp -f $DB2_PKG.obj|grep "BABdb2agt/ca_backup"|sed -e "s/ //g" | ${AWK} -F"/BABdb2agt/ca_backup" '{ print $1}'`
		    if [ -h $DB2_OLD_PKG_DIR/BABdb2agt ]; then
		      HOME_DIR=`ls -l $DB2_OLD_PKG_DIR/BABdb2agt | sed 's/.*>//g'`
		      DB2_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d $DB2_OLD_PKG_DIR/BABdb2agt ]; then
		      DB2_OLD_PKG_DIR="$DB2_OLD_PKG_DIR/BABdb2agt"      
		    elif [ -h /opt/CA/BABdb2agt ]; then
		      HOME_DIR=`ls -l /opt/CA/BABdb2agt | sed 's/.*>//g'`
		      DB2_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d /opt/CA/BABdb2agt ]; then
		      DB2_OLD_PKG_DIR=/opt/CA/BABdb2agt
		    fi
		fi
		if [ "$DB2_OLD_PKG_DIR" = "" ]
		then
		    DB2_NEED_UPGRADE=0
		else
		    BUILDNUM_OLD_DB2=$(Get_BuildNum "${DB2_OLD_PKG_DIR}/data/RELVERSION")
		    if [ $BUILDNUM_OLD_DB2 -lt $CURRENT_BUILD ]; then
			DB2_NEED_UPGRADE=1
		    else
			DB2_ALREADY_INSTALLED=1
		    fi
		    DB2_OLD_PKG_DIR=`dirname $DB2_OLD_PKG_DIR`
		fi
	fi
	isInstalled $DB2_OLD
	if [ $? -eq 0 ];then
		DB2_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			DB2_OLD_VERSION=`pkgparam $DB2_OLD VERSION 2> /dev/null`
			DB2_OLD_PKG_DIR=`pkgparam $DB2_OLD CADB2_HOME 2> /dev/null`
		elif [ "$OS" = "AIX" ]; then
		    if [ -h /opt/CA/BEBdb2agt ]; then
		      HOME_DIR=`ls -l /opt/CA/BEBdb2agt | sed 's/.*>//g'`
		      DB2_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /usr/CAdb2 ]; then
		      HOME_DIR=`ls -l /usr/CAdb2 | sed 's/.*>//g'`
		      DB2_OLD_PKG_DIR="${HOME_DIR}"
		    elif [ -d /opt/CA/BEBdb2agt ]; then
		      DB2_OLD_PKG_DIR="/opt/CA/BEBdb2agt"      
		    elif [ -d /usr/CAdb2 ]; then
		      DB2_OLD_PKG_DIR=/usr/CAdb2
		    fi
		    ver=`$PKGINFO | grep $DB2_OLD`
		    DB2_OLD_VERSION=`echo $ver | cut -d" " -f2`
		fi
		if [ "$DB2_OLD_PKG_DIR" = "" ]
		then
		    DB2_OLD_INSTALLED=0
		else
		    BUILDNUM_OLD_DB2=$(Get_BuildNum "${DB2_OLD_PKG_DIR}/data/RELVERSION")
		    DB2_OLD_PKG_DIR_SUB=`basename $DB2_OLD_PKG_DIR`
		    DB2_OLD_PKG_DIR=`dirname $DB2_OLD_PKG_DIR`
		fi
	fi	

	isInstalled $NOTES_PKG
	if [ $? -eq 0 ];then
		if [ "$OS" = "SunOS" ]; then
			NOTES_OLD_PKG_DIR=`pkgparam $NOTES_PKG|grep "BABlotusagt" |grep -v "^BABlotusagt"|grep -v "^/var/sadm/pkg/"`
		elif [ "$OS" = "HP-UX" ]; then
    			NOTES_OLD_PKG_DIR=`${PKGINFO} -a location $NOTES_PKG | grep "$NOTES_PKG" | grep -v "$NOTES_PKG.$NOTES_PKG" | ${AWK} '{ print $NF }'`
    			NOTES_OLD_PKG_DIR="${NOTES_OLD_PKG_DIR}/BABlotusagt"
		elif [ "$OS" = "AIX" ]; then
		    NOTES_OLD_PKG_DIR=`lslpp -f $NOTES_PKG.obj|grep "BABlotusagt/lotusagentd"|sed -e "s/ //g" | ${AWK} -F"/BABlotusagt/lotusagentd" '{ print $1}'`
		    if [ -h $NOTES_OLD_PKG_DIR/BABlotusagt ]; then
		      HOME_DIR=`ls -l $NOTES_OLD_PKG_DIR/BABlotusagt | sed 's/.*>//g'`
		      NOTES_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d $NOTES_OLD_PKG_DIR/BABlotusagt ]; then
		      NOTES_OLD_PKG_DIR="$NOTES_OLD_PKG_DIR/BABlotusagt"      
		    elif [ -h /opt/CA/BABlotusagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BABlotusagt | sed 's/.*>//g'`
		      NOTES_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -d /opt/CA/BABlotusagt ]; then
		      NOTES_OLD_PKG_DIR=/opt/CA/BABlotusagt
		    fi
		fi
		if [ "$NOTES_OLD_PKG_DIR" = "" ]
		then
		    NOTES_NEED_UPGRADE=0
		else
		    BUILDNUM_OLD_NOTES=$(Get_BuildNum "${NOTES_OLD_PKG_DIR}/data/RELVERSION")
		    if [ $BUILDNUM_OLD_NOTES -lt $CURRENT_BUILD ]; then
			NOTES_NEED_UPGRADE=1
		    else
			NOTES_ALREADY_INSTALLED=1
		    fi
		    NOTES_OLD_PKG_DIR=`dirname $NOTES_OLD_PKG_DIR`
		fi
	fi
	isInstalled $NOTES_OLD
	if [ $? -eq 0 ];then
		NOTES_OLD_INSTALLED=1
		if [ "$OS" = "SunOS" ]; then
			NOTES_OLD_VERSION=`pkgparam $NOTES_OLD VERSION 2> /dev/null`
			NOTES_OLD_PKG_DIR=`pkgparam $NOTES_OLD CALOTUS_HOME 2> /dev/null`
		elif [ "$OS" = "HP-UX" ]; then
    			NOTES_OLD_VERSION=`${PKGINFO} -a revision $NOTES_OLD | grep "$NOTES_OLD" | grep -v "$NOTES_OLD.$NOTES_OLD" | ${AWK} '{ print $NF }'`
    			NOTES_OLD_PKG_DIR=`${PKGINFO} -a location $NOTES_OLD | grep "$NOTES_OLD" | grep -v "$NOTES_OLD.$NOTES_OLD" | ${AWK} '{ print $NF }'`
    			if [ -d $NOTES_OLD_PKG_DIR/BEBlotusagt ]; then
    				NOTES_OLD_PKG_DIR="$NOTES_OLD_PKG_DIR/BEBlotusagt"
    			elif [ -d $NOTES_OLD_PKG_DIR/CAlotus ]; then
    				NOTES_OLD_PKG_DIR="$NOTES_OLD_PKG_DIR/CAlotus"    				
    			fi
		elif [ "$OS" = "AIX" ]; then
		    if [ -h /opt/CA/BEBlotusagt ]; then
		      HOME_DIR=`ls -l /opt/CA/BEBlotusagt | sed 's/.*>//g'`
		      NOTES_OLD_PKG_DIR="$HOME_DIR"      
		    elif [ -h /usr/CAlotus ]; then
		      HOME_DIR=`ls -l /usr/CAlotus | sed 's/.*>//g'`
		      NOTES_OLD_PKG_DIR="${HOME_DIR}"
		    elif [ -d /opt/CA/BEBlotusagt ]; then
		      NOTES_OLD_PKG_DIR="/opt/CA/BEBlotusagt"      
		    elif [ -d /usr/CAlotus ]; then
		      NOTES_OLD_PKG_DIR=/usr/CAlotus
		    fi
		    ver=`$PKGINFO | grep $INFMX_OLD`
		    NOTES_OLD_VERSION=`echo $ver | cut -d" " -f2`
		fi
		if [ "$NOTES_OLD_PKG_DIR" = "" ]
		then
		    NOTES_OLD_INSTALLED=0
		else
		    BUILDNUM_OLD_NOTES=$(Get_BuildNum "${NOTES_OLD_PKG_DIR}/data/RELVERSION")
		    NOTES_OLD_PKG_DIR_SUB=`basename $NOTES_OLD_PKG_DIR`
		    NOTES_OLD_PKG_DIR=`dirname $NOTES_OLD_PKG_DIR`
		fi
	fi	
fi
	stopDial
	haveoldpkg
	return 0
}
#
# check wheher no pervious ARCserve edition package
#
haveoldpkg()
{
	echo 
	if [ $CMG_OLD_INSTALLED -eq 1 -o $AGT_OLD_INSTALLED -eq 1 ]; then
		echo
		echo "$INST_MSG_213"
		index=0
		if [ $CMG_OLD_INSTALLED -eq 1 ];then
			CAAGENT_NEED_UPGRADE=1
			index=$(($index + 1 ))
			if [ "$OS" = "OSF1" ]; then
			  printf "%-3s %-40s (BABCMAGT)\n" "${index}." "BrightStor ARCserve Backup Common Agent"
			else
			  printf "%-3s %-40s (BABcmagt)\n" "${index}." "BrightStor ARCserve Backup Common Agent"
			fi
		fi
		if [ $AGT_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			if [ "$OS" = "OSF1" ]; then
			  printf "%-3s %-40s (BABAGNTUX)\n" "${index}." "BrightStor ARCserve Backup Client Agent"
			else
			  printf "%-3s %-40s (BABagntux)\n" "${index}." "BrightStor ARCserve Backup Client Agent"
			fi
		fi
		echo "${INST_MSG_191a}"
		if [ $EXEC_MODE -ne $SLNT_MODE ]; then
			GET_INSTALL_FLAG2
		else
			INSTALL_FLAG=1
		fi
		if [ $INSTALL_FLAG -eq 1 ];then
			echo
	                echo "$INST_MSG_192a"
	                startDial &
                   	DIALPID=$!
			remove_old_babagent >> ${LOG_FILE} 2>&1
			stopDial
			echo
		fi
			
	elif [ $BEBSVR_OLD_INSTALLED -eq 1 -o $BEBMGR_OLD_INSTALLED -eq 1 -o $UAGENT_OLD_INSTALLED -eq 1 \
		-o $ASAGENT_OLD_INSTALLED -eq 1 -o $ORA_OLD_INSTALLED -eq 1 -o $DRO_OLD_INSTALLED -eq 1 \
		-o $NAS_OLD_INSTALLED -eq 1 -o $NLO_OLD_INSTALLED -eq 1 -o $SAN_OLD_INSTALLED -eq 1 \
		-o $ORA8_OLD_INSTALLED -eq 1 -o $IBM_OLD_INSTALLED -eq 1 -o $TIMEFINDER_OLD_INSTALLED -eq 1 \
		-o $ORA8SL_OLD_INSTALLED -eq 1 -o $NOTES_OLD_INSTALLED -eq 1 -o $DB2_OLD_INSTALLED -eq 1 \
		-o $ING_OLD_INSTALLED -eq 1 -o $SYBASE_OLD_INSTALLED -eq 1 -o $SAP_OLD_INSTALLED -eq 1 \
		-o $INFMX_OLD_INSTALLED -eq 1 ]
	then
		echo
		echo "$INST_MSG_181"
		index=0
	
		if [ $BEBSVR_OLD_INSTALLED -eq 1 -o $BEBMGR_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Server & Manager                   ($BEBMGR_OLD & $BEBSVR_OLD) \n" "${index}."
			if [ "$BEBSVR_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_BASE" != "1230" -a "$BUILDNUM_OLD_BASE" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$BEBSVR_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_BASE" != "1230" -a "$BUILDNUM_OLD_BASE" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$BEBSVR_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_BASE" != "1230" -a "$BUILDNUM_OLD_BASE" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$BEBSVR_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_BASE" != "1500" -a "$BUILDNUM_OLD_BASE" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$BEBSVR_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_BASE" != "1500" -a "$BUILDNUM_OLD_BASE" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$BEBSVR_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_BASE" != "1500" -a "$BUILDNUM_OLD_BASE" != "1450" ]; then
				MIG_STOP="yes"
			fi
		fi
		
		if [ $GATEWAY_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s iGateway                           ($GATEWAY_OLD)\n" "${index}."
		fi		
	
		if [ $ASAGENT_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Common Agent Module                ($ASAGENT_OLD)\n" "${index}."
		fi
	
		if [ $UAGENT_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for UNIX              ($UAGENT_OLD)\n" "${index}."
			if [ "$UAGENT_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_UAGENT" != "1230" -a "$BUILDNUM_OLD_UAGENT" != "1226" -a "$BUILDNUM_OLD_UAGENT" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$UAGENT_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_UAGENT" != "1230" -a "$BUILDNUM_OLD_UAGENT" != "1226" -a "$BUILDNUM_OLD_UAGENT" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$UAGENT_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_UAGENT" != "1230" -a "$BUILDNUM_OLD_UAGENT" != "1226" -a "$BUILDNUM_OLD_UAGENT" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$UAGENT_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_UAGENT" != "1500" -a "$BUILDNUM_OLD_UAGENT" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$UAGENT_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_UAGENT" != "1500" -a "$BUILDNUM_OLD_UAGENT" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$UAGENT_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_UAGENT" != "1500" -a "$BUILDNUM_OLD_UAGENT" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$UAGENT_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_UAGENT" != "1500" -a "$BUILDNUM_OLD_UAGENT" != "1450" ]; then
				MIG_STOP="yes"
			fi
		fi
	
		if [ $DRO_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Disaster Recovery Option           ($DRO_OLD)\n" "${index}."
		fi
		
		if [ $NAS_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Network Attached Storage Option    ($NAS_OLD)\n" "${index}."
		fi
	
		if [ $NLO_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s StorageTek ACSLS Option            ($NLO_OLD)\n" "${index}."
		fi
	
		if [ $SAN_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Storage Area Network Option        ($SAN_OLD)\n" "${index}."
		fi
	
		if [ $IBM_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s IBM3494 Library Option             ($IBM_OLD)\n" "${index}."
		fi
	
		if [ $ORA_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for Oracle            ($ORA_OLD)\n" "${index}."
			if [ "$ORA_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_ORA" != "1230" -a "$BUILDNUM_OLD_ORA" != "1226" -a "$BUILDNUM_OLD_ORA" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_ORA" != "1230" -a "$BUILDNUM_OLD_ORA" != "1226" -a "$BUILDNUM_OLD_ORA" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_ORA" != "1230" -a "$BUILDNUM_OLD_ORA" != "1226" -a "$BUILDNUM_OLD_ORA" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_ORA" != "1500" -a "$BUILDNUM_OLD_ORA" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_ORA" != "1500" -a "$BUILDNUM_OLD_ORA" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_ORA" != "1500" -a "$BUILDNUM_OLD_ORA" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_ORA" != "1500" -a "$BUILDNUM_OLD_ORA" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_ORA" != "1500" -a "$BUILDNUM_OLD_ORA" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.0.6" -a "$BUILDNUM_OLD_ORA" != "1500" -a "$BUILDNUM_OLD_ORA" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA_OLD_VERSION" = "10.0.6.0" -a "$BUILDNUM_OLD_ORA" != "1500" -a "$BUILDNUM_OLD_ORA" != "1450" ]; then
				MIG_STOP="yes"
			fi
		fi
	
		if [ $ORA8_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for Oracle            ($ORA8_OLD)\n" "${index}."
			if [ "$ORA8_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_ORA8" != "1230" -a "$BUILDNUM_OLD_ORA8" != "1226" -a "$BUILDNUM_OLD_ORA8" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_ORA8" != "1230" -a "$BUILDNUM_OLD_ORA8" != "1226" -a "$BUILDNUM_OLD_ORA8" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_ORA8" != "1230" -a "$BUILDNUM_OLD_ORA8" != "1226" -a "$BUILDNUM_OLD_ORA8" != "1800" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_ORA8" != "1500" -a "$BUILDNUM_OLD_ORA8" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_ORA8" != "1500" -a "$BUILDNUM_OLD_ORA8" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_ORA8" != "1500" -a "$BUILDNUM_OLD_ORA8" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_ORA8" != "1500" -a "$BUILDNUM_OLD_ORA8" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8_OLD_VERSION" = "10.0.6" -a "$BUILDNUM_OLD_ORA8" != "1500" -a "$BUILDNUM_OLD_ORA8" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8_OLD_VERSION" = "10.0.6.0" -a "$BUILDNUM_OLD_ORA8" != "1500" -a "$BUILDNUM_OLD_ORA8" != "1450" ]; then
				MIG_STOP="yes"
			fi
		fi
	
		if [ $INFMX_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for Informix          ($INFMX_OLD)\n" "${index}."
			if [ "$INFMX_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_INFMX" != "1230" -a "$BUILDNUM_OLD_INFMX" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$INFMX_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_INFMX" != "1230" -a "$BUILDNUM_OLD_INFMX" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$INFMX_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_INFMX" != "1230" -a "$BUILDNUM_OLD_INFMX" != "1226" ]; then
				MIG_STOP="yes"
#			elif [ "$INFMX_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_INFMX" != "1500" -a "$BUILDNUM_OLD_INFMX" != "1450" -a "$BUILDNUM_OLD_INFMX" != "1015" ]; then
#				MIG_STOP="yes"
#			elif [ "$INFMX_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_INFMX" != "1500" -a "$BUILDNUM_OLD_INFMX" != "1450" ]; then
#				MIG_STOP="yes"
#			elif [ "$INFMX_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_INFMX" != "1500" -a "$BUILDNUM_OLD_INFMX" != "1450" ]; then
#				MIG_STOP="yes"
#			elif [ "$INFMX_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_INFMX" != "1500" -a "$BUILDNUM_OLD_INFMX" != "1450" ]; then
#				MIG_STOP="yes"
			fi
		fi
	
		if [ $SYBASE_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for Sybase            ($SYBASE_OLD)\n" "${index}."
			if [ "$SYBASE_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_SYBASE" != "1230" -a "$BUILDNUM_OLD_SYBASE" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$SYBASE_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_SYBASE" != "1230" -a "$BUILDNUM_OLD_SYBASE" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$SYBASE_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_SYBASE" != "1230" -a "$BUILDNUM_OLD_SYBASE" != "1226" ]; then
				MIG_STOP="yes"
#			elif [ "$SYBASE_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_SYBASE" != "1500" -a "$BUILDNUM_OLD_SYBASE" != "1450" ]; then
#				MIG_STOP="yes"
#			elif [ "$SYBASE_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_SYBASE" != "1500" -a "$BUILDNUM_OLD_SYBASE" != "1450" ]; then
#				MIG_STOP="yes"
#			elif [ "$SYBASE_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_SYBASE" != "1500" -a "$BUILDNUM_OLD_SYBASE" != "1450" ]; then
#				MIG_STOP="yes"
#			elif [ "$SYBASE_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_SYBASE" != "1500" -a "$BUILDNUM_OLD_SYBASE" != "1450" ]; then
#				MIG_STOP="yes"
			fi
		fi
	
		if [ $SAP_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for SAP R/3           ($SAP_OLD)\n" "${index}."
			if [ "$SAP_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_SAP" != "1230" -a "$BUILDNUM_OLD_SAP" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$SAP_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_SAP" != "1230" -a "$BUILDNUM_OLD_SAP" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$SAP_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_SAP" != "1230" -a "$BUILDNUM_OLD_SAP" != "1226" ]; then
				MIG_STOP="yes"
#			elif [ "$SAP_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_SAP" != "1500" -a "$BUILDNUM_OLD_SAP" != "1450" ]; then
#				MIG_STOP="yes"
#			elif [ "$SAP_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_SAP" != "1500" -a "$BUILDNUM_OLD_SAP" != "1450" ]; then
#				MIG_STOP="yes"
#			elif [ "$SAP_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_SAP" != "1500" -a "$BUILDNUM_OLD_SAP" != "1450" ]; then
#				MIG_STOP="yes"
#			elif [ "$SAP_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_SAP" != "1500" -a "$BUILDNUM_OLD_SAP" != "1450" ]; then
#				MIG_STOP="yes"
			fi
		fi
	
		if [ $ING_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for IngresII          ($ING_OLD)\n" "${index}."
			if [ "$ING_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_ING" != "1230" -a "$BUILDNUM_OLD_ING" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$ING_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_ING" != "1230" -a "$BUILDNUM_OLD_ING" != "1226" ]; then
				MIG_STOP="yes"
			fi
		fi
	
		if [ $DB2_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for DB2               ($DB2_OLD)\n" "${index}."
			if [ "$DB2_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_DB2" != "1230" -a "$BUILDNUM_OLD_DB2" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$DB2_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_DB2" != "1230" -a "$BUILDNUM_OLD_DB2" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$DB2_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_DB2" != "1230" -a "$BUILDNUM_OLD_DB2" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$DB2_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_DB2" != "1500" -a "$BUILDNUM_OLD_DB2" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$DB2_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_DB2" != "1500" -a "$BUILDNUM_OLD_DB2" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$DB2_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_DB2" != "1500" -a "$BUILDNUM_OLD_DB2" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$DB2_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_DB2" != "1500" -a "$BUILDNUM_OLD_DB2" != "1450" ]; then
				MIG_STOP="yes"
			fi
		fi
	
		if [ $NOTES_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for Lotus Domino R/5  ($NOTES_OLD)\n" "${index}."
			if [ "$NOTES_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_NOTES" != "1230" -a "$BUILDNUM_OLD_NOTES" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$NOTES_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_NOTES" != "1230" -a "$BUILDNUM_OLD_NOTES" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$NOTES_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_NOTES" != "1230" -a "$BUILDNUM_OLD_NOTES" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$NOTES_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_NOTES" != "1500" -a "$BUILDNUM_OLD_NOTES" != "1450" -a "$BUILDNUM_OLD_NOTES" != "1230" ]; then
				MIG_STOP="yes"
			elif [ "$NOTES_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_NOTES" != "1500" -a "$BUILDNUM_OLD_NOTES" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$NOTES_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_NOTES" != "1500" -a "$BUILDNUM_OLD_NOTES" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$NOTES_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_NOTES" != "1500" -a "$BUILDNUM_OLD_NOTES" != "1450" ]; then
				MIG_STOP="yes"
			fi
		fi
	
		if [ $ORA8SL_OLD_INSTALLED -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s Backup Agent for Oracle Serverless ($ORA8SL_OLD)\n" "${index}."
			if [ "$ORA8SL_OLD_VERSION" = "10.5" -a "$BUILDNUM_OLD_ORA8SL" != "1230" -a "$BUILDNUM_OLD_ORA8SL" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8SL_OLD_VERSION" = "10.5.0" -a "$BUILDNUM_OLD_ORA8SL" != "1230" -a "$BUILDNUM_OLD_ORA8SL" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8SL_OLD_VERSION" = "10.5.0.0" -a "$BUILDNUM_OLD_ORA8SL" != "1230" -a "$BUILDNUM_OLD_ORA8SL" != "1226" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8SL_OLD_VERSION" = "10.0" -a "$BUILDNUM_OLD_ORA8SL" != "1500" -a "$BUILDNUM_OLD_ORA8SL" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8SL_OLD_VERSION" = "10.0.0" -a "$BUILDNUM_OLD_ORA8SL" != "1500" -a "$BUILDNUM_OLD_ORA8SL" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8SL_OLD_VERSION" = "10.0.0.0" -a "$BUILDNUM_OLD_ORA8SL" != "1500" -a "$BUILDNUM_OLD_ORA8SL" != "1450" ]; then
				MIG_STOP="yes"
			elif [ "$ORA8SL_OLD_VERSION" = "10.0.5" -a "$BUILDNUM_OLD_ORA8SL" != "1500" -a "$BUILDNUM_OLD_ORA8SL" != "1450" ]; then
				MIG_STOP="yes"
			fi
		fi
	
		echo 
		BEB_COMPONENTS_MIGRATION=1
	
		if [ "X${MIG_STOP}" = "Xyes" ]; then
			echo "$INST_MSG_187"
			echo
			echo "1. BrightStor ARCserve Backup v10.0 sp4 JPN "
			echo "2. BrightStor Enterprise Backup v10.0 sp4 JPN "
			echo "3. BrightStor Enterprise Backup v10.0 sp5 "
			echo "4. BrightStor Enterprise Backup v10.5 (any Service Pack)"
			echo
			echo "$INST_MSG_186"
			echo
			echo "${INST_MSG_60}"
			exit 1		
		fi
		if [ $EXEC_MODE -ne $SLNT_MODE ]; then
			echo "$INST_MSG_182"
			GET_INSTALL_FLAG2
			if [ $INSTALL_FLAG -eq 1 ];then
				return 0
			else
				echo 
				echo "$INST_MSG_60"
				echo
				exit 0
			fi
			
		fi
	elif [ $CAAGENT_NEED_UPGRADE -eq 1 -o $SERVER_NEED_UPGRADE -eq 1 -o $UAG_NEED_UPGRADE -eq 1 \
		-o $NAS_NEED_UPGRADE -eq 1 -o $DRO_NEED_UPGRADE -eq 1 -o $SAN_NEED_UPGRADE -eq 1 \
		-o $ING_NEED_UPGRADE -eq 1 -o $SYB_NEED_UPGRADE -eq 1 -o $INFMX_NEED_UPGRADE -eq 1 \
		-o $NLO_NEED_UPGRADE -eq 1 -o $IBM_NEED_UPGRADE -eq 1 -o $SAP_NEED_UPGRADE -eq 1 \
		-o $NOTES_NEED_UPGRADE -eq 1 -o $DB2_NEED_UPGRADE -eq 1 -o $GATEWAY_NEED_UPGRADE -eq 1 \
		-o $ORA_NEED_UPGRADE -eq 1 ]; then
		echo
		echo "$INST_MSG_213"
		index=0
		if [ $SERVER_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABsvr & BABmgr) \n" "${index}." "Server & Manager"
		fi
		if [ $GATEWAY_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (iGateway)\n" "${index}." "iGateway"
		fi		
		if [ $CAAGENT_HAVE_INSTALLED -eq 1 ];then
			CAAGENT_NEED_UPGRADE=1
			index=$(($index + 1 ))
			if [ "$OS" = "OSF1" ]; then
			  printf "%-3s %-40s (BABCMAGT)\n" "${index}." "Common Agent"
			else
			  printf "%-3s %-40s (BABcmagt)\n" "${index}." "Common Agent"
			fi
		fi
		if [ $UAG_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			if [ "$OS" = "OSF1" ]; then
			  printf "%-3s %-40s (BABAGNTUX)\n" "${index}." "Client Agent"
			else
			  printf "%-3s %-40s (BABagntux)\n" "${index}." "Client Agent"
			fi
		fi
		if [ $DRO_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABdr)\n" "${index}." "Disaster Recovery Option"
		fi
		if [ $NAS_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABnas)\n" "${index}." "NDMP NAS Option"
		fi
		if [ $NLO_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABstklib)\n" "${index}." "Enterprise Option for StorageTek ACSLS"
		fi
		if [ $SAN_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABsan)\n" "${index}." "Storage Area Network (SAN) Option"
		fi
		if [ $IBM_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABibmlib)\n" "${index}." "Enterprise Option for IBM3494"
		fi
		if [ $ORA_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			if [ "$OS" = "OSF1" ]; then
			  printf "%-3s %-40s (BABORA12)\n" "${index}." "Agent for Oracle"
			else
			  printf "%-3s %-40s (BABora)\n" "${index}." "Agent for Oracle"
			fi
		fi
		if [ $INFMX_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			if [ "$OS" = "OSF1" ]; then
			  printf "%-3s %-40s (BABINFMX)\n" "${index}." "Agent for Informix"
			else
			  printf "%-3s %-40s (BABinfmx)\n" "${index}." "Agent for Informix"
			fi
		fi
		if [ $SYB_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABsybase)\n" "${index}." "Agent for Sybase "
		fi
		if [ $SAP_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABsap)\n" "${index}." "Enterprise Option for SAP R/3 for Oracle"
		fi
		if [ $ING_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABing)\n" "${index}." "Enterprise Option for Advantage Ingres"
		fi
		if [ $DB2_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABdb2)\n" "${index}." "Enterprise Option for DB2 UDB"
		fi
		if [ $NOTES_NEED_UPGRADE -eq 1 ];then
			index=$(($index + 1 ))
			printf "%-3s %-40s (BABlotus)\n" "${index}." "Agent for Lotus Domino"
		fi
		echo 
		BAB_COMPONENTS_UPGRADE=1
		if [ $EXEC_MODE -ne $SLNT_MODE ]; then
			echo "$INST_MSG_214"
			GET_INSTALL_FLAG2
			if [ $INSTALL_FLAG -eq 1 ];then
				return 0
			else
				echo 
				echo "$INST_MSG_60"
				echo
				exit 0
			fi
		fi
	else
		return 0
	fi
	
}
isInstalled()
{	

	CHECK_PKG=$1
if [ "$OS" = "SunOS" ]; then
	pkginfo ${CHECK_PKG} >/dev/null 2>&1
elif [ "$OS" = "HP-UX" ]; then
	swlist ${CHECK_PKG} >/dev/null 2>&1
elif [ "$OS" = "AIX" ]; then
	lslpp -f ${CHECK_PKG}.obj >/dev/null 2>&1
elif [ "$OS" = "FreeBSD" ]; then
	pkg_info -e ${CHECK_PKG} >/dev/null 2>&1
else
	echo ${CHECK_PKG}|grep "BAB" >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		${PKGINFO} |${GREP} ${CHECK_PKG} >/dev/null 2>&1
	else
		PKGINFO_OSF1_BEB |${GREP} ${CHECK_PKG} >/dev/null 2>&1
	fi
fi
	if [ $? -ne 0 ] ;then
		return 1
	fi
	return 0
}
Process_Package_Migrate()
{
	if [ $BEBSVR_OLD_INSTALLED -eq 1 -o $SERVER_NEED_UPGRADE -eq 1 ]; then
		SVR_SELECTED=1
		AGT_SELECTED=1
               	BEB_CMG_REQUESTED=1
               	selected_1=1
		SERVER_INSTALL="YES"
	fi
	if [ $ASAGENT_OLD_INSTALLED -eq 1 -o $CAAGENT_NEED_UPGRADE -eq 1 ]; then
               	BEB_CMG_REQUESTED=1
	fi
	if [ $UAGENT_OLD_INSTALLED -eq 1 -o $UAG_NEED_UPGRADE -eq 1 ]; then
		AGT_SELECTED=1
              	BEB_CMG_REQUESTED=1
		UAGENT_INSTALL="YES"
	fi
	if [ $ORA_OLD_INSTALLED -eq 1 -o $ORA8_OLD_INSTALLED -eq 1 -o $ORA8SL_OLD_INSTALLED -eq 1 \
		-o $TIMEFINDER_OLD_INSTALLED -eq 1 -o $ORA_NEED_UPGRADE -eq 1 ]; then
		ORA8_SELECTED=1
              	BEB_CMG_REQUESTED=1
		ORA8_INSTALL="YES"
	fi
	if [ $INFMX_OLD_INSTALLED -eq 1 -o $INFMX_NEED_UPGRADE -eq 1 ]; then
		INFMX_SELECTED=1
              	BEB_CMG_REQUESTED=1
		INFMX_INSTALL="YES"
	fi
	if [ $SAP_OLD_INSTALLED -eq 1 -o $SAP_NEED_UPGRADE -eq 1 ]; then
		SAP_SELECTED=1
              	BEB_CMG_REQUESTED=1
		SAP_INSTALL="YES"
	fi
	if [ $SYBASE_OLD_INSTALLED -eq 1 -o $SYB_NEED_UPGRADE -eq 1 ]; then
		SYBASE_SELECTED=1
              	BEB_CMG_REQUESTED=1
		SYBASE_INSTALL="YES"
	fi
	if [ $ING_OLD_INSTALLED -eq 1 -o $ING_NEED_UPGRADE -eq 1 ]; then
		ING_SELECTED=1
              	BEB_CMG_REQUESTED=1
		ING_INSTALL="YES"
	fi
	if [ $DB2_OLD_INSTALLED -eq 1 -o $DB2_NEED_UPGRADE -eq 1 ]; then
		DB2_SELECTED=1
              	BEB_CMG_REQUESTED=1
		DB2_INSTALL="YES"
	fi
	if [ $NOTES_OLD_INSTALLED -eq 1 -o $NOTES_NEED_UPGRADE -eq 1 ]; then
		NOTES_SELECTED=1
              	BEB_CMG_REQUESTED=1
		NOTES_INSTALL="YES"
	fi
	if [ $DRO_OLD_INSTALLED -eq 1 -o $DRO_NEED_UPGRADE -eq 1 ]; then
		DRO_SELECTED=1
		DRO_INSTALL="YES"
	fi
	if [ $NAS_OLD_INSTALLED -eq 1 -o $NAS_NEED_UPGRADE -eq 1 ]; then
		NAS_SELECTED=1
		NAS_INSTALL="YES"
	fi
	if [ $NLO_OLD_INSTALLED -eq 1 -o $NLO_NEED_UPGRADE -eq 1 ]; then
		NLO_SELECTED=1
		NLO_INSTALL="YES"
	fi
	if [ $SAN_OLD_INSTALLED -eq 1 -o $SAN_NEED_UPGRADE -eq 1 ]; then
		SAN_SELECTED=1
		SAN_INSTALL="YES"
	fi
	if [ $IBM_OLD_INSTALLED -eq 1 -o $IBM_NEED_UPGRADE -eq 1 ]; then
		IBM_SELECTED=1
		IBM_INSTALL="YES"
	fi
}

#return 1:down
#return 0:running
bab_is_down () {

	CHD_LIST='caservd|cadiscov|cauthd|calogger|cadbd|camediad|caqd|cacommd|caagentd|sanpeer|sanghost|ssi|mini_el'
	ps -el | $EGREP $CHD_LIST | $EGREP -v $GREP 1>/dev/null 2>&1
	if [ $? -ne 0 ] ;then
		return 1
	else
		return 0
	fi
}
shutdown_caagent()
{

#  check if BrightStor UNIX Client Agent is already started

#   ASD_COUNT=`caagent status 2>/dev/null | grep "running" | wc -l `
#   if [ $ASD_COUNT = "1" ]
#   then
    if [ -f /usr/bin/caagent ]; then
          /usr/bin/caagent stop
    elif [ -f $CAAGENT_OLD_PKG_DIR/caagent ]; then
    	$CAAGENT_OLD_PKG_DIR/caagent stop
    elif [ -f /opt/CA/BABcmagt/caagent ]; then
    	/opt/CA/BABcmagt/caagent stop
    fi
          
        ${ECHO} $INST_MSG_189
#   fi
}
stop_all()
{

    if [ $BEBSVR_OLD_INSTALLED -eq 1 -o $SERVER_NEED_UPGRADE -eq 1 ]; then
	    bab_is_down
	    if [ $? -eq 0 ] ;then
		
		${ECHO} 
		if [ $SERVER_NEED_UPGRADE -eq 1 ]; then
			${ECHO} $INST_MSG_188
		else
			${ECHO} $INST_MSG_188a
		fi
if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ]; then
		INSTALL_FLAG=1
elif [ $EXEC_MODE -eq $REGR_MODE ]; then
		GET_INSTALL_FLAG2
fi
		if [ $INSTALL_FLAG -eq 1 ];then
		
		        if [ $SERVER_NEED_UPGRADE -eq 1 ]; then
		        	BEB_HOME=$BEB_OLD_PKG_DIR/BrightStorARCserve
		        else
		        	BEB_HOME=$BEB_OLD_PKG_DIR/BrightStorEB
		        fi
		        export BEB_HOME
			#
			# stop nlo if NLO installed
			#
			if [ -f $BEB_HOME/sbin/nlo_start.sh ]; then
			   SSI=`ps -ef | $EGREP ssi | $EGREP $BEB_HOME | $EGREP -v $GREP | awk '{print $2}'`
			   MINI=`ps -ef | $EGREP mini_el | $EGREP $BEB_HOME | $EGREP -v $GREP | awk '{print $2}'`
			   kill -9 $SSI $MINI 2>/dev/null
			fi
			
			# stop san if SAN installed
			#
			if [ -f $BEB_HOME/config/sanpeer.cfg ]; then
			  $BEB_HOME/sbin/sanstop
			fi
			
			# stop other services
	    	  	if [ -x $BEB_HOME/sbin/cstop ] ;then
				
	                        if [ $EXEC_MODE -ne $SLNT_MODE ]; then
	                            $BEB_HOME/sbin/cstop
	                        else
	                            echo "y" | $BEB_HOME/sbin/cstop
	                        fi
		  		if [ $? -ne 0 ];then
		  			return 1 
		  		fi 
			fi 	      	  
	
	    	  	if [ -x $BEB_HOME/bin/stopgui ] ;then
				
		  		$BEB_HOME/bin/stopgui
		  		if [ $? -ne 0 ];then
		  			return 1 
		  		fi 	  		
			fi 
		 
	    	  	if [ -x $BEB_HOME/sbin/stopingres ] ;then
				
		  		$BEB_HOME/sbin/stopingres
		  		if [ $? -ne 0 ];then
		  			return 1 
		  		fi 	  		
			fi 

			shutdown_caagent		
		  	
		  	trytime=0
		  	endflag=0
		  	#try 30 times
		  	while [ $trytime -lt 30 -a $endflag -ne 1 ]
		  	do
		  		bab_is_down
		  		if [ $? -eq 1 ];then	  		
		  			endflag=1
		  		else
		  			trytime=$((trytime+1))
		  			sleep 5
		  		fi
		  	done
		  	return 0
		else
			return 0
		fi
	    fi
    fi
    return 0
}

Setup_Portal()
{
	if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ]; then
		echo
		echo "${INST_MSG_200}"
		echo "${INST_MSG_201}"
	  while [ 1 -eq 1 ]
	  do
		echo
		getyn "${INST_MSG_202}" 0
		if [ $? -eq 1 ]; then
		  echo "${INST_MSG_203} \c"
		  read Portal_Server_Name
		  echo "${INST_MSG_210} $Portal_Server_Name"
		  getyn "${INST_MSG_234}" 0
		  if [ $? -eq 1 ]; then
		    break
		  fi
		else
		  break
		fi
	  done
	fi
}
Setup_Doc_Install()
{
	if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ]; then
		echo
		echo "$INST_MSG_194"
		echo
		GET_INSTALL_FLAG_YN
		if [ $INSTALL_FLAG -eq 1 ]; then
			INSTALL_DOC="YES"
		fi
	fi
}
Setup_License_Path()
{
  if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ]; then
    # if CASHCOMP is not set, read CASHCOMP value from /etc/profile.CA
    if [ "$CASHCOMP" = "" ]; then
      if [ -f /etc/profile.CA ]; then
        . /etc/profile.CA
      fi
      if [ "${CASHCOMP}" = "" ];then
        if [ "${CALIB}" != "" -a -d "${CALIB}" ];then
          CASHCOMP="`dirname ${CALIB}`"
        elif [ "${CABIN}" != "" -a -d "${CABIN}" ];then
          CASHCOMP="`dirname ${CABIN}`"
        fi
      fi
    fi
    if [ "$CASHCOMP" = "" ]; then
      CASHCOMP=/opt/CA/SharedComponents
      while [ 1 -eq 1 ]
      do
        echo
        echo "${INST_MSG_219}"
        getyn "${INST_MSG_208}" 0
        if [ $? -eq 1 ]; then
          echo "${INST_MSG_209} \c"
          read License_Path
          echo "${INST_MSG_210} $License_Path"
          getyn "${INST_MSG_234}" 0
          if [ $? -eq 1 ]; then
            CASHCOMP=$License_Path
            break
          fi
        else
          break
        fi
      done
    fi
  fi
}

Display_License_Menu()
{
while [ 1 -eq 1 ]
do
  echo
  echo "${INST_MENU_0}"
  echo "${INST_MENU_1}"
  echo "${INST_MENU_2}"
  echo "${INST_MENU_3}"
  echo "${INST_MENU_4}"
  echo "${INST_MSG_220} \c"
  read LICENSE_CHOICE
  case $LICENSE_CHOICE in
    1|2|3|4)
        break
        ;;
    *)
        echo "$INST_MSG_16"
        ;;
  esac
done 
}

Add_Key()
{
key=$1
if [ "$License_Path" = "" ]; then
  UTIL_PATH=$CASHCOMP/ca_lic
else
  UTIL_PATH=$License_Path/ca_lic
fi
$UTIL_PATH/CALicense $key >/dev/null 2>&1
return $?
}

Query_Key()
{
key=$1
code=$2
if [ "$License_Path" = "" ]; then
  UTIL_PATH=$CASHCOMP/ca_lic
else
  UTIL_PATH=$License_Path/ca_lic
fi
if [ "$code" = "" ]; then
  $UTIL_PATH/CALicense $key -q >/dev/null 2>&1
else
  $UTIL_PATH/CALicense $key -c $code -q >/dev/null 2>&1
fi
return $?
}

Setup_License_Key()
{
while [ 1 -eq 1 ]
do
  Display_License_Menu
  if [ "$LICENSE_CHOICE" = "2" ]; then
    echo "${INST_MSG_221} \c"
    read license_key
    Query_Key $license_key 2OEM
    if [ $? -eq 0 ]; then
       Add_Key $license_key
       rc=$?
       if [ $rc -eq 0 -o $rc -eq 245 ]; then
         echo "${INST_MSG_222}"
         break
       else
         echo "${INST_MSG_227} $rc"
       fi
    else
       echo "${INST_MSG_223}"
    fi
  elif [ "$LICENSE_CHOICE" = "3" ]; then
    echo "${INST_MSG_221} \c"
    read license_key
    Add_Key $license_key
    rc=$?
    if [ $rc -eq 0 -o $rc -eq 245 ]; then
       echo "${INST_MSG_222}"
    else
       echo "${INST_MSG_227} $rc"
       continue
    fi
    while [ 1 -eq 1 ]
    do
      getyn "${INST_MSG_224}" 0
      if [ $? -eq 0 ]; then
        return
      else
        echo "${INST_MSG_221} \c"
        read license_key
        Add_Key $license_key
        rc=$?
        if [ $rc -eq 0 -o $rc -eq 245 ]; then
           echo "${INST_MSG_222}"
        else
           echo "${INST_MSG_227} $rc"
           continue
        fi
      fi
    done
  else
    break
  fi
done
}

check_ARCserveIT()
{
if [ "$ARC_HOME" != "" ]; then
  if [ -r $ARC_HOME/data/RELVERSION ]; then
    TNG_VER=`cat $ARC_HOME/data/RELVERSION | grep "ARCserveIT" | grep "6.61" | grep -v grep`
    if [ "$TNG_VER" != "" ]; then
      echo
      echo "${INST_MSG_240}"
      echo "${INST_MSG_241}"
      echo "${INST_MSG_242}"
      echo
      exit 101
    fi
  fi
fi
}

    ###################################################################
    # Main body of sh script
    #
    ###################################################################

    THISSCRIPT=`basename $0`
    THISDIR=`dirname $0`
	# tar file names of the different packages
	#
    HOMEDIR=`pwd`
    TMPDIR=/var/tmp
    ROOT_PATH=`echo $THISDIR | grep '^/'`
    if [ "$ROOT_PATH" = "" ]; then
	  THISDIR=$HOMEDIR/$THISDIR
    fi
    PKG_LOCATION="$THISDIR"
    DSPKG_LST="/opt/CA/BABcmagt/dsCheckPkgs.lst"
    Installation_Initialize 2>/dev/null
    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ]
    then
    Migration_ARC_Init 
    else
    Migration_ARC_Init >/dev/null 2>&1
    fi

      if [ -f $HOMEDIR/$LIC98_PKG ]
      then
          LIC98_PKG_R=$HOMEDIR/$LIC98_PKG
      else
          LIC98_PKG_R=$LIC98_PKG
      fi

    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ]
    then
        if [ $EXEC_MODE -ne $RESP_MODE ]; then
          check_ARCserveIT
        fi
        verify_license
        view_notes
if [ "$OS" != "FreeBSD" ]; then
        Setup_License_Path
fi
if [ "${LIC_CHECK}" = "YES" ]; then
        Install_License_Package
        Setup_License_Key
fi
    else
    	if [ -f ${LOG_FILE} ] ; then
    		/bin/rm ${LOG_FILE}
    		touch ${LOG_FILE}
    	fi
        check_ARCserveIT >> ${LOG_FILE} 2>&1
    fi

    if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ]
    then
	[ -f ${TMPFILENAME} ] && rm -f ${TMPFILENAME}  
	if [ $# -ge 1 -a "X$1" = "X-f" ]; then
		if [ "$2" = "" ]; then
			echo
	               	echo "${INST_MSG_55}"
	               	echo "${THISSCRIPT} -f FULL_PATH_RESPONSE_FILE"
	               	echo
	               	exit 1
		else
			SLT_RESPONSE_FILE=$2
		fi
		if [ ! -r $SLT_RESPONSE_FILE ]
		then
			echo
			echo "${INST_MSG_170} $SLT_RESPONSE_FILE"
			echo "${INST_MSG_171}"
			echo
			exit 1
		else
			PATH=`pwd`:$PATH; export PATH
			. ${SLT_RESPONSE_FILE} >> ${LOG_FILE} 2>&1
			if [ $? -ne 0 ];then
				echo
				printf "${INST_MSG_226}" "${SLT_RESPONSE_FILE}"
				echo 
				exit 7 
			fi
		fi
	elif [ $# -ge 1 -a "X$1" = "X--upgrade" ]; then
		OLD_NLS_LANG=$NLS_LANG
		if [ "$LANG" = "" ] 
		then
			LANG=C
		fi
		
		NLS_LOCALE=$LANG
	        NLS_LANG=`$NLS_UTILITY_FILE -c $LANG  $NLSMAPFILE 2>/dev/null`
	        LC_CTYPE=`locale 2>/dev/null | grep LC_CTYPE | grep -v grep | cut -d"=" -f2| cut -d"\"" -f2`
		if [  "$NLS_LANG" = "C" -a "$LC_CTYPE" != "" ]
		then
		        LC_CTYPE_TYPE=`$NLS_UTILITY_FILE -c $LC_CTYPE  $NLSMAPFILE 2>/dev/null`
		        if [ "$LC_CTYPE_TYPE" != "$NLS_LANG" ]
		        then
		                NLS_LANG=$LC_CTYPE_TYPE
		                NLS_LOCALE=$LC_CTYPE
		        fi
		fi
		echo > /dev/null
	else
		echo
               	echo "${INST_MSG_55}"
               	echo "${THISSCRIPT} -f FULL_PATH_RESPONSE_FILE"
               	echo
               	exit 1
	fi
	set_msgpath
	get_config
    fi

    if [ $EXEC_MODE -eq $RESP_MODE ]
    then
    	echo
	dskSpaceMsg
	echo
	prompt_response_location
    fi

if [ "$OS" = "HP-UX" ]; then
    if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ] ; then
        os_level=`uname -r`
        case $os_level in
        *.11.00)
            check_patch >> ${LOG_FILE} 2>&1
            ;;
        esac
    else
        os_level=`uname -r`
        case $os_level in
        *.11.00)
            check_patch
            ;;
        esac
    fi
fi
    # Set workspace directory
    #
    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
	    if [ $# -gt 2 ]
	    then
	        USAGE
	    elif [ ! -d $TMPDIR ]
	    then
	        echo "${INST_MSG_96}" "$TMPDIR"
	        USAGE
	    fi
    fi
    YES_FILE=/tmp/YES.pkgask.$$
	if [ "$OS" = "SunOS" ]; then
	    if [ $EXEC_MODE -ne $RESP_MODE ]
	    then
	      rm -f ${YES_FILE}
	      echo "y" > ${YES_FILE}; echo "y" >> ${YES_FILE}
	    fi
	fi
	if [ "$OS" = "AIX" -a $EXEC_MODE -ne $RESP_MODE ]; then
	        Check_Platform
	fi
	    
    # For old packages detection
    if [ $EXEC_MODE -ne $RESP_MODE ]; then
	    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
	    	detect_old_pkg
	    elif [ $EXEC_MODE -ne $SDO_MODE ] ; then
	    	detect_old_pkg >> ${LOG_FILE} 2>&1
	    fi
    fi
    
    # Package selection
    #
    if [ $EXEC_MODE -ne $RESP_MODE ]
    then
if [ "$OS" = "SunOS" ]; then
        BEB_PKG_DIR=`pkgparam $SVR_PKG BAB_HOME 2> /dev/null`
        if [ "$BEB_PKG_DIR" = "" ]
        then
            BEB_PKG_DIR=$BEB_PKG_DIR_DEFAULT
            BEB_BASE_INSTALLED=0
        else
            BEB_PKG_DIR=`dirname $BEB_PKG_DIR`
            BEB_BASE_INSTALLED=1
        fi
elif [ "$OS" = "HP-UX" ]; then
        BEB_PKG_INFO=`${PKGINFO} | ${GREP} $SVR_PKG`
        if [ "${BEB_PKG_INFO}" != "" ]
        then
            BEB_PKG_DIR=`${PKGINFO} -a location $SVR_PKG | grep $SVR_PKG | grep -v $SVR_PKG.$SVR_PKG | ${AWK} '{ print $NF }'`
            BEB_BASE_INSTALLED=1
        else
            BEB_PKG_DIR=${BEB_PKG_DIR_DEFAULT}
            BEB_BASE_INSTALLED=0
        fi
elif [ "$OS" = "AIX" ]; then
        BEB_PKG_INFO=`$PKGINFO | grep $SVR_PKG`
        if [ "${BEB_PKG_INFO}" = "" ]
        then
            BEB_BASE_INSTALLED=0
        else
            if [ -h /opt/CA/BrightStorARCserve ]
            then
                HOME_DIR=`ls -l /opt/CA/BrightStorARCserve | sed 's/.*> //g'`
                BEB_PKG_DIR=`dirname $HOME_DIR`
            fi
            BEB_BASE_INSTALLED=1
        fi
fi
    fi

    	if [ $EXEC_MODE -eq $SDO_MODE -a "$CMAGT_INSTALL" = "YES" ] ; then
        	INSTALL_CMAGT >> ${LOG_FILE} 2>&1
    	fi
    	if [ $EXEC_MODE -eq $SDO_MODE -a "$SERVER_INSTALL" = "YES" ] ; then
        	BEB_BASE_REQUESTED=1
    	fi
      Finalize_User_Packages

       if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ] ; then
                       Get_Choice >> ${LOG_FILE} 2>&1 # verify TMPDIR space
       else
                       Get_Choice # verify TMPDIR space
       fi

    if [ ${BEB_BASE_REQUESTED} -eq 1 ]; then
      Setup_Portal
      
      if [ -d $PKG_LOCATION/doc/${NLS_LANG} ]; then
      	Setup_Doc_Install
      fi
    fi

         #Create Groups
    if [ "$OS" = "AIX" -a "$BEB_BASE_REQUESTED" = "1" ]; then
    	Select_Env
    elif [ ${BEB_BASE_REQUESTED} -eq 1 ]; then
        Select_Env
        #Create beb group
        if [ "X${BEB_OLD_PKG_DIR}" = "X" ]; then
        	create_group 0
        fi
    fi

    if [ "${AGT_PKG}" = "BABagntux" -o "${AGT_PKG}" = "BABAGNTUX" ]
    then
        #Create uagent group
        if [ "X${UAGENT_OLD_PKG_DIR}" = "X" ]; then
        	create_group 1
        fi
    fi

    if [ ${BEB_CMG_REQUESTED} -eq 1 -a $CAAGENT_NEED_UPGRADE -ne 1 ]
    then
        tmpcmagt=`$PKGINFO | grep $CMG_PKG`
        if [ "$tmpcmagt" = "" ] 
        then
            #common agent needs to be installed
            BEB_CMG_REQUESTED=1
        else
            #common agent does not need to be installed
            BEB_CMG_REQUESTED=0
        fi
    fi

    if [ ${BEB_CMG_REQUESTED} -eq 1 -o $EXEC_MODE -eq $RESP_MODE ]
    then
        #Configure automatic startup shutdown
        cfgAgtStrtStop
    fi

    if [ $EXEC_MODE -eq $RESP_MODE ]
    then
	create_response_file
	if [ $? -eq 0 ] ; then
		echo ""
	  	echo "${INST_MSG_97}"
	  	echo "${INST_MSG_98} [${RESPONSE_FILE}]"
	  	echo ""
	        exit
        else
		echo ""
	  	echo "${INST_MSG_172}"
	  	echo "${INST_MSG_60}"
	  	echo ""
	  	exit
        fi
    fi

    if [ $EXEC_MODE -eq $SLNT_MODE -o $EXEC_MODE -eq $SDO_MODE ] ; then
    	Implicit_Requirements >> ${LOG_FILE} 2>&1
    elif [ $EXEC_MODE -ne $RESP_MODE ]; then
    	Implicit_Requirements
    fi

    mkdir -p $TMPDIR/$PID 2>/dev/null
    if [ $? != 0 ]
    then
        echo "${INST_MSG_99} $TMPDIR/$PID"
        CLEANUP 10
    fi
    #catch certain signal and try to clean up
    #
    trap CLEANUP 1 2 3 5 15

    # display log file location
    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
    	displayLogLocation
    else
    	displayLogLocation >> ${LOG_FILE} 2>&1
    fi
    
    # if CAIGLBL0000 is set skip, the native uagent packages
    if [ "$CAIGLBL0000" != "" ]
    then
        UAG_PKG=""
        UAG_PKG_UPPER=""
    fi
    
     if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
       stop_all
     else
       stop_all >> ${LOG_FILE} 2>&1
     fi
     rc=$?
    if [ $rc -ne 0 ]; then
     if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
    	echo "$INST_MSG_232"
    	CLEANUP $rc
     else
    	echo "$INST_MSG_232" >> ${LOG_FILE} 2>&1
    	CLEANUP $rc >> ${LOG_FILE} 2>&1
     fi
    fi
    check_RELVERSION
    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
    	Install_Packages
    else
    	silent_prepare
    	Install_Packages >> ${LOG_FILE} 2>&1
    fi

    if [ $BEB_NEW_INSTALLED -eq 1 ]; then
    	    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
		  Set_Env
	    else
		  Set_Env >> ${LOG_FILE} 2>&1
	    fi
	    
	if [ ! -f ${INSTALL_README} ]; then
	  cp ${PKG_LOCATION}/readme.txt $BEB_PKG_DIR/BrightStorARCserve >> ${LOG_FILE} 2>&1
	else
	  cp ${INSTALL_README} $BEB_PKG_DIR/BrightStorARCserve/readme.txt > /dev/null 2>&1
	fi
	if [ ! -f ${INSTALL_README_HTML} ]; then
	  cp ${PKG_LOCATION}/readme.html $BEB_PKG_DIR/BrightStorARCserve >> ${LOG_FILE} 2>&1
	else
	  cp ${INSTALL_README_HTML} $BEB_PKG_DIR/BrightStorARCserve/readme.html > /dev/null 2>&1
	fi
    fi

    umask $SAVEMASK
    rm -f $YES_FILE 2> /dev/null
    [ -s "${TMPFILENAME}" ] || rm -f ${TMPFILENAME} >/dev/null 2>&1
    if [ $EXEC_MODE -ne $SLNT_MODE -a $EXEC_MODE -ne $SDO_MODE ] ; then
	CLEANUP 0
    else
	CLEANUP 0 >> ${LOG_FILE} 2>&1
    fi
