summaryrefslogtreecommitdiff
path: root/contrib/etc_init.d_gpsd
blob: e7b56dff7ef4f38575d06747f51e5a1b0165c5f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /bin/sh
#
#	Author: Tilman Koschnick <til@subnetz.org>.
#

### BEGIN INIT INFO
# Provides:          gpsd
# Required-Start:    $syslog $network
# Required-Stop:     $syslog $network
# Default-Start:     2 3 4 5
# Default-Stop:      S 1 0 6
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/gpsd
NAME=gpsd
DESC="GPS daemon"
PIDFILE="/var/run/gpsd.pid"
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)

test -x $DAEMON || exit 0

# include gpsd defaults
if [ -f /etc/default/gpsd ] ; then
	. /etc/default/gpsd
else
	echo "$NAME: Cannot find /etc/default/gpsd - failed."
	exit 1
fi

set -e

case "$1" in
  start)
	if [ "x$START_DAEMON" = "xtrue" ] ; then
		echo -n "Starting $DESC: $NAME"
		start-stop-daemon --start --quiet \
			--exec $DAEMON -- $DAEMON_OPTS -P $PIDFILE $DEVICES \
			&& echo "." \
			|| echo " - failed."
	else
		echo "$NAME is configured not to start automatically at boot time."
		echo "  To change this, modify /etc/default/gpsd."
	fi		
	;;
  stop)
	if [ "x$START_DAEMON" = "xtrue" ] ; then
		echo -n "Stopping $DESC: $NAME"
		start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
		echo "."
	else
		echo "$NAME is configured not to start automatically at boot time."
		echo "  To change this, run 'dpkg-reconfigure gpsd'."
	fi		
	;;
  reload|force-reload)
	echo "$DESC: Resetting connection to GPS device."
	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE
	;;
  restart)
	set +e; $SELF stop; set -e
		$SELF start
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0