tor.sh.in 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2006-2007 Andrew Lewman
  4. #
  5. # tor The Onion Router
  6. #
  7. # Startup/shutdown script for tor. This is a wrapper around torctl;
  8. # torctl does the actual work in a relatively system-independent, or at least
  9. # distribution-independent, way, and this script deals with fitting the
  10. # whole thing into the conventions of the particular system at hand.
  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. ### BEGIN INIT INFO
  19. # Provides: tor
  20. # Required-Start: $remote_fs $network
  21. # Required-Stop: $remote_fs $network
  22. # Default-Start: 3 5
  23. # Default-Stop: 0 1 2 6
  24. # Short-Description: Start the tor daemon
  25. # Description: Start the tor daemon: the anon-proxy server
  26. ### END INIT INFO
  27. . /etc/rc.status
  28. # Shell functions sourced from /etc/rc.status:
  29. # rc_check check and set local and overall rc status
  30. # rc_status check and set local and overall rc status
  31. # rc_status -v ditto but be verbose in local rc status
  32. # rc_status -v -r ditto and clear the local rc status
  33. # rc_failed set local and overall rc status to failed
  34. # rc_reset clear local rc status (overall remains)
  35. # rc_exit exit appropriate to overall rc status
  36. # First reset status of this service
  37. rc_reset
  38. # Increase open file descriptors a reasonable amount
  39. ulimit -n 8192
  40. TORCTL=@BINDIR@/torctl
  41. # torctl will use these environment variables
  42. TORUSER=@TORUSER@
  43. export TORUSER
  44. TORGROUP=@TORGROUP@
  45. export TORGROUP
  46. if [ -x /bin/su ] ; then
  47. SUPROG=/bin/su
  48. elif [ -x /sbin/su ] ; then
  49. SUPROG=/sbin/su
  50. elif [ -x /usr/bin/su ] ; then
  51. SUPROG=/usr/bin/su
  52. elif [ -x /usr/sbin/su ] ; then
  53. SUPROG=/usr/sbin/su
  54. else
  55. SUPROG=/bin/su
  56. fi
  57. case "$1" in
  58. start)
  59. echo "Starting tor daemon"
  60. ## Start daemon with startproc(8). If this fails
  61. ## the echo return value is set appropriate.
  62. startproc -f $TORCTL start
  63. # Remember status and be verbose
  64. rc_status -v
  65. ;;
  66. stop)
  67. echo "Stopping tor daemon"
  68. startproc -f $TORCTL stop
  69. # Remember status and be verbose
  70. rc_status -v
  71. ;;
  72. restart)
  73. echo "Restarting tor daemon"
  74. startproc -f $TORCTL restart
  75. # Remember status and be verbose
  76. rc_status -v
  77. ;;
  78. reload)
  79. echo "Reloading tor daemon"
  80. startproc -f $TORCTL reload
  81. # Remember status and be verbose
  82. rc_status -v
  83. ;;
  84. status)
  85. startproc -f $TORCTL status
  86. # Remember status and be verbose
  87. rc_status -v
  88. ;;
  89. *)
  90. echo "Usage: $0 (start|stop|restart|reload|status)"
  91. RETVAL=1
  92. esac
  93. rc_exit