aboutsummaryrefslogtreecommitdiffstats
path: root/main/gpsd/gpsd.initd
blob: ea7f2ad477935d1f2fa9cb0b651f301f44e28ef5 (plain) (blame)
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
#!/sbin/openrc-run
# Copyright 2012 Nathan Angelacos 

description="GPS daemon"

depend() {
	need net
	after firewall
	use ntp-server
}

GPS=${SVCNAME#*.}
if [ -n "${GPS}" ] && [ ${SVCNAME} != "gpsd" ]; then
   GPSPID="/var/run/gpsd.${GPS}.pid"
else
   GPSPID="/var/run/gpsd.pid"
fi

start() {

        if [ -z "${DEVICE}" ]; then
		eerror "Specify a GPS device in /etc/conf.d/${SVCNAME}" 
		return 1
        fi

	ebegin "Starting gpsd"
	start-stop-daemon --start --quiet \
		--exec /usr/sbin/gpsd \
		--  ${ARGS} -P "${GPSPID}" ${DEVICE}
	eend $? "Failed to start gpsd"
}

stop() {
	ebegin "Stopping gpsd"
	start-stop-daemon --stop --quiet \
		--pidfile "${GPSPID}"
	eend $? "Failed to stop gpsd"
}