[Lunar-commits] <moonbase> gpsd: Just adding a little control using a reworked hack of the init.d

Dennis `stumbles` Veatch stumbles at lunar-linux.org
Sat Jul 3 12:13:21 CEST 2010


commit a1e2352a1d7a99d52be83e51ee3371f32b981ec4
Author: Dennis `stumbles` Veatch <stumbles at lunar-linux.org>
Date:   Sat Jul 3 06:13:21 2010 -0400

    gpsd: Just adding a little control using a reworked hack of the init.d
    
    provided by gpsd.
---
 science/gpsd/BUILD       |    2 +-
 science/gpsd/init.d/gpsd |   90 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 1 deletions(-)

diff --git a/science/gpsd/BUILD b/science/gpsd/BUILD
index 8db02d4..5362a41 100644
--- a/science/gpsd/BUILD
+++ b/science/gpsd/BUILD
@@ -1,6 +1,6 @@
 (
 
-  OPTS="$OPTS --enable-itrax --disable-tnt --enable-dbus"
+  OPTS="$OPTS --enable-itrax --disable-tnt --enable-dbus" &&
 
   default_build &&
 
diff --git a/science/gpsd/init.d/gpsd b/science/gpsd/init.d/gpsd
new file mode 100644
index 0000000..b7b8713
--- /dev/null
+++ b/science/gpsd/init.d/gpsd
@@ -0,0 +1,90 @@
+#!/bin/bash
+#
+# /etc/rc.d/init.d/gpsd
+#
+# Starts the gps daemon
+#
+# chkconfig: 345 44 56
+# description: Listen and dispatch GPS events
+# processname: gpsd
+
+# Source function library.
+. /lib/lsb/init-functions
+
+DAEMON=gps
+PROGNAME=${DAEMON}d
+TTY=/dev/ttyUSB0
+PIDFILE=/var/run/gpsd.pid
+CONTROL_SOCKET=/var/run/gpsd.sock
+OPTIONS="-n -F $CONTROL_SOCKET -P $PIDFILE"
+
+test -x /usr/sbin/$PROGNAME || exit 0
+
+RETVAL=0
+
+#
+# See how we were called.
+#
+
+start() {
+# Check if it is already running
+  [ "$EUID" != "0" ] && exit 4
+  if [ ! -f /var/lock/$PROGNAME ]; then
+    echo -n "Starting $DAEMON daemon: "
+    /usr/sbin/$PROGNAME $OPTIONS $TTY
+    RETVAL=$?
+    [ $RETVAL -eq 0 ] && touch /var/lock/$PROGNAME
+    echo
+  fi
+  return $RETVAL
+}
+
+stop() {
+  [ "$EUID" != "0" ] && exit 4
+  echo -n "Stopping $DAEMON daemon: "
+  pkill $PROGNAME
+  RETVAL=$?
+  [ $RETVAL -eq 0 ] && rm -f /var/lock/$PROGNAME
+  echo
+  return $RETVAL
+}
+
+
+restart() {
+  stop
+  start
+}
+
+reload() {
+  trap "" SIGHUP
+  killall -HUP $PROGNAME
+}
+
+case "$1" in
+  start)
+    start
+  ;;
+  stop)
+    stop
+  ;;
+  reload)
+    reload
+  ;;
+  restart)
+    restart
+  ;;
+  condrestart)
+    if [ -f /var/lock/$PROGNAME ]; then
+      restart
+    fi
+  ;;
+  status)
+    status $PROGNAME
+  ;;
+  *)
+    INITNAME=`basename $0`
+    echo "Usage: $INITNAME {start|stop|restart|condrestart|status}"
+    exit 1
+esac
+
+exit $RETVAL


More information about the Lunar-commits mailing list