gpsd.init.in 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/sh
  2. #
  3. # gpsd Service daemon for mediating access to a GPS
  4. #
  5. # chkconfig: - 44 66
  6. # description: gpsd is a service daemon that mediates access to a GPS sensor \
  7. # connected to the host computer by serial or USB interface, \
  8. # making its data on the location/course/velocity of the sensor \
  9. # available to be queried on TCP port 2947 of the host computer.
  10. # processname: gpsd
  11. # pidfile: @RUNDIR@/gpsd.pid
  12. # http://fedoraproject.org/wiki/FCNewInit/Initscripts
  13. ### BEGIN INIT INFO
  14. # Provides: gpsd
  15. # Required-Start: network
  16. # Required-Stop: network
  17. # Should-Start:
  18. # Should-Stop:
  19. # Default-Start:
  20. # Default-Stop:
  21. # Short-Description: Service daemon for mediating access to a GPS
  22. # Description: gpsd is a service daemon that mediates access to a GPS sensor
  23. # connected to the host computer by serial or USB interface, making its
  24. # data on the location/course/velocity of the sensor available to be
  25. # queried on TCP port 2947 of the host computer.
  26. ### END INIT INFO
  27. # Source function library.
  28. . /etc/rc.d/init.d/functions
  29. exec="/usr/sbin/gpsd"
  30. prog=$(basename $exec)
  31. PIDFILE=@RUNDIR@/gpsd.pid
  32. CONTROL_SOCKET=@RUNDIR@/gpsd.sock
  33. [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
  34. lockfile=/var/lock/subsys/$prog
  35. start() {
  36. [ "$EUID" != "0" ] && exit 4
  37. echo -n $"Starting $prog: "
  38. daemon $exec -P $PIDFILE -F $CONTROL_SOCKET $OPTIONS $DEVICE
  39. retval=$?
  40. echo
  41. [ $retval -eq 0 ] && touch $lockfile
  42. return $retval
  43. }
  44. stop() {
  45. [ "$EUID" != "0" ] && exit 4
  46. echo -n $"Stopping $prog: "
  47. killproc $prog
  48. retval=$?
  49. echo
  50. [ $retval -eq 0 ] && rm -f $lockfile
  51. return $retval
  52. }
  53. restart() {
  54. stop
  55. start
  56. }
  57. case "$1" in
  58. start|stop|restart)
  59. $1
  60. ;;
  61. force-reload)
  62. restart
  63. ;;
  64. status)
  65. status $prog
  66. ;;
  67. try-restart|condrestart)
  68. if status $prog >/dev/null ; then
  69. restart
  70. fi
  71. ;;
  72. reload)
  73. status $prog >/dev/null || exit 7
  74. # If config can be reloaded without restarting, implement it here,
  75. # remove the "exit", and add "reload" to the usage message below.
  76. action $"Service $prog does not support the reload action: " /bin/false
  77. exit 3
  78. ;;
  79. *)
  80. echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
  81. exit 2
  82. esac