#!/bin/sh
# TorPreFlight is invoked before the install begins

# Figure out where Tor is installed
if [ -f /Library/StartupItems/Tor/Tor.loc ]; then
	TORPATH=`cat /Library/StartupItems/Tor/Tor.loc`
else
	TORPATH="/Library/Tor/"
fi
echo $TORPATH

# Backup all of Tor, just in case
if [ -d $TORPATH ]; then
	tar zcf /tmp/TorSavedMe.tar.gz $TORPATH/var/lib/tor $TORPATH/torrc
fi

# Remove Tor and everything to do with it
if [ -f $TORPATH/uninstall_tor_bundle.sh ]; then
	$TORPATH/uninstall_tor_bundle.sh
else
	$PACKAGE_PATH/Contents/Resources/uninstall_tor_bundle.sh
fi

# This is complete, we have a fresh system on which to install Tor
