TorPreFlight 950 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. # TorPreFlight is invoked before the install begins
  3. # Figure out where Tor is installed
  4. if [ -f /Library/StartupItems/Tor/Tor.loc ]; then
  5. TORPATH=`cat /Library/StartupItems/Tor/Tor.loc`
  6. elif [ -f /System/Library/LaunchDaemons/net.freehaven.tor.plist ]; then
  7. TORPATH=/`grep -A1 "<key>Program</key>" /System/Library/LaunchDaemons/net.freehaven.tor.plist | grep string | cut -d"/" -f2,3`
  8. else
  9. TORPATH="/Library/Tor/"
  10. fi
  11. echo $TORPATH
  12. # Backup all of Tor, just in case
  13. if [ -d $TORPATH ]; then
  14. tar zcf ~/`date "+%Y-%m-%d"`-Tor.backup.tar.gz $TORPATH/var/lib/tor/ $TORPATH/torrc
  15. echo `date "+%Y-%m-%d"`-Tor.backup.tar.gz > ~/TorSavedMe
  16. fi
  17. # Remove Tor and everything to do with it
  18. if [ -f $TORPATH/uninstall_tor_bundle.sh ]; then
  19. $TORPATH/uninstall_tor_bundle.sh
  20. echo "You made it to the uninstaller"
  21. else
  22. $PACKAGE_PATH/Contents/Resources/uninstall_tor_bundle.sh
  23. fi
  24. # This is complete, we have a fresh system on which to install Tor