You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.1 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2006-2011 OpenWrt.org
  3. START=50
  4. STOP=50
  5. USE_PROCD=1
  6. TORRC_GEN="/tmp/torrc"
  7. handle_conf_file() {
  8. local conf_path="$1"
  9. if [ -f "$conf_path" ] || [ -d "$conf_path" ]; then
  10. echo "%include $conf_path"
  11. fi
  12. }
  13. generate_conf() {
  14. local default_conf generated_conf
  15. config_load tor
  16. config_get default_conf conf default "/etc/tor/torrc"
  17. config_get generated_conf conf generated "/tmp/torrc"
  18. TORRC_GEN="$generated_conf"
  19. {
  20. echo "## This file was automatically generated please do not edit here !"
  21. config_list_foreach "conf" head_include handle_conf_file
  22. echo "%include $default_conf"
  23. config_list_foreach "conf" tail_include handle_conf_file
  24. } > "$TORRC_GEN"
  25. }
  26. reload_service() {
  27. procd_send_signal /usr/sbin/tor
  28. }
  29. start_service() {
  30. mkdir -m 0700 -p /var/lib/tor
  31. chown -R tor:tor /var/lib/tor
  32. mkdir -m 0755 -p /var/log/tor
  33. chown -R tor:tor /var/log/tor
  34. generate_conf
  35. procd_open_instance
  36. procd_set_param command /usr/sbin/tor --runasdaemon 0
  37. procd_append_param command -f "$TORRC_GEN"
  38. procd_set_param respawn
  39. procd_close_instance
  40. }