tor.sh.in 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. TORGROUP=@TORGROUP@
  31. export TORGROUP
  32. if [ -x /bin/su ] ; then
  33. SUPROG=/bin/su
  34. elif [ -x /sbin/su ] ; then
  35. SUPROG=/sbin/su
  36. elif [ -x /usr/bin/su ] ; then
  37. SUPROG=/usr/bin/su
  38. elif [ -x /usr/sbin/su ] ; then
  39. SUPROG=/usr/sbin/su
  40. else
  41. SUPROG=/bin/su
  42. fi
  43. case "$1" in
  44. start)
  45. action $"Starting tor:" $TORCTL start
  46. RETVAL=$?
  47. ;;
  48. stop)
  49. action $"Stopping tor:" $TORCTL stop
  50. RETVAL=$?
  51. ;;
  52. restart)
  53. action $"Restarting tor:" $TORCTL restart
  54. RETVAL=$?
  55. ;;
  56. reload)
  57. action $"Reloading tor:" $TORCTL reload
  58. RETVAL=$?
  59. ;;
  60. status)
  61. $TORCTL status
  62. RETVAL=$?
  63. ;;
  64. *)
  65. echo "Usage: $0 (start|stop|restart|reload|status)"
  66. RETVAL=1
  67. esac
  68. exit $RETVAL