python-crypto: moved to github
[packages.git] / net / gpsd / files / gpsd.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2009-2011 OpenWrt.org
3 START=50
4
5 NAME=gpsd
6 PIDF=/var/run/$NAME.pid
7 PROG=/usr/sbin/$NAME
8
9 start() {
10     config_load gpsd
11     config_get device core device
12     config_get port core port
13     config_get_bool listen_globally core listen_globally
14     config_get_bool enabled core enabled
15     [ "$enabled" != "1" ] && exit
16     logger -t "$NAME" "Starting..."
17     [ ! -c "$device" ] && {
18         logger -t "$NAME" "Unable to find device $device. Exiting."
19         exit 1
20     }
21     [ "$listen_globally" != "0" ] && append args "-G"
22     $PROG -n -P $PIDF -S $port $args $device
23 }
24
25 stop() {
26     logger -t "$NAME" "Stopping..."
27     [ -f "$PIDF" ] && {
28         read PID < "$PIDF"
29         kill -9 $PID
30         rm $PIDF
31     }
32 }