#!/bin/bash

# BEGIN STRING TABLE
DIFF_USER1="This application was installed by a different user. You may not"
DIFF_USER2="have the correct permissions to correctly uninstall it."
DIFF_USER3="Do you want to attempt to uninstall anyway? [N/y] "
ABORTED="Uninstall aborted. Your system has been left unchanged."
UNINSTALL_VERIFY="Are you sure you want to uninstall this application? [N/y] "
# END STRING TABLE

auto_remove=N
uid=`id -u`

if [ -z "$SETUP_USERID" ]; then
	# Setup canceled
	SETUP_USERID=$UID
	auto_remove=Y
fi

if [ $uid -ne $SETUP_USERID ]; then
    echo $DIFF_USER1
    echo $DIFF_USER2
    echo -n $DIFF_USER3
    read response
    case $response in
	y|Y|yes|Yes|YES )
	    # do nothing....
	;;
	* )
	    echo $ABORTED
	    exit 0
	;;
    esac
else
    if [ $auto_remove != "Y" ]; then
    	echo -n "$UNINSTALL_VERIFY"
    	read response
    	case $response in
		y|Y|yes|Yes|YES )
	    		# do nothing....
		;;
		* )
	    		echo $ABORTED
	    		exit 0
		;;
    	esac
    fi
fi

function RemoveLink() {
   if [ -L "$1" ]; then
      rm -f "$1"
   fi
}

function RemoveFile() {
   if [ -e "$1" ]; then
      rm -f "$1"
   fi
}


# Pre-uninstall cleanup

RemoveLink $SETUP_INSTALLPATH/bin/libborqt-6.9-qt2.3.so

RemoveFile $SETUP_INSTALLPATH/fonts/installed_path
RemoveFile $SETUP_INSTALLPATH/fonts/install_log
