#!/bin/sh ### BEGIN INIT INFO # Provides: gpsd # Required-Start: $remote_fs $syslog $network # Should-Start: bluetooth dbus udev # Required-Stop: $remote_fs $syslog $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # X-Start-Before: ntp # Short-Description: GPS33 (Global Positioning System) daemon # Description: The gpsd service daemon is able to monitor one or # more GPS devices connected to a host computer, making # all data on the location and movements of the sensors # available to be queried on TCP port 2947. ### END INIT INFO# Author: Bernd Zeimetz # # Please remove the "Author" lines above and replace them # with your own name if you copy and modify this script.# Do NOT "set -e"# PATH should only include /usr/* if it runs after the mountnfs.sh script RUNDIR=/run/gpsd PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC="GPS2 (Global Positioning System) daemon" NAME=gpsd DAEMON=/usr/sbin/$NAME PIDFILE=$RUNDIR/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME# Exit if the package is not installed [ -x "$DAEMON" ] || exit 0# Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAMEif [ -z "$GPSD_SOCKET" ] && [ -z "$DEVICES" ]; thenGPSD_SOCKET=/var/run/gpsd.sock fiif [ -n "$GPSD_SOCKET" ]; thenGPSD_OPTIONS="$GPSD_OPTIONS -F $GPSD_SOCKET" fi# Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh# Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions# # Function that starts the daemon/service # do_start() {# Return# 0 if daemon has been started# 1 if daemon was already running# 2 if daemon could not be startedbaudrate=115200mkdir -p $RUNDIR || return 2start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \|| return 1while [ $baudrate -ne 9600 ]dobaudrate=`stty speed 9600 -F $DEVICES`done start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \$GPSD_OPTIONS -P $PIDFILE $DEVICES \|| return 2 }# # Function that stops the daemon/service # do_stop() {# Return# 0 if daemon has been stopped# 1 if daemon was already stopped# 2 if daemon could not be stopped# other if a failure occurredstart-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAMERETVAL="$?"[ "$RETVAL" = 2 ] && return 2# Many daemons don't delete their pidfiles when they exit.rm -f $PIDFILEreturn "$RETVAL" }# # Function that sends a SIGHUP to the daemon/service # do_reload() {## If the daemon can reload its configuration without# restarting (for example, when it is sent a SIGHUP),# then implement that here.#start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAMEreturn 0 }case "$1" instart)if [ "$START_DAEMON" = "true" ]; then[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"do_startcase "$?" in0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;esacelse[ "$VERBOSE" != no ] && \log_daemon_msg "Not starting $DESC" "$NAME" && \log_end_msg 0fi;;stop)[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"do_stopcase "$?" in0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;esac;;status)status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?;;reload|force-reload)log_daemon_msg "Reloading $DESC" "$NAME"do_reloadlog_end_msg $?;;restart)## If the "reload" option is implemented then remove the# 'force-reload' alias#log_daemon_msg "Restarting $DESC" "$NAME"do_stopcase "$?" in0|1)do_startcase "$?" in0) log_end_msg 0 ;;1) log_end_msg 1 ;; # Old process is still running*) log_end_msg 1 ;; # Failed to startesac;;*)# Failed to stoplog_end_msg 1;;esac;;*)echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2exit 3;; esac: