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.

46 lines
979 B

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2007 OpenWrt.org
  3. START=99
  4. USE_PROCD=1
  5. append_bool() {
  6. local section="$1"
  7. local option="$2"
  8. local value="$3"
  9. local _val
  10. config_get_bool _val "$section" "$option" '0'
  11. [ "$_val" -gt 0 ] && append args "$3"
  12. }
  13. append_string() {
  14. local section="$1"
  15. local option="$2"
  16. local value="$3"
  17. local _val
  18. config_get _val "$section" "$option"
  19. [ -n "$_val" ] && append args "$3$_val"
  20. }
  21. start_service() {
  22. config_load "p910nd"
  23. config_foreach start_p910nd p910nd
  24. }
  25. start_p910nd() {
  26. local section="$1"
  27. config_get_bool "enabled" "$section" "enabled" '1'
  28. if [ "$enabled" -gt 0 ]; then
  29. args="-d "
  30. config_get port "$section" port
  31. name=p910${port}d
  32. append_bool "$section" bidirectional "-b"
  33. append_string "$section" device "-f "
  34. append_string "$section" bind "-i "
  35. append_string "$section" port ""
  36. procd_open_instance $name
  37. procd_set_param command /usr/sbin/p910nd $args
  38. procd_set_param respawn
  39. procd_close_instance
  40. fi
  41. }