#!/bin/sh

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

# Check for 'root' early on and exit with appropriate message
ID_CMD="id -u"
if [ `uname` = "SunOS" ] ; then
        ID_CMD="/usr/xpg4/bin/id -u"
fi

if [ `$ID_CMD` -ne  0 ] ; then
        echo "ERROR: Must be logged on as root."
        exit 1
fi

# Get the Machine Type for the platform that we are running on
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
                ;;
	Linux)
                if [ $HDWR_TYPE = "x86_64" ] ; then
                        if [ -e "./RALUS64/uninstallralus" ] ; then
                                cd ./RALUS64
                                ./uninstallralus $*
                        else
                                echo "ERROR: Unable to launch Linux 64-bit uninstaller." 
                        fi
                        exit 1
                fi

		OS=Linux;export OS
		PERL_VER=5.8.8;export PERL_VER
		;;
        AIX)
                OS=AIX;export OS
                PERL_VER=5.8.8;export PERL_VER
                ;;
        Darwin)
                echo "Not supported for this platform. Please try using ./uninstallrams"
                exit 1
                ;;
	*)
		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 ./uninstallralus.pl $*
