rc.subr 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. # $Id$
  3. # $FreeBSD: ports/security/tor-devel/files/tor.in,v 1.1 2006/02/17 22:21:25 mnag Exp $
  4. #
  5. # (rc.subr written by Peter Thoenen for Net/FreeBSD)
  6. #
  7. # REQUIRE: NETWORKING SERVERS USR
  8. # BEFORE: LOGIN
  9. #
  10. # Add the following lines to /etc/rc.conf to enable tor
  11. #
  12. # tor_enable (bool): Set to "NO" by default
  13. # Set it to "YES" to enable tor
  14. # tor_conf (str): Points to your tor conf file
  15. # Default: /usr/local/etc/tor/torrc
  16. # tor_user (str): Tor Daemon user. Default _tor
  17. # tor_groupr (str): Tor Daemon group. Default _tor
  18. #
  19. . /etc/rc.subr
  20. name="tor"
  21. rcvar=${name}_enable
  22. load_rc_config ${name}
  23. : ${tor_enable="NO"}
  24. : ${tor_conf="/usr/local/etc/tor/torrc"}
  25. : ${tor_user="_tor"}
  26. : ${tor_group="_tor"}
  27. : ${tor_pidfile="/var/run/tor/tor.pid"}
  28. : ${tor_logfile="/var/log/tor"}
  29. : ${tor_datadir="/var/run/tor"}
  30. required_files=${tor_conf}
  31. required_dirs=${tor_datadir}
  32. command="/usr/local/bin/${name}"
  33. command_args="-f ${tor_conf} --pidfile ${tor_pidfile} --runasdaemon 1 --datadirectory ${tor_datadir} --user ${tor_user} --group ${tor_group}"
  34. extra_commands="log"
  35. log_cmd="${name}_log"
  36. tor_log() {
  37. cat ${tor_logfile}
  38. }
  39. run_rc_command "$1"