ugps.init 653 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (c) 2014 OpenWrt.org
  3. START=80
  4. USE_PROCD=1
  5. PROG=/usr/sbin/ugps
  6. service_triggers() {
  7. procd_add_reload_trigger gps
  8. }
  9. start_service() {
  10. local tty="$(uci get gps.@gps[-1].tty)"
  11. local atime="$(uci get gps.@gps[-1].adjust_time)"
  12. local disabled="$(uci get gps.@gps[-1].disabled || echo 0)"
  13. [ "$disabled" == "0" ] || return
  14. [ "$tty" ] || return
  15. case "$tty" in
  16. "/"*)
  17. true
  18. ;;
  19. *)
  20. tty="/dev/$tty"
  21. ;;
  22. esac
  23. procd_open_instance
  24. procd_set_param command "$PROG"
  25. [ "$atime" -eq 0 ] || procd_append_param command "-a"
  26. procd_append_param command "$tty"
  27. procd_set_param respawn
  28. procd_close_instance
  29. }