#! /bin/sh
#### UNINSTALL SCRIPT - Generated by SetupDB 1.6 #####
DetectARCH()
{
        status=1
        case `uname -m` in
           amd64 | x86_64)  echo "amd64"
                  status=0;;
           i?86 | i86*)  echo "x86"
                  status=0;;
           90*/*)
		   echo "hppa"
		   status=0;;
	    *)
		case `uname -s` in
		    IRIX*)
			echo "mips"
			status=0;;
           AIX*)
           echo "ppc"
           status=0;;
		    *)
			arch=`uname -p 2>/dev/null || uname -m`
                       if test "$arch" = powerpc; then
                          echo "ppc"
                       else
                          echo $arch
                       fi
			status=0;;
		esac
        esac
        return $status
}

DetectOS()
{
  os=`uname -s`
  if test "$os" = OpenUNIX; then
     echo SCO_SV
  else
     echo $os
  fi
  return 0
}

FindBinary()
{
  arch=$1
  if which loki-uninstall 2> /dev/null > /dev/null || type -p loki-uninstall 2> /dev/null > /dev/null; then
    if loki-uninstall -v > /dev/null 2> /dev/null; then
        echo `exec 2>&-; which loki-uninstall || type loki-uninstall`
    else
        echo "$HOME/.loki/installed/bin/`DetectOS`/$arch/uninstall"
    fi
  else
    echo "$HOME/.loki/installed/bin/`DetectOS`/$arch/uninstall"
  fi
}

arch=`DetectARCH`
UNINSTALL=`FindBinary $arch`

# Special case: if amd64 and binary is missing, try to run x86 build...
if test ! -x "$UNINSTALL" ; then
  if test "$arch" = amd64 ; then
    UNINSTALL=`FindBinary x86`
  fi
fi

if test ! -x "$UNINSTALL" ; then
    echo Could not find a usable uninstall program. Aborting.
    exit 1
fi

exec "$UNINSTALL" -L google-earth "/opt/google-earth/.manifest/google-earth.xml" "$1"

