#!/bin/sh # File : uninstall.command # # Purpose : Remove the Privoxy application and (optionally) its # configuration files from the target system # # Copyright : Written by and Copyright (C) 2001-2012 the # Privoxy team. http://www.privoxy.org/ # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software # Foundation; either version 2 of the License, or (at # your option) any later version. # # This program is distributed in the hope that it will # be useful, but WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. See the GNU General Public # License for more details. # # The GNU General Public License should be included with # this file. If not, you can view it at # http://www.gnu.org/copyleft/gpl.html # or write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA # # Modification : If you modify this file please consider whether your # changes ought to be passed back to the macsetup module. # root_UID=0 # Root has $UID 0. if [ "$UID" -eq "$root_UID" ]; then echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! echo 'About to remove the Privoxy application. Are you sure? (Y/N)' echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! read ANSWER if (test z$ANSWER = zY) || (test z$ANSWER = zy) then echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! echo 'Last chance. Removing Privoxy... Are you sure? (Y/N)' echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! read ANSWER if (test z$ANSWER = zY) || (test z$ANSWER = zy) then echo Stopping Privoxy. kill `ps -ax | grep /privoxy | grep -v grep | awk '{ print $1 }'` 2> /dev/null # Remove items common to all OS X versions echo Deleting Privoxy and its documentation # Delete binary rm -f /usr/local/sbin/privoxy # Delete documention rm -rf /usr/local/share/doc/privoxy # Delete manpage rm -f /usr/local/share/man/man1/privoxy.1 # Optionally delete config files echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! echo 'Delete configuration files? (Y/N)' echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! read ANSWER if (test z$ANSWER = zY) || (test z$ANSWER = zy) then rm -rf /usr/local/etc/privoxy fi # Delete log files rm -rf /var/log/privoxy # Delete folder from /Applications rm -rf /Applications/Privoxy # Delete all items referenced by the installation package echo 'Delete package installation receipt (ignore errors relating to other bundle identifiers).' # On OS X 10.5 or newer we can use the new pkgutil command else simply delete the receipt file if [ -x /usr/sbin/pkgutil ]; then pkgutil --forget org.ijbswa.privoxyPRIVOXY_VERSION.pkg else rm -rf /Library/Receipts/Privoxy\ PRIVOXY_VERSION\ OS\ X\ 10.4.pkg fi # Check the Trash, just in case the user manually removed the only obvious item from /Applications if [ -d ~/.Trash/Privoxy ]; then echo Removing Privoxy from the trash. rm -rf ~/.Trash/Privoxy fi # Delete host-dependent items - first ascertain OS X version darwin_major_rel_num="`/usr/bin/uname -r | /usr/bin/sed 's/\..*//'`" case "${darwin_major_rel_num}" in # Mac OS X 10.5 or higher 9|1*) # Delete Privoxy LaunchDaemon echo 'Delete Privoxy LaunchDaemon (an error will be thrown regarding "no such process")' /bin/launchctl unload /Library/LaunchDaemons/org.ijbswa.privoxy.plist /bin/launchctl remove /Library/LaunchDaemons/org.ijbswa.privoxy.plist rm -f /Library/LaunchDaemons/org.ijbswa.privoxy.plist # The installer might have disabled a previous Privoxy LaunchDaemon rm -rf /Library/LaunchDaemons/Disabled/org.ijbswa.privoxy.plist # There might have previously been a StartupItem installed rm -rf /Library/StartupItems/Privoxy # There might have previously been a disabled Privoxy StartupItem rm -rf /Library/StartupItems/Disabled/Privoxy # Remove user and group echo Removing privoxy user and group dscl /Local/Default -delete /Users/_privoxy dscl /Local/Default -delete /Groups/_privoxy ;; # Mac OS X 10.4, 10.3 8|7) # Delete Privoxy StartupItem echo Delete Privoxy StartupItem rm -rf /Library/StartupItems/Privoxy # The installer might have disabled a previous Privoxy StartupItem rm -rf /Library/StartupItems/Disabled/Privoxy # Remove user and group echo Removing privoxy user and group niutil -destroy / /groups/privoxy niutil -destroy / /users/privoxy ;; # default *) ;; esac # Despite the various errors that may have been thrown, give the user a good feeling! echo echo Uninstallation complete. else echo Uninstall aborted. fi else echo Uninstall aborted. fi else echo echo This script requires administrator privileges. echo "Please run it from Terminal, using an administrator account, as follows:" echo echo "sudo /Applications/Privoxy/uninstall.command" echo fi exit 0