#!/bin/sh

# The environment variable $SRCHOME cannot be set during the installation
unset SRCHOME

AWK=/bin/awk

BUNDLE=tg
OCR_LOC=/etc/oracle/ocr.loc
LOCALONLY=local_only
LOCAL=TRUE

CMDDIR=`dirname $0`

if [ "$CMDDIR" = "." ]; then
    CMDDIR=`pwd`;
fi

# Replace relative path with fully qualified path.
if [ ! "`echo $CMDDIR|grep '^/'`" ]; then
    CMDDIR=`pwd`/$CMDDIR;
fi

if [ x${PATH} != x ]; then
    PATH=/usr/bin:/usr/ccs/bin:$PATH:$CMDDIR/install
    export PATH 
else
    PATH=/usr/bin:/usr/ccs/bin:$CMDDIR/install
    export PATH
fi

if [ x${LD_LIBRARY_PATH} != x ]; then
    LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH
else
    LD_LIBRARY_PATH=/usr/lib
    export LD_LIBRARY_PATH
fi

# Determine whether there is an existing CRS or not.
# Local is value of local_only in ocr.loc.
# False means there is an existing CRS installation on the system.
if [ -r $OCR_LOC ]; then
    LOCAL=`$AWK -F= /$LOCALONLY/'{print $2}' $OCR_LOC`
fi

case "$BUNDLE" in
db)
# One-click: only if there is no cmd line argument and it's not on CRS node
if [ $# -gt 0 -o "$LOCAL" = "FALSE" -o \
     ! -r $CMDDIR/install/oneclick.properties ]; then
    $CMDDIR/install/.oui $*
else
    $CMDDIR/install/.oui -oneclick
fi
;;
crs)
    $CMDDIR/install/.oui $* -formCluster
;;
*)
    $CMDDIR/install/.oui $*
;;
esac
