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.

47 lines
841 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_load_validate gpsd gpsd "$1" "$2" \
  10. 'enabled:bool:1' \
  11. 'device:string' \
  12. 'listen_globally:bool:0' \
  13. 'port:port:2947'
  14. }
  15. gpsd_instance()
  16. {
  17. [ "$2" = 0 ] || {
  18. echo "validation failed"
  19. return 1
  20. }
  21. [ "$enabled" = "0" ] && return 1
  22. procd_open_instance
  23. procd_set_param command "$PROG" -N -n
  24. [ "$listen_globally" -ne 0 ] && procd_append_param command -G
  25. procd_append_param command -S "$port"
  26. procd_append_param command "$device"
  27. procd_set_param respawn
  28. procd_close_instance
  29. }
  30. start_service()
  31. {
  32. config_load "$NAME"
  33. config_foreach validate_section_gpsd gpsd gpsd_instance
  34. }
  35. service_triggers() {
  36. procd_add_reload_trigger "$NAME"
  37. procd_add_validation validate_section_gpsd
  38. }