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.

51 lines
1000 B

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2007 OpenWrt.org
  3. START=50
  4. append_bool() {
  5. local section="$1"
  6. local option="$2"
  7. local value="$3"
  8. local _val
  9. config_get_bool _val "$section" "$option" '0'
  10. [ "$_val" -gt 0 ] && append args "$3"
  11. }
  12. append_string() {
  13. local section="$1"
  14. local option="$2"
  15. local value="$3"
  16. local _val
  17. config_get _val "$section" "$option"
  18. [ -n "$_val" ] && append args "$3$_val"
  19. }
  20. start_service() {
  21. local section="$1"
  22. args=""
  23. append_bool "$section" bidirectional "-b"
  24. append_string "$section" device "-f "
  25. append_string "$section" bind "-i "
  26. append_string "$section" port ""
  27. config_get_bool "enabled" "$section" "enabled" '1'
  28. [ "$enabled" -gt 0 ] && /usr/sbin/p910nd $args
  29. }
  30. stop_service() {
  31. local section="$1"
  32. config_get port "$section" port
  33. PID_F=/var/run/p910${port}d.pid
  34. [ -f $PID_F ] && kill $(cat $PID_F)
  35. }
  36. start() {
  37. config_load "p910nd"
  38. config_foreach start_service p910nd
  39. }
  40. stop() {
  41. config_load "p910nd"
  42. config_foreach stop_service p910nd
  43. }