tor.sh.in 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #
  10. # These next couple of lines "declare" tor for the "chkconfig" program,
  11. # originally from SGI, used on Red Hat/Fedora and probably elsewhere.
  12. #
  13. # chkconfig: 2345 90 10
  14. # description: Onion Router - A low-latency anonymous proxy
  15. #
  16. ### BEGIN INIT INFO
  17. # Provides: tor
  18. # Required-Start: $remote_fs $network
  19. # Required-Stop: $remote_fs $network
  20. # Default-Start: 3 5
  21. # Default-Stop: 0 1 2 6
  22. # Short-Description: Start the tor daemon
  23. # Description: Start the tor daemon: the anon-proxy server
  24. ### END INIT INFO
  25. . /etc/rc.status
  26. # Shell functions sourced from /etc/rc.status:
  27. # rc_check check and set local and overall rc status
  28. # rc_status check and set local and overall rc status
  29. # rc_status -v ditto but be verbose in local rc status
  30. # rc_status -v -r ditto and clear the local rc status
  31. # rc_failed set local and overall rc status to failed
  32. # rc_reset clear local rc status (overall remains)
  33. # rc_exit exit appropriate to overall rc status
  34. # First reset status of this service
  35. rc_reset
  36. # Increase open file descriptors a reasonable amount
  37. ulimit -n 8192
  38. TORCTL=@BINDIR@/torctl
  39. # torctl will use these environment variables
  40. TORUSER=@TORUSER@
  41. export TORUSER
  42. TORGROUP=@TORGROUP@
  43. export TORGROUP
  44. if [ -x /bin/su ] ; then
  45. SUPROG=/bin/su
  46. elif [ -x /sbin/su ] ; then
  47. SUPROG=/sbin/su
  48. elif [ -x /usr/bin/su ] ; then
  49. SUPROG=/usr/bin/su
  50. elif [ -x /usr/sbin/su ] ; then
  51. SUPROG=/usr/sbin/su
  52. else
  53. SUPROG=/bin/su
  54. fi
  55. case "$1" in
  56. start)
  57. echo "Starting tor daemon"
  58. ## Start daemon with startproc(8). If this fails
  59. ## the echo return value is set appropriate.
  60. startproc -f $TORCTL start
  61. # Remember status and be verbose
  62. rc_status -v
  63. ;;
  64. stop)
  65. echo "Stopping tor daemon"
  66. startproc -f $TORCTL stop
  67. # Remember status and be verbose
  68. rc_status -v
  69. ;;
  70. restart)
  71. echo "Restarting tor daemon"
  72. startproc -f $TORCTL restart
  73. # Remember status and be verbose
  74. rc_status -v
  75. ;;
  76. reload)
  77. echo "Reloading tor daemon"
  78. startproc -f $TORCTL reload
  79. # Remember status and be verbose
  80. rc_status -v
  81. ;;
  82. status)
  83. startproc -f $TORCTL status
  84. # Remember status and be verbose
  85. rc_status -v
  86. ;;
  87. *)
  88. echo "Usage: $0 (start|stop|restart|reload|status)"
  89. RETVAL=1
  90. esac
  91. rc_exit