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.

62 lines
1.6 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2015 OpenWrt.org
  3. START=50
  4. STOP=20
  5. SERVICE_DAEMONIZE=1
  6. SERVICE_PID_FILE=/var/run/u2pnpd.pid
  7. SERVICE_USE_PID=1
  8. SERVICE_WRITE_PID=1
  9. start_instance() {
  10. local section="$1"
  11. local enabled
  12. local interface manufacturer manufacturerURL modelDescription
  13. local modelName modelNumber modelURL serialNumber friendlyName
  14. local uuid httpsURL
  15. local i
  16. config_get_bool enabled "$section" 'enabled' 1
  17. [ "$enabled" -gt 0 ] || return 0
  18. for i in interface httpsURL manufacturer manufacturerURL modelDescription \
  19. modelName modelNumber modelURL serialNumber friendlyName uuid; do
  20. config_get "$i" "$section" "$i"
  21. done
  22. [ -n "$interface" ] && SERVICE_PID_FILE="/var/run/u2pnpd.$interface.pid"
  23. service_start /usr/bin/u2pnpd ${httpsURL:+-s} \
  24. ${interface:+--interface="$interface"} \
  25. ${manufacturer:+--manufacturer="$manufacturer"} \
  26. ${manufacturerURL:+--manufacturerURL="$manufacturerURL"} \
  27. ${modelDescription:+--modelDescription="$modelDescription"} \
  28. ${modelName:+--modelName="$modelName"} \
  29. ${modelNumber:+--modelNumber="$modelNumber"} \
  30. ${modelURL:+--modelURL="$modelURL"} \
  31. ${serialNumber:+--serialNumber="$serialNumber"} \
  32. ${friendlyName:+--friendlyName="$friendlyName"} \
  33. ${uuid:+--uuid="$uuid"}
  34. }
  35. stop_instance() {
  36. local section="$1"
  37. local interface
  38. config_get interface "$section" 'interface'
  39. [ -n "$interface" ] && SERVICE_PID_FILE="/var/run/u2pnpd.$interface.pid"
  40. service_stop /usr/bin/u2pnpd
  41. rm -f "$SERVICE_PID_FILE"
  42. }
  43. start() {
  44. config_load 'u2pnpd'
  45. config_foreach start_instance 'u2pnpd'
  46. }
  47. stop() {
  48. config_load 'u2pnpd'
  49. config_foreach stop_instance 'u2pnpd'
  50. }