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
|
|
|
|
|
|
|
# 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
|
|
|
|
2005-03-18 21:59:14 +01:00
|
|
|
# Create the configuration file only if there wan't one already.
|
|
|
|
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-06-07 20:21:32 +02:00
|
|
|
if [ -d /Library/StartupItems/Tor ]; then
|
|
|
|
rm -f /Library/StartupItems/Tor/Tor.loc
|
|
|
|
echo "$TARGET" > /Library/StartupItems/Tor/Tor.loc
|
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
|
|
|
|
cp -r $PACKAGE_PATH/Contents/Resources/documents $TARGET/documents
|
|
|
|
|
|
|
|
# Copy Uninstaller
|
|
|
|
cp -r $PACKAGE_PATH/Contents/Resources/*ninstall* $TARGET/
|