tor.sh.in 2.6 KB

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