tor.sh.in 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. #
  3. # tor The Onion Router
  4. #
  5. # Startup/shutdown script for tor. This is a wrapper around torctl;
  6. # torctl does the actual work in a relatively system-independent, or at least
  7. # distribution-independent, way, and this script deals with fitting the
  8. # whole thing into the conventions of the particular system at hand.
  9. # This particular script is written for Red Hat/Fedora Linux, and may
  10. # also work on Mandrake, but not SuSE.
  11. #
  12. # These next couple of lines "declare" tor for the "chkconfig" program,
  13. # originally from SGI, used on Red Hat/Fedora and probably elsewhere.
  14. #
  15. # chkconfig: 2345 90 10
  16. # description: Onion Router - A low-latency anonymous proxy
  17. #
  18. # Library functions
  19. if [ -f /etc/rc.d/init.d/functions ]; then
  20. . /etc/rc.d/init.d/functions
  21. elif [ -f /etc/init.d/functions ]; then
  22. . /etc/init.d/functions
  23. fi
  24. # Increase open file descriptors a reasonable amount
  25. ulimit -n 8192
  26. TORCTL=@BINDIR@/torctl
  27. # torctl will use these environment variables
  28. TORUSER=@TORUSER@
  29. export TORUSER
  30. if [ -x /bin/su ] ; then
  31. SUPROG=/bin/su
  32. elif [ -x /sbin/su ] ; then
  33. SUPROG=/sbin/su
  34. elif [ -x /usr/bin/su ] ; then
  35. SUPROG=/usr/bin/su
  36. elif [ -x /usr/sbin/su ] ; then
  37. SUPROG=/usr/sbin/su
  38. else
  39. SUPROG=/bin/su
  40. fi
  41. case "$1" in
  42. start)
  43. action $"Starting tor:" $TORCTL start
  44. RETVAL=$?
  45. ;;
  46. stop)
  47. action $"Stopping tor:" $TORCTL stop
  48. RETVAL=$?
  49. ;;
  50. restart)
  51. action $"Restarting tor:" $TORCTL restart
  52. RETVAL=$?
  53. ;;
  54. reload)
  55. action $"Reloading tor:" $TORCTL reload
  56. RETVAL=$?
  57. ;;
  58. status)
  59. $TORCTL status
  60. RETVAL=$?
  61. ;;
  62. *)
  63. echo "Usage: $0 (start|stop|restart|reload|status)"
  64. RETVAL=1
  65. esac
  66. exit $RETVAL