Change the way Tor starts on OSX 10.4 vs pre-10.4. 10.4 Tor now uses

launchd for current and forward compatibility.


svn:r6766
This commit is contained in:
Andrew Lewman 2006-07-16 13:58:10 +00:00
parent 886b10bbe2
commit 1478636f54
6 changed files with 55 additions and 12 deletions

View File

@ -5,3 +5,4 @@ TorBundleInfo.plist
TorDesc.plist
TorInfo.plist
TorStartupDesc.plist
net.freehaven.tor.plist

View File

@ -6,4 +6,5 @@ EXTRA_DIST = PrivoxyConfDesc.plist PrivoxyConfInfo.plist \
TorInfo.plist.in TorStartupDesc.plist.in TorStartupInfo.plist \
package.sh privoxy.config TorPostflight addsysuser \
Tor_Uninstaller.applescript uninstall_tor_bundle.sh \
package_list.txt tor_logo.gif Tor_Uninstaller.app.tar.gz
package_list.txt tor_logo.gif Tor_Uninstaller.app.tar.gz \
net.freehaven.tor.plist.in

View File

@ -19,6 +19,25 @@ if [ "$TARGET" == "//Library/Tor" ]; then
TARGET=/Library/Tor
fi
## 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
# Create user $TORUSER in group daemon. If it's already there, great.
$ADDSYSUSER $TORUSER "Tor System user" $TORDIR
@ -88,6 +107,7 @@ if [ -f $PACKAGE_PATH/Contents/Resources/Tor_Uninstaller.app.tar.gz ]; then
cd $TARGET && tar zxf Tor_Uninstaller.app.tar.gz
chmod -R 755 $TARGET/Tor_Uninstaller.app
chown -R _tor:_tor Tor_Uninstaller.app
rm $TARGET/Tor_Uninstaller.app.tar.gz
fi
if [ -f $PACKAGE_PATH/Contents/Resources/uninstall_tor_bundle.sh ]; then
@ -98,3 +118,14 @@ fi
if [ -f $PACKAGE_PATH/Contents/Resources/package_list.txt ]; then
cp $PACKAGE_PATH/Contents/Resources/package_list.txt $TARGET/package_list.txt
fi
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
fi
else
if [ -d /Library/StartupItems/Tor ]; then
rm -f /Library/StartupItems/Tor/Tor.loc
echo "$TARGET" > /Library/StartupItems/Tor/Tor.loc
fi
fi

View File

@ -31,7 +31,6 @@
<key>LowPriorityIO</key>
<true/>
<!--
<key>HardResourceLimits</key>
<dict>
<key>Core</key>
@ -61,7 +60,7 @@
<key>Stack</key>
<integer>10000000000</integer>
</dict>
-->
<key>Bonjour</key>
<false/>

View File

@ -82,6 +82,9 @@ cp contrib/osx/Tor_Uninstaller.app.tar.gz $BUILD_DIR/tor_resources/Tor_Uninstall
cp contrib/osx/uninstall_tor_bundle.sh $BUILD_DIR/tor_resources/uninstall_tor_bundle.sh
cp contrib/osx/package_list.txt $BUILD_DIR/tor_resources/package_list.txt
cp contrib/osx/tor_logo.gif $BUILD_DIR/tor_resources/background.gif
if [ $OS = "tiger" OR $OS = "leopard" ]; then
cp contrib/osx/net.freehaven.tor.plist $BUILD_DIR/tor_resources/net.freehaven.tor.plist
fi
cat <<EOF > $BUILD_DIR/tor_resources/Welcome.txt
Tor: an anonymous Internet communication system
@ -130,17 +133,22 @@ $PACKAGEMAKER -build \
-d contrib/osx/PrivoxyConfDesc.plist
### Make Startup Script package
# If Tiger or later, use launchd. Otherwise, use StartupItems
mkdir -p $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
cp contrib/osx/Tor contrib/osx/StartupParameters.plist \
if [ $OS = "tiger" ]; then
cp contrib/osx/net.freehaven.tor.plist $BUILD_DIR/tor_resources/net.freehaven.tor.plist
else
mkdir -p $BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
cp contrib/osx/Tor contrib/osx/StartupParameters.plist \
$BUILD_DIR/torstartup_packageroot/Library/StartupItems/Tor
find $BUILD_DIR/torstartup_packageroot -print0 | sudo xargs -0 chown root:wheel
$PACKAGEMAKER -build \
find $BUILD_DIR/torstartup_packageroot -print0 | sudo xargs -0 chown root:wheel
$PACKAGEMAKER -build \
-p $BUILD_DIR/output/torstartup.pkg \
-f $BUILD_DIR/torstartup_packageroot \
-i contrib/osx/TorStartupInfo.plist \
-d contrib/osx/TorStartupDesc.plist
fi
### Assemble the metapackage. Packagemaker won't buld metapackages from
# the command line, so we need to do it by hand.

View File

@ -134,7 +134,10 @@ niutil -destroy . /users/$TOR_USER
## clean up
echo ". Cleaning up"
rm -rf $TEMP_BOM_CONTENTS
rm -rf /Library/Privoxy/ /Library/StartupItems/Tor/ /Library/StartupItems/Privoxy/ /Library/Tor/
rm -rf /Library/Privoxy/ /Library/StartupItems/Privoxy/ /Library/Tor/ /Library/StartupItems/Tor/
if [ -f /System/Library/LaunchDaemons/net.freehaven.tor.plist ]; then
rm /System/Library/LaunchDaemons/net.freehaven.tor.plist
fi
echo ". Finished"