2005-01-05 03:46:25 +01:00
|
|
|
#!/bin/sh
|
2007-10-28 05:46:26 +01:00
|
|
|
# ====================================================================
|
2007-10-28 05:52:38 +01:00
|
|
|
# TorPostFlight is distributed under this license
|
2007-10-28 05:46:26 +01:00
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Andrew Lewman
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
#
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following disclaimer
|
|
|
|
# in the documentation and/or other materials provided with the
|
|
|
|
# distribution.
|
|
|
|
#
|
|
|
|
# * Neither the names of the copyright owners nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived from
|
|
|
|
# this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
# ======================================================================
|
2005-01-05 03:46:25 +01:00
|
|
|
|
|
|
|
# TorPostflight gets invoked after any install or upgrade.
|
|
|
|
|
|
|
|
ADDSYSUSER=$RECEIPT_PATH/addsysuser
|
|
|
|
if [ ! -x "$ADDSYSUSER" ]; then
|
|
|
|
echo "Could not find addsysuser script."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
TORUSER=_tor
|
|
|
|
TORGROUP=daemon
|
2005-03-18 21:59:14 +01:00
|
|
|
TARGET=$2/Library/Tor
|
|
|
|
TORDIR=$TARGET/var/lib/tor
|
2007-03-12 00:59:37 +01:00
|
|
|
LOGFILE=/var/log/tor.log
|
2008-05-29 02:14:37 +02:00
|
|
|
TORBUTTON_VERSION="1.1.18-alpha"
|
2005-01-05 03:46:25 +01:00
|
|
|
|
2006-05-16 07:48:08 +02:00
|
|
|
# Check defaults for TARGET
|
|
|
|
if [ "$TARGET" == "//Library/Tor" ]; then
|
|
|
|
TARGET=/Library/Tor
|
|
|
|
fi
|
|
|
|
|
2005-01-05 03:46:25 +01:00
|
|
|
# Create user $TORUSER in group daemon. If it's already there, great.
|
|
|
|
$ADDSYSUSER $TORUSER "Tor System user" $TORDIR
|
|
|
|
|
|
|
|
# Create the tor directory, if it doesn't exist.
|
|
|
|
if [ ! -d $TORDIR ]; then
|
|
|
|
mkdir -p $TORDIR
|
|
|
|
fi
|
|
|
|
# Check its permissions.
|
|
|
|
chown $TORUSER $TORDIR
|
|
|
|
chgrp daemon $TORDIR
|
|
|
|
chmod 700 $TORDIR
|
2007-04-11 02:42:49 +02:00
|
|
|
|
|
|
|
if [ ! -f $LOGFILE ]; then
|
|
|
|
touch $LOGFILE
|
|
|
|
chown $TORUSER $LOGFILE
|
|
|
|
chgrp daemon $LOGFILE
|
|
|
|
chmod 660 $LOGFILE
|
|
|
|
fi
|
2005-01-05 03:46:25 +01:00
|
|
|
|
2006-07-21 06:30:19 +02:00
|
|
|
# Create the configuration file only if there wasn't one already.
|
2005-03-18 21:59:14 +01:00
|
|
|
if [ ! -f $TARGET/torrc ]; then
|
2007-10-15 06:04:16 +02:00
|
|
|
cp $TARGET/torrc.sample $TARGET/torrc
|
2005-03-18 21:59:14 +01:00
|
|
|
fi
|
|
|
|
|
2008-05-29 02:14:37 +02:00
|
|
|
# Put the geoip database into the datadir
|
|
|
|
if [ ! -f $TORDIR/geoip ]; then
|
|
|
|
cp $PACKAGE_PATH/Contents/Resources/geoip $TORDIR/geoip
|
|
|
|
fi
|
|
|
|
|
2005-03-18 21:59:14 +01:00
|
|
|
# Ensure symbolic links
|
2005-01-05 03:46:25 +01:00
|
|
|
cd /usr/bin
|
|
|
|
if [ -e /usr/bin/tor -a ! -L /usr/bin/tor ]; then
|
|
|
|
mv tor tor_old
|
|
|
|
fi
|
|
|
|
if [ -e /usr/bin/tor-resolve -a ! -L /usr/bin/tor-resolve ]; then
|
|
|
|
mv tor-resolve tor-resolve_old
|
|
|
|
fi
|
2005-03-18 21:59:14 +01:00
|
|
|
ln -sf $TARGET/tor .
|
2006-01-10 19:43:10 +01:00
|
|
|
ln -sf $TARGET/tor-resolve .
|
2005-03-18 21:59:14 +01:00
|
|
|
|
|
|
|
cd /usr/share/man/man1
|
2007-12-06 19:46:59 +01:00
|
|
|
MAN1=$TARGET/share/man/man1
|
|
|
|
#ln -sf $MAN1/*.1 .
|
2005-03-18 22:45:36 +01:00
|
|
|
|
2005-05-17 07:26:54 +02:00
|
|
|
if [ -d /Library/StartupItems/Privoxy ]; then
|
|
|
|
find /Library/StartupItems/Privoxy -print0 | xargs -0 chown root:wheel
|
|
|
|
fi
|
2006-03-11 06:23:18 +01:00
|
|
|
|
|
|
|
# Copy Documentation
|
2006-03-11 07:13:08 +01:00
|
|
|
if [ -d $PACKAGE_PATH/Contents/Resources/documents ];then
|
|
|
|
cp -r $PACKAGE_PATH/Contents/Resources/documents $TARGET/documents
|
|
|
|
fi
|
2006-03-11 06:23:18 +01:00
|
|
|
|
|
|
|
# Copy Uninstaller
|
2006-03-11 07:13:08 +01:00
|
|
|
if [ -f $PACKAGE_PATH/Contents/Resources/Tor_Uninstaller.applescript ]; then
|
|
|
|
cp $PACKAGE_PATH/Contents/Resources/Tor_Uninstaller.applescript $TARGET/Tor_Uninstaller.applescript
|
2007-10-15 06:04:16 +02:00
|
|
|
chmod 550 $TARGET/Tor_Uninstaller.applescript
|
2006-03-11 07:13:08 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $PACKAGE_PATH/Contents/Resources/uninstall_tor_bundle.sh ]; then
|
|
|
|
cp $PACKAGE_PATH/Contents/Resources/uninstall_tor_bundle.sh $TARGET/uninstall_tor_bundle.sh
|
2007-10-15 06:04:16 +02:00
|
|
|
chmod 550 $TARGET/uninstall_tor_bundle.sh
|
2006-03-11 07:13:08 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $PACKAGE_PATH/Contents/Resources/package_list.txt ]; then
|
|
|
|
cp $PACKAGE_PATH/Contents/Resources/package_list.txt $TARGET/package_list.txt
|
|
|
|
fi
|
2006-07-16 15:58:10 +02:00
|
|
|
|
2006-07-28 15:52:36 +02:00
|
|
|
if [ -d /Library/StartupItems/Tor ]; then
|
|
|
|
rm -f /Library/StartupItems/Tor/Tor.loc
|
|
|
|
echo "$TARGET" > /Library/StartupItems/Tor/Tor.loc
|
2006-07-16 15:58:10 +02:00
|
|
|
fi
|
2007-10-15 06:04:16 +02:00
|
|
|
|
2008-05-29 02:14:37 +02:00
|
|
|
# This only works if the user installing us is an Admin user.
|
|
|
|
# Otherwise, this will silently fail to install torbutton in firefox.
|
2007-10-15 06:04:16 +02:00
|
|
|
if [ -f /Applications/Firefox.app/Contents/MacOS/firefox ]; then
|
2008-04-15 22:18:32 +02:00
|
|
|
if [ -f /Library/Torbutton/torbutton-$TORBUTTON_VERSION.xpi ]; then
|
2008-03-30 01:40:09 +01:00
|
|
|
# Open firefox with a prompt to install the torbutton xpi
|
2008-04-15 22:18:32 +02:00
|
|
|
su $USER open -a /Applications/Firefox.app /Library/Torbutton/torbutton-$TORBUTTON_VERSION.xpi
|
2007-10-15 06:04:16 +02:00
|
|
|
fi
|
|
|
|
fi
|