tor.init 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #! /bin/sh
  2. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  3. DAEMON=/usr/bin/tor
  4. NAME=tor
  5. DESC="tor daemon"
  6. TORLOG=/var/log/tor/log
  7. TORPID=/var/run/tor/tor.pid
  8. ARGS="--pidfile $TORPID --logfile $TORLOG --runasdaemon 1"
  9. test -x $DAEMON || exit 0
  10. # Include tor defaults if available
  11. if [ -f /etc/default/tor ] ; then
  12. . /etc/default/tor
  13. fi
  14. set -e
  15. case "$1" in
  16. start)
  17. if [ "$RUN_DAEMON" != "yes" ]; then
  18. echo "Not starting $DESC (Disabled in /etc/default/tor)."
  19. else
  20. echo -n "Starting $DESC: "
  21. start-stop-daemon --start --quiet --oknodo \
  22. --chuid debian-tor:debian-tor \
  23. --pidfile $TORPID \
  24. --exec $DAEMON -- $ARGS
  25. echo "$NAME."
  26. fi
  27. ;;
  28. stop)
  29. echo -n "Stopping $DESC: "
  30. start-stop-daemon --stop --quiet --oknodo --pidfile $TORPID \
  31. --exec $DAEMON
  32. echo "$NAME."
  33. ;;
  34. reload|force-reload)
  35. echo "Reloading $DESC configuration."
  36. start-stop-daemon --stop --signal 1 --oknodo --quiet --pidfile $TORPID \
  37. --exec $DAEMON
  38. ;;
  39. restart)
  40. $0 stop
  41. sleep 1
  42. $0 start
  43. ;;
  44. *)
  45. echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
  46. exit 1
  47. ;;
  48. esac
  49. exit 0