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.

49 lines
1.2 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=50
  4. STOP=20
  5. USE_PROCD=1
  6. append_arg() {
  7. local cfg="$1"
  8. local opt="$2"
  9. local var="$3"
  10. local def="$4"
  11. local val
  12. config_get val "$cfg" "$var"
  13. [ -n "$val" ] || [ -n "$def" ] && procd_append_param command "$opt" "${val:-$def}"
  14. }
  15. start_instance() {
  16. local cfg="$1"
  17. local enabled
  18. config_get_bool enabled "$cfg" 'enabled' 1
  19. [ "$enabled" -gt 0 ] || return 0
  20. procd_open_instance
  21. procd_set_param command /usr/bin/u2pnpd
  22. append_arg "$cfg" -s httpsURL
  23. append_arg "$cfg" --interface interface
  24. append_arg "$cfg" --manufacturer manufacturer
  25. append_arg "$cfg" --manufacturerURL manufacturerURL
  26. append_arg "$cfg" --modelDescription modelDescription
  27. append_arg "$cfg" --modelName modelName
  28. append_arg "$cfg" --modelNumber modelNumber
  29. append_arg "$cfg" --modelURL modelURL
  30. append_arg "$cfg" --serialNumber serialNumber
  31. append_arg "$cfg" --friendlyName friendlyName
  32. append_arg "$cfg" --uuid uuid
  33. procd_set_param file /etc/config/u2pnpd
  34. procd_set_param respawn
  35. procd_close_instance
  36. }
  37. start_service() {
  38. config_load u2pnpd && config_foreach start_instance u2pnpd
  39. }
  40. service_triggers() {
  41. procd_add_reload_trigger u2pnpd
  42. }