2 # ====================================================================
3 # TorPostFlight is distributed under this license
5 # Copyright (c) 2006 Andrew Lewman
6 # Copyright (c) 2008 The Tor Project
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are
12 # * Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
15 # * Redistributions in binary form must reproduce the above
16 # copyright notice, this list of conditions and the following disclaimer
17 # in the documentation and/or other materials provided with the
20 # * Neither the names of the copyright owners nor the names of its
21 # contributors may be used to endorse or promote products derived from
22 # this software without specific prior written permission.
24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 # ======================================================================
37 # TorPostflight gets invoked after any install or upgrade.
39 ADDSYSUSER
=$RECEIPT_PATH/addsysuser
40 if [ ! -x "$ADDSYSUSER" ]; then
41 echo "Could not find addsysuser script."
48 TORDIR
=$TARGET/var
/lib
/tor
49 LOGFILE
=/var
/log
/tor.log
51 # Check defaults for TARGET
52 if [ "$TARGET" == "//Library/Tor" ]; then
56 # Create user $TORUSER in group daemon. If it's already there, great.
57 $ADDSYSUSER $TORUSER "Tor System user" $TORDIR
59 # Create the tor directory, if it doesn't exist.
60 if [ ! -d $TORDIR ]; then
63 # Check its permissions.
64 chown
$TORUSER $TORDIR
68 if [ ! -f $LOGFILE ]; then
70 chown
$TORUSER $LOGFILE
75 # Create the configuration file only if there wasn't one already.
76 if [ ! -f $TARGET/torrc
]; then
77 cp $TARGET/torrc.sample
$TARGET/torrc
80 # Put the geoip database into the datadir
81 if [ ! -f $TORDIR/geoip
]; then
82 cp $PACKAGE_PATH/Contents
/Resources
/geoip
$TORDIR/geoip
85 # Ensure symbolic links
87 if [ -e /usr
/bin
/tor
-a ! -L /usr
/bin
/tor
]; then
90 if [ -e /usr
/bin
/tor-resolve
-a ! -L /usr
/bin
/tor-resolve
]; then
91 mv tor-resolve tor-resolve_old
94 ln -sf $TARGET/tor-resolve .
96 cd /usr
/share
/man
/man1
97 MAN1
=$TARGET/share
/man
/man1
101 if [ -d $PACKAGE_PATH/Contents
/Resources
/documents
];then
102 cp -r $PACKAGE_PATH/Contents
/Resources
/documents
$TARGET/documents
106 if [ -f $PACKAGE_PATH/Contents
/Resources
/Tor_Uninstaller.applescript
]; then
107 cp $PACKAGE_PATH/Contents
/Resources
/Tor_Uninstaller.applescript
$TARGET/Tor_Uninstaller.applescript
108 chmod 550 $TARGET/Tor_Uninstaller.applescript
111 if [ -f $PACKAGE_PATH/Contents
/Resources
/uninstall_tor_bundle.sh
]; then
112 cp $PACKAGE_PATH/Contents
/Resources
/uninstall_tor_bundle.sh
$TARGET/uninstall_tor_bundle.sh
113 chmod 550 $TARGET/uninstall_tor_bundle.sh
116 if [ -f $PACKAGE_PATH/Contents
/Resources
/package_list.txt
]; then
117 cp $PACKAGE_PATH/Contents
/Resources
/package_list.txt
$TARGET/package_list.txt
120 if [ -d /Library
/StartupItems
/Tor
]; then
121 rm -f /Library
/StartupItems
/Tor
/Tor.loc
122 echo "$TARGET" > /Library
/StartupItems
/Tor
/Tor.loc