TorPostflight 831 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. # TorPostflight gets invoked after any install or upgrade.
  3. ADDSYSUSER=$RECEIPT_PATH/addsysuser
  4. if [ ! -x "$ADDSYSUSER" ]; then
  5. echo "Could not find addsysuser script."
  6. exit 1
  7. fi
  8. TORUSER=_tor
  9. TORGROUP=daemon
  10. TORDIR=/Library/Tor/var/lib/tor
  11. # Create user $TORUSER in group daemon. If it's already there, great.
  12. $ADDSYSUSER $TORUSER "Tor System user" $TORDIR
  13. # Create the tor directory, if it doesn't exist.
  14. if [ ! -d $TORDIR ]; then
  15. mkdir -p $TORDIR
  16. fi
  17. # Check its permissions.
  18. chown $TORUSER $TORDIR
  19. chgrp daemon $TORDIR
  20. chmod 700 $TORDIR
  21. # Ensure a symbolic link.
  22. cd /usr/bin
  23. if [ -e /usr/bin/tor -a ! -L /usr/bin/tor ]; then
  24. mv tor tor_old
  25. fi
  26. if [ -e /usr/bin/tor-resolve -a ! -L /usr/bin/tor-resolve ]; then
  27. mv tor-resolve tor-resolve_old
  28. fi
  29. ln -sf /Library/Tor/tor .
  30. ln -sf /Library/Tor/tor_resolve .