#!/bin/bash

ARCH=`uname -m`
BUILD_ARCH="x86_64"

#if [ ! $ARCH = $BUILD_ARCH ]; then
#	echo "Build architecture:	$BUILD_ARCH" 
#	echo "Current architecture:	$ARCH" 
#	echo "Incompatible architectures, stop now..."
#	exit 1
#fi

if [ "$(whoami)" != "root" ]; then
	echo "Please run as root or sudo."
	exit 1
fi

echo "Start to uninstall..."

plat_id=`cat /etc/*release`

if echo "$plat_id" | grep -q "Ubuntu"; then
  	echo "Ubuntu platform... "
	chmod 755 /opt/weida/Ubuntu_install
	/opt/weida/Ubuntu_install "no"
fi

if echo "$plat_id" | grep -q "Fedora"; then
  	echo "Fedora platform... "
	chmod 755 /opt/weida/Fedora_install
	/opt/weida/Fedora_install "no"
fi

if echo "$plat_id" | grep -q "openSUSE"; then
  	echo "openSUSE platform... "
	chmod 755 /opt/weida/OpenSuse_install
	/opt/weida/OpenSuse_install "no"
fi

if echo "$plat_id" | grep -q "CentOS"; then
  	echo "CentOS platform... "
	chmod 755 /opt/weida/CentOS_install
	/opt/weida/CentOS_install "no"
fi

if echo "$plat_id" | grep -q "Mint"; then
  	echo "Mint platform... "
	chmod 755 /opt/weida/Mint_install
	/opt/weida/Mint_install "no"
fi

rm -r /opt/weida >& /dev/null;

echo "Uninstall completed !"
exit 1
