#!/bin/sh 
# uninstall.sh
# Created by Tresa on 08/03/11.# Copyright 2011 __MyCompanyName__. All rights reserved.

BASEDIR=$(dirname "$0")
cd "$BASEDIR"
cd ../
cd "./InstallFiles/Uninstall/"

cp -f -R "Scan Assistant.zip" "/tmp/"
ditto -xk "/tmp/Scan Assistant.zip" "/tmp/"

cd "/tmp/Scan Assistant"

sudo Common/PerformOperations.app/Contents/MacOS/PerformOperations -mode "root" -InstallerPath "$0"
sleep 5

while true;
do
if ps ax | grep -v grep | grep PerformOperations > /dev/null
then
	sleep 1
else
	break
fi
done
sudo -u "$USER" Common/PerformOperations.app/Contents/MacOS/PerformOperations -mode "user"
cd ../

sudo rm -f -R "/tmp/Scan Assistant"
sudo rm -f -R "/tmp/Scan Assistant.zip"