#!/bin/sh
#
#
# Copyright 2000 Xi Graphics
#
# Uninstall - Find installation dir/process for this OS and exec/chain 
#	Uninstall it.
#
# $XiGId: Uninstall.toplev,v 1.2 2000/10/31 03:37:25 jon Exp $
#
#########################################################################
# set -x			# uncomment for debuging

# remove stuff that will probably only confuse things.
unset ENV
unset START	

### Off we go.  We can't be fancy since we can't assume that we're running
###  on something reasonably smart like ksh or bash.

# messages
INST_ABORT="### Uninstall aborted."

if [ -z "$INSTALL_PATH" ]
then
	PATH=/bin:/usr/bin:/sbin:/usr/sbin:/etc
else
	PATH="$INSTALL_PATH"
fi

CURDIR="`pwd`"		# get current location

SYSTYPE=""				# Type of OS

### Check platform - see if we have it...
# get the OS type

SYSTYPE="`uname -s`"

if [ -z "$SYSTYPE" ]
then	# Eh?
	echo "ERROR: Couldn't determine System type with 'uname -s'"
	echo "$INST_ABORT"
	
	exit 1
fi

# Check to see if this is BSD/OS, if so - rename to BSD_OS for obvious reasons.

if [ "$SYSTYPE" = 'BSD/OS' ]
then
	SYSTYPE="BSD_OS"
fi

INSTALLDIR=""

# determine install directory based on SYSTYPE - for LFB toplev only

case $SYSTYPE in
	BSD_OS)
		INSTALLDIR="bsdi"
		;;
	FreeBSD)
		INSTALLDIR="freebsd"
		;;
	SunOS)
		INSTALLDIR="solaris"
		;;
	UnixWare)
		INSTALLDIR="unixware"
		;;
	Linux)
		INSTALLDIR="linux"
		;;
	*)
		echo "### Unrecognized System Type: $SYSTYPE."
		echo "$INST_ABORT"
		exit 1
		;;
esac

# handle XiG installer OS's first
case $SYSTYPE in
        BSD_OS|FreeBSD|Linux)
	# XiG installer

		INSTALLBS="$CURDIR/$INSTALLDIR"

		if [ ! -f "$INSTALLBS/Uninstall" ]
		then
			echo "### Cannot find uninstall program: $INSTALLBS/Uninstall, for OS: $SYSTYPE"
			echo "$INST_ABORT"
			exit 1
		fi

		# now fire it off...	

		cd $INSTALLBS
		exec ./Uninstall $*

		# if we're here, there was a problem
		echo "### Could not exec $INSTALLBS/Uninstall: status: $?"
		echo "$INST_ABORT"
		exit 1
		;;

	## now check out the others (solaris and unixware)
	SunOS|UnixWare)
		# Here, both OS's use the pkgadd facility...

		# make sure it's there...
		if [ -d $CURDIR/$INSTALLDIR/accelx ]
		then
			:
		else
			echo "## Could not find the $CURDIR/$INSTALLDIR/accelx directory,"
			echo "##  please contact Xi Graphics support."
			echo "$INST_ABORT"
			exit 1
		fi



		# remove it.
		echo "pkgrm accelx"
		pkgrm accelx

		;;

	*)
		# OS/2, for example ;-)
		echo "## No support for $SYSTYPE on this media."
		echo "$INST_ABORT"
		;;

esac

exit 0





