rc.gpsd.new 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/sh
  2. # /etc/rc.d/rc.gpsd
  3. # Start/stop/restart gpsd
  4. # Sebastian Arcus and David Spencer
  5. #
  6. # To enable automatic discovery of your GPS device by udev, uncomment the
  7. # appropriate line of /etc/udev/rules.d/97-gpsd.rules
  8. #
  9. # Configuration options may be set in /etc/rc.d/rc.gpsd.conf
  10. # but the defaults will usually be adequate.
  11. gpsd_start() {
  12. if [ ! -x /lib/udev/gpsd.hotplug ]; then
  13. echo "$(basename $0): /lib/udev/gpsd.hotplug not found (or not executable); cannot start."
  14. exit 1
  15. fi
  16. if [ -r /etc/rc.d/rc.gpsd.conf ]; then
  17. . /etc/rc.d/rc.gpsd.conf
  18. fi
  19. # Set config defaults in case the .conf file was absent or bogus
  20. GPSD_DEVICES="${GPSD_DEVICES:-/dev/gps*}"
  21. GPSD_OPTIONS="${GPSD_OPTIONS:-}"
  22. GPSD_SOCKET="${GPSD_SOCKET:-/var/run/gpsd.sock}"
  23. for DEVNAME in $GPSD_DEVICES; do
  24. if [ -e $DEVNAME ]; then
  25. echo "$(basename $0): Starting gpsd for $DEVNAME"
  26. ACTION=add DEVNAME=$DEVNAME /lib/udev/gpsd.hotplug
  27. else
  28. echo "$(basename $0): $DEVNAME not found, gpsd not started"
  29. fi
  30. done
  31. }
  32. gpsd_stop() {
  33. echo "Stopping gpsd..."
  34. killall gpsd >/dev/null 2>&1
  35. return 0
  36. }
  37. case "$1" in
  38. start)
  39. gpsd_start
  40. ;;
  41. stop)
  42. gpsd_stop
  43. ;;
  44. restart)
  45. gpsd_stop
  46. sleep 1
  47. gpsd_start
  48. ;;
  49. *)
  50. echo "Usage: $0 start|stop|restart"
  51. exit 1
  52. ;;
  53. esac