From 2dac3e03e77449b07831594555253053bc3dd61b Mon Sep 17 00:00:00 2001 From: John Klug Date: Tue, 10 Jan 2017 19:37:44 -0600 Subject: Add status to gpsd init script --- recipes-navigation/gpsd/gpsd/gpsd | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'recipes-navigation') diff --git a/recipes-navigation/gpsd/gpsd/gpsd b/recipes-navigation/gpsd/gpsd/gpsd index d9cf201..9c59f10 100755 --- a/recipes-navigation/gpsd/gpsd/gpsd +++ b/recipes-navigation/gpsd/gpsd/gpsd @@ -63,6 +63,7 @@ do_start() gpsctl -t 'u-blox' -s $GPS_BAUD -b -f $GPS_LINE # The next line is needed due to a bug in gpsctl. # We will go back to the default baud rate if we don't do this step. + echo Expect a timeout error here. Need this error. gpsctl -T 2 -f $GPS_LINE stty -F $GPS_LINE $GPS_BAUD /usr/sbin/start-stop-daemon -N -20 --start --quiet --pidfile $PIDFILE --exec $DAEMON --test \ @@ -104,6 +105,19 @@ do_reload() { return 0 } +do_status() { + NAME=$1 + PIDFILE=$2 + # -t: test only but not stop + start-stop-daemon -K -t --quiet --pidfile $PIDFILE --name $NAME + # exit with status 0 if process is found + if [ "$?" = "0" ]; then + return 0 + else + return 1 + fi +} + case "$1" in start) echo "Starting $DESC" "$NAME" @@ -116,7 +130,19 @@ case "$1" in exit $? ;; status) - ;; + echo -n "status $NAME ... " + do_status "$NAME" "$PIDFILE" + if [ "$?" = "0" ]; then + echo "running" + exit 0 + else + echo "stopped" + exit 1 + fi + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2 + ;; reload|force-reload) echo "Reloading $DESC" "$NAME" do_reload -- cgit v1.2.3