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 72 73 74 75
|
#! /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: 0 1 6
# Short-Description: Start the GPS (Global Positioning System) daemon
### END INIT INFO
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/gpsd
DESC="GPS (Global Positioning System) daemon"
PIDFILE="/var/run/gpsd.pid"
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
# include gpsd defaults
if [ -f /etc/default/gpsd ] ; then
. /etc/default/gpsd
else
log_failure_msg "gpsd: error: Cannot find /etc/default/gpsd."
exit 1
fi
case "$1" in
start)
if [ "x$START_DAEMON" = "xtrue" ] ; then
log_daemon_msg "Starting $DESC" "gpsd"
start-stop-daemon --start --quiet \
--exec $DAEMON -- $DAEMON_OPTS -P $PIDFILE $DEVICES \
&& log_end_msg 0 \
|| log_end_msg 1
else
log_warning_msg "gpsd is configured not to start automatically at boot time."
log_warning_msg " To change this, run 'dpkg-reconfigure gpsd'."
fi
;;
stop)
if [ "x$START_DAEMON" = "xtrue" ] ; then
log_daemon_msg "Stopping $DESC" "gpsd"
WARN=$(start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE)
log_end_msg 0
[ -n "$WARN" ] && log_warning_msg "$WARN"
else
log_warning_msg "gpsd is configured not to start automatically at boot time."
log_warning_msg " To change this, run 'dpkg-reconfigure gpsd'."
fi
;;
reload|force-reload)
log_action_msg "gpsd: Resetting connection to GPS device"
WARN=$(start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE)
[ -n "$WARN" ] && log_warning_msg "$WARN"
;;
restart)
set +e; $SELF stop; set -e
$SELF start
;;
*)
N=/etc/init.d/gpsd
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
|