gpsdate/gpsdate.init

77 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

2013-04-10 11:03:22 +00:00
#!/bin/sh
#/etc/init.d/gpsdate: start gpsdate daemon.
### BEGIN INIT INFO
# Provides: gpsdate
# Short-Description: Start software gpsdate
# Required-Start: $all
# Required-Stop: $all
# Should-Start: gpsd
2013-04-10 11:03:22 +00:00
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
2013-04-10 11:03:22 +00:00
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin
test -x /usr/sbin/gpsdate || exit 0
# For configuration of the init script use the file
# /etc/default/gpsdate, do not edit this init script.
# Set run_gpsdate to 1 to start gpsdate or 0 to disable it.
# Specify additional gpsdate options here (see manpage).
gpsdate_options=""
# Specify module to load
gpsdate_module="none"
run_gpsdate=1
[ -e /etc/default/gpsdate ] && . /etc/default/gpsdate
NAME=gpsdate
DAEMON=/usr/sbin/gpsdate
case "$1" in
start)
if [ $run_gpsdate = 1 ]
then
# do we have to load a module?
[ ${gpsdate_module:-none} != "none" ] && /sbin/modprobe $gpsdate_module
# Unconditionally start gpsdate daemon because we want to run it even
# if wd_keepalive wasn't running
echo "Starting gpsdate..."
$DAEMON ${GPSDATE_HOST} ${GPSDATE_PORT} $gpsdate_options
2013-04-10 11:03:22 +00:00
fi
;;
stop)
# This should use start-stop-daemon and create a pid file
echo "Stopping gpsdate in a brutal way"
kill -9 `pidof $DAEMON`
2013-04-10 11:03:22 +00:00
;;
restart)
$0 force-reload
;;
force-reload)
if [ $run_gpsdate = 0 ]; then exit 0; fi
echo "Restarting ${NAME}"
$0 stop
$0 start
2013-04-10 11:03:22 +00:00
;;
*)
echo "Usage: /etc/init.d/gpsdate {start|stop|restart|force-reload}"
exit 1
esac
exit 0