1
0

p910nd.init 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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" runas_root
  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. config_get_bool runas_root "$section" runas_root 0
  40. [ "$runas_root" -ne 1 ] && procd_set_param user p910nd
  41. config_get_bool "mdns" "$section" "mdns" '0'
  42. config_get mdns_note "$section" mdns_note
  43. config_get mdns_ty "$section" mdns_ty
  44. config_get mdns_product "$section" mdns_product
  45. config_get mdns_mfg "$section" mdns_mfg
  46. config_get mdns_mdl "$section" mdns_mdl
  47. config_get mdns_cmd "$section" mdns_cmd
  48. [ "$mdns" -gt 0 ] && procd_add_mdns "pdl-datastream" "tcp" "$((port+9100))" "note=$mdns_note" "ty=$mdns_ty" "product=$mdns_product" "usb_MFG=$mdns_mfg" "usb_MDL=$mdns_mdl" "usb_CMD=$mdns_cmd"
  49. procd_close_instance
  50. fi
  51. }