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.

44 lines
787 B

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2009-2011 OpenWrt.org
  3. START=50
  4. USE_PROCD=1
  5. PROG=/usr/sbin/gpsd
  6. NAME=gpsd
  7. validate_section_gpsd()
  8. {
  9. uci_validate_section gpsd gpsd "${1}" \
  10. 'enabled:bool:1' \
  11. 'device:string' \
  12. 'listen_globally:bool:0' \
  13. 'port:port:2947'
  14. }
  15. gpsd_instance()
  16. {
  17. local device enabled listen_globally port
  18. validate_section_gpsd "${1}" || {
  19. echo "validation failed"
  20. return 1
  21. }
  22. [ "${enabled}" = "0" ] && return 1
  23. procd_open_instance
  24. procd_set_param command "$PROG" -N -n
  25. [ "${listen_globally}" -ne 0 ] && procd_append_param command -G
  26. procd_append_param command -S "${port}"
  27. procd_append_param command "${device}"
  28. procd_set_param respawn
  29. procd_close_instance
  30. }
  31. start_service()
  32. {
  33. config_load "${NAME}"
  34. config_foreach gpsd_instance gpsd
  35. }