Devuan fork of gpsd
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.

gpsd.init 1.7 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. #
  3. # Author: Tilman Koschnick <til@subnetz.org>.
  4. #
  5. ### BEGIN INIT INFO
  6. # Provides: gpsd
  7. # Required-Start: $syslog $network
  8. # Required-Stop: $syslog $network
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: Start the GPS (Global Positioning System) daemon
  12. ### END INIT INFO
  13. set -e
  14. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  15. DAEMON=/usr/sbin/gpsd
  16. DESC="GPS (Global Positioning System) daemon"
  17. PIDFILE="/var/run/gpsd.pid"
  18. SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
  19. test -x $DAEMON || exit 0
  20. . /lib/lsb/init-functions
  21. # include gpsd defaults
  22. if [ -f /etc/default/gpsd ] ; then
  23. . /etc/default/gpsd
  24. else
  25. log_failure_msg "gpsd: error: Cannot find /etc/default/gpsd."
  26. exit 1
  27. fi
  28. case "$1" in
  29. start)
  30. if [ "x$START_DAEMON" = "xtrue" ] ; then
  31. log_daemon_msg "Starting $DESC" "gpsd"
  32. start-stop-daemon --start --quiet \
  33. --exec $DAEMON -- $DAEMON_OPTS -P $PIDFILE $DEVICES \
  34. && log_end_msg 0 \
  35. || log_end_msg 1
  36. else
  37. log_daemon_msg "Not starting $DESC" "gpsd" && log_end_msg 0
  38. fi
  39. ;;
  40. stop)
  41. if [ "x$START_DAEMON" = "xtrue" ] ; then
  42. log_daemon_msg "Stopping $DESC" "gpsd"
  43. WARN=$(start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE)
  44. log_end_msg 0
  45. [ -n "$WARN" ] && log_warning_msg "$WARN"
  46. else
  47. log_daemon_msg "Not stopping $DESC" "gpsd" && log_end_msg 0
  48. fi
  49. ;;
  50. reload|force-reload)
  51. log_action_msg "gpsd: Resetting connection to GPS device"
  52. WARN=$(start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE)
  53. [ -n "$WARN" ] && log_warning_msg "$WARN"
  54. ;;
  55. restart)
  56. set +e; $SELF stop; set -e
  57. $SELF start
  58. ;;
  59. *)
  60. N=/etc/init.d/gpsd
  61. echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
  62. exit 1
  63. ;;
  64. esac
  65. exit 0