#!/bin/sh

VXIF_HOME=./;export VXIF_HOME
VXIF_ORIGENVLANG=$LANG;export VXIF_ORIGENVLANG
PERL_UNICODE=1;export PERL_UNICODE

# Let's get the type of Machine we are running on this platform
HDWR_TYPE=`uname -m`

# Use our own distribution of Perl (VRTSperl)
case `uname` in
        SunOS)
                OS=SunOS;export OS
                PERL_VER=5.8.8;export PERL_VER
                ;;

        AIX)
                OSLEVEL=`oslevel | cut -d. -f1`
                OSLEVEL1=`oslevel`
                echo "AIX operating system $OSLEVEL1 found on the system"
		#do not allow install or upgrade below AIX 7.1
                if [ $OSLEVEL -lt 7 ] ; then
                  echo "ERROR:AIX operating system  not supported for RALUS install.Exiting..."
                  exit 1
                fi

		OS=AIX;export OS
		PERL_VER=5.8.8;export PERL_VER
		;;

	Linux)

	        if [ $HDWR_TYPE = "i686" ] ; then
		    echo "ERROR: Backup Exec RALUS install/upgrade is not supported on 32-bit Linux servers."
		    exit 1
		fi

		if [ $HDWR_TYPE = "x86_64" ] ; then
			if [ -e "./RALUS64/installralus" ] ; then
				cd ./RALUS64
				./installralus $*
			else
				echo "ERROR: Unable to launch Linux 64-bit installer."
			fi
			exit 1
		fi
		OS=Linux;export OS
		PERL_VER=5.8.8;export PERL_VER
		;;
	*)
		echo "Not Supported."
                exit 1
		;;
esac

if [ -z "$VXIF_HOME" ] ; then
	echo "ERROR: Environment variable VXIF_HOME is not defined. Exiting ... "
	exit 1;
fi

if [ ! -d "${VXIF_HOME}/VxIF" ] ; then
	echo "ERROR: VXIF_HOME is invalid. It must point to the root of VxIF. Exiting ... "
	exit 1;
fi

perl -I.. -I$PATH -I$VXIF_HOME ./installralus.pl $*
