123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- #!/bin/sh
- PACKAGE_LIST_SRC=./package_list.txt
- TOR_USER=_tor
- STARTUP_ITEMS_DIR=/Library/StartupItems
- PKG_RCPT_BASE_DIR=/Library/Receipts
- BOM_INTERMEDIATE_DIR=Contents/Resources
- INFO_INTERMEDIATE_DIR=$BOM_INTERMEDIATE_DIR/English.lproj
- TEMP_BOM_CONTENTS=/tmp/tor_uninst_scratch
- if [ "`whoami`" != "root" ]; then
- echo "Must be root to run the uninstall script."
- exit -1
- fi
- TOR_PID=`ps -uax | grep 'Tor/tor ' | grep -v grep | awk '{print $2;}'`
- if [ ${#TOR_PID} -gt 0 ]; then
- echo ". Killing currently running tor process, pid is $TOR_PID"
- kill -9 $TOR_PID
- else
- echo ". tor process appears to already be stopped"
- fi
- PRIVOXY_PID=`ps -uax | grep privoxy | grep -v grep | awk '{print $2;}'`
- if [ ${#PRIVOXY_PID} -gt 0 ]; then
- echo ". Killing currently running privoxy process, pid is $PRIVOXY_PID"
- kill -9 $PRIVOXY_PID
- else
- echo ". privoxy process appears to already be stopped"
- fi
- while read LINE; do
- if [ ${#LINE} -gt 0 ]; then
- PACKAGE_NAME=$LINE.pkg
- PACKAGE_PATH=$PKG_RCPT_BASE_DIR/$PACKAGE_NAME
- echo ". Uninstalling $PACKAGE_NAME"
- if [ ! -d $PACKAGE_PATH ]; then
- echo " . No receipt exists for this package -- skipping."
- continue
- fi
-
-
- STARTUP_DIR=$STARTUP_ITEMS_DIR/$LINE
- if [ -d $STARTUP_DIR ]; then
- echo " . Deleting startup item $STARTUP_DIR"
- rm -rf $STARTUP_DIR
- fi
-
- DEFAULT_LOC=`grep DefaultLocation $PACKAGE_PATH/$INFO_INTERMEDIATE_DIR/$LINE.info | awk '{print $2;}'`
- if [ ${#DEFAULT_LOC} -eq 0 ]; then
- echo "!! Could not find default location for $LINE package -- skipping package."
- continue
- fi
-
- BOM_FILE=$PACKAGE_PATH/$BOM_INTERMEDIATE_DIR/$LINE.bom
- lsbom $BOM_FILE > $TEMP_BOM_CONTENTS
- while read BOM_ITEM; do
-
- COL_COUNT=$(echo $BOM_ITEM | awk '{print NF;}')
- if [ "$COL_COUNT" -eq 5 ]; then
- FILE_NAME=$DEFAULT_LOC/$(echo $BOM_ITEM | awk '{print $1;}')
- echo " . Removing $FILE_NAME"
- rm -rf $FILE_NAME
- fi
- done < $TEMP_BOM_CONTENTS
-
- echo " . Removing package receipt $PACKAGE_PATH"
- rm -rf $PACKAGE_PATH
- fi
- done < $PACKAGE_LIST_SRC
- echo ". Removing created user $TOR_USER"
- if [ -x /usr/bin/dscl ]; then
- dscl . -delete /users/$TOR_USER
- else
- niutil -destroy . /users/$TOR_USER
- fi
- echo ". Cleaning up"
- rm -rf $TEMP_BOM_CONTENTS
- rm -rf /Library/Privoxy/ /Library/StartupItems/Privoxy/ /Library/Tor/ /Library/StartupItems/Tor/ /Library/Torbutton/
- echo ". Finished"
|