2005-01-05 03:46:25 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# 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
|
2005-03-18 22:45:36 +01:00
|
|
|
LOGDIR=$TARGET/var/log/tor
|
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
|
|
|
|
|
2006-07-16 15:58:10 +02:00
|
|
|
## Determine OSX Version
|
|
|
|
# map version to name
|
|
|
|
if [ -x /usr/bin/sw_vers ]; then
|
|
|
|
# This is poor, yet functional. We don't care about the 3rd number in
|
|
|
|
# the OS version
|
|
|
|
OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2`
|
|
|
|
case "$OSVER" in
|
|
|
|
"10.5") OS="leopard";;
|
|
|
|
"10.4") OS="tiger";;
|
|
|
|
"10.3") OS="panther";;
|
|
|
|
"10.2") OS="jaguar";;
|
|
|
|
"10.1") OS="puma";;
|
|
|
|
"10.0") OS="cheetah";;
|
|
|
|
*) OS="unknown";;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
OS="unknown"
|
|
|
|
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
|
2005-03-18 22:45:36 +01:00
|
|
|
if [ ! -d $LOGDIR ]; then
|
|
|
|
mkdir -p $LOGDIR
|
|
|
|
fi
|
2005-01-05 03:46:25 +01:00
|
|
|
# Check its permissions.
|
|
|
|
chown $TORUSER $TORDIR
|
|
|
|
chgrp daemon $TORDIR
|
|
|
|
chmod 700 $TORDIR
|
2005-03-18 22:45:36 +01:00
|
|
|
chown $TORUSER $LOGDIR
|
|
|
|
chgrp daemon $LOGDIR
|
|
|
|
chmod 700 $LOGDIR
|
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
|
|
|
|
cp $TARGET/torrc.sample $TARGET/torrc
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 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
|
|
|
|
MAN1=$TARGET/man/man1
|
|
|
|
ln -sf $MAN1/*.1 .
|
2005-03-18 22:45:36 +01:00
|
|
|
|
|
|
|
if [ ! -e /var/log/tor -o -L /var/log/tor ]; then
|
|
|
|
cd /var/log
|
|
|
|
rm -f tor
|
|
|
|
ln -sf $LOGDIR tor
|
2005-03-18 23:43:46 +01:00
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
chmod 755 $TARGET/Tor_Uninstaller.applescript
|
|
|
|
fi
|
|
|
|
|
2006-07-07 02:55:12 +02:00
|
|
|
if [ -f $PACKAGE_PATH/Contents/Resources/Tor_Uninstaller.app.tar.gz ]; then
|
|
|
|
cp $PACKAGE_PATH/Contents/Resources/Tor_Uninstaller.app.tar.gz $TARGET/Tor_Uninstaller.app.tar.gz
|
|
|
|
cd $TARGET && tar zxf Tor_Uninstaller.app.tar.gz
|
|
|
|
chmod -R 755 $TARGET/Tor_Uninstaller.app
|
|
|
|
chown -R _tor:_tor Tor_Uninstaller.app
|
2006-07-16 15:58:10 +02:00
|
|
|
rm $TARGET/Tor_Uninstaller.app.tar.gz
|
2006-07-07 02:55:12 +02:00
|
|
|
fi
|
|
|
|
|
2006-03-11 07:13:08 +01:00
|
|
|
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
|
|
|
|
chmod 755 $TARGET/uninstall_tor_bundle.sh
|
|
|
|
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-27 03:20:02 +02:00
|
|
|
# If the pre-install script did it's thing, it should have saved the
|
|
|
|
# config and server keys; put these back and clean up
|
|
|
|
if [ -f ~/TorSavedMe ]; then
|
|
|
|
TARBALL=`cat ~/TorSavedMe`
|
|
|
|
tar zxf $TARBALL -C /
|
|
|
|
rm ~/TorSavedMe ~/$TARBALL
|
|
|
|
fi
|
|
|
|
|
2006-07-21 06:30:19 +02:00
|
|
|
# Determine how to start by OS Version
|
2006-07-16 15:58:10 +02:00
|
|
|
if [ $OS = "tiger" ]; then
|
|
|
|
if [ -f $PACKAGE_PATH/Contents/Resources/net.freehaven.tor.plist ]; then
|
|
|
|
cp $PACKAGE_PATH/Contents/Resources/net.freehaven.tor.plist /System/Library/LaunchDaemons/net.freehaven.tor.plist
|
2006-07-17 06:31:22 +02:00
|
|
|
chmod 644 /System/Library/LaunchDaemons/net.freehaven.tor.plist
|
2006-07-23 14:52:06 +02:00
|
|
|
grep -q "#--START" $TARGET/torrc
|
|
|
|
if [ "$?" -ne "0" ]; then
|
|
|
|
echo "#--START required settings--" >> $TARGET/torrc
|
|
|
|
echo "RunAsDaemon 0" >> $TARGET/torrc
|
|
|
|
echo "Log notice file $TARGET/var/log/tor/tor.log" >> $TARGET/torrc
|
|
|
|
echo "DataDirectory $TARGET/var/lib/tor" >> $TARGET/torrc
|
|
|
|
echo "Group daemon" >> $TARGET/torrc
|
|
|
|
echo "User _tor" >> $TARGET/torrc
|
|
|
|
echo "PidFile /var/run/Tor.pid" >> $TARGET/torrc
|
|
|
|
echo "#--END required settings--" >> $TARGET/torrc
|
|
|
|
fi
|
2006-07-18 06:40:02 +02:00
|
|
|
/bin/launchctl load /System/Library/LaunchDaemons/net.freehaven.tor.plist
|
|
|
|
/bin/launchctl start net.freehaven.tor
|
2006-07-16 15:58:10 +02:00
|
|
|
else
|
|
|
|
if [ -d /Library/StartupItems/Tor ]; then
|
|
|
|
rm -f /Library/StartupItems/Tor/Tor.loc
|
|
|
|
echo "$TARGET" > /Library/StartupItems/Tor/Tor.loc
|
|
|
|
fi
|
|
|
|
fi
|