#! /bin/sh
#
# fso-gpsd
#		Init.d file for the fso-gpsd
#
#		Heavily based on the template file written by Miquel van
#		Smoorenburg <miquels@cistron.nl> and modified for Debian
#		by Ian Murdock <imurdock@gnu.ai.mit.edu>, version 1.9.
#
### BEGIN INIT INFO
# Provides:          fso-gpsd
# Required-Start:    $remote_fs dbus frameworkd
# Required-Stop:     $remote_fs dbus frameworkd
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts the fso gspd compatibility daemon
# Description:       This init script starts the gpsd compatibility daemon
#                    for systems running the fso-frameworkd server.
### END INIT INFO

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/fso-gpsd
NAME=fso-gpsd
DESC="freesmartphone.org GPSD compatibility daemon"
PIDDIR=/var/run/
PIDFILE=${PIDDIR}/${NAME}.pid
DAEMON_OPTS="-S localhost:gpsd -P $PIDFILE"


# Gracefully exit if the package has been removed (but not purged).
[ -x "$DAEMON" ] || exit 0


# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
. /lib/lsb/init-functions


case "$1" in
    start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
	start-stop-daemon --oknodo --start --quiet --pidfile ${PIDFILE} \
		--exec $DAEMON -- $DAEMON_OPTS
	[ "$VERBOSE" != no ] && log_end_msg $?
	;;
    stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
	start-stop-daemon --oknodo --stop --quiet --pidfile ${PIDFILE}
	[ "$VERBOSE" != no ] && log_end_msg $?
	;;
    restart|force-reload)
	$0 stop
	$0 start
	;;
    *)
	log_success_msg "Usage: $0 {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
