1
0

u2pnpd.init 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. }