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