This patch adds an init script and an hotplug script for the gpsd package.
An UCI-based configuration file is also provided. Supported option are:
device, where the gps receiver is plugged
port, port on which gpsd shall listen for incoming queries
enabled, turn gpsd on/off
Signed-off-by: Roberto Riggio <roberto.rig...@create-net.org>
--
Index: net/gpsd/files/gpsd.init
===================================================================
--- net/gpsd/files/gpsd.init (revision 0)
+++ net/gpsd/files/gpsd.init (revision 0)
@@ -0,0 +1,69 @@
+#!/bin/sh /etc/rc.common
+
+START=50
+NAME=gpsd
+PIDF=/var/run/$NAME.pid
+PROG=/usr/sbin/$NAME
+
+. /etc/functions.sh
+
+start() {
+ config_load gpsd
+ config_get device core device
+ config_get port core port
+ config_get_bool enabled core enabled
+ [ $enabled == 0 ] && exit 1
+ logger "Starting: $NAME"
+ [ -f "$PIDF" ] && {
+ logger "Already running ($NAME). Exiting."
+ exit 1
+ }
+ [ ! -c "$device" ] && {
+ logger "Unable to find device $device. Exiting."
+ exit 1
+ }
+ ($PROG -n -N -P $PIDF -S $port $device &) &
+ [ ! -f "$PIDF" ] && {
+ logger "Unable to start $NAME. Exiting."
+ exit 1
+ }
+}
+
+stop() {
+ logger "Stopping: $NAME"
+ [ -f "$PIDF" ] && {
+ kill -9 $(cat $PIDF)
+ rm $PIDF
+ }
+}
+
Index: net/gpsd/files/gpsd.config
===================================================================
--- net/gpsd/files/gpsd.config (revision 0)
+++ net/gpsd/files/gpsd.config (revision 0)
@@ -0,0 +1,4 @@
+config gpsd core
+ option device "/dev/ttyUSB0"
+ option port "2947"
+ option enabled "true"
Index: net/gpsd/files/gpsd.hotplug
===================================================================
--- net/gpsd/files/gpsd.hotplug (revision 0)
+++ net/gpsd/files/gpsd.hotplug (revision 0)
@@ -0,0 +1,17 @@
+case "$ACTION" in
+ add)
+ # start process
+ # only pl2303 devices are handled
+ if [ "$PRODUCT" = "67b/2303/300" ] && [ "$TYPE" = "0/0/0" ] &&
[ "$INTERFACE" = "255/0/0" ]; then
+ /etc/init.d/gpsd start
+ fi
+ ;;
+ remove)
+ # stop process
+ # only pl2303 devices are handled
+ if [ "$PRODUCT" = "67b/2303/300" ] && [ "$TYPE" = "0/0/0" ] &&
[ "$INTERFACE" = "255/0/0" ]; then
+ /etc/init.d/gpsd stop
+ fi
+ ;;
+esac
+
Index: net/gpsd/Makefile
===================================================================
--- net/gpsd/Makefile (revision 18258)
+++ net/gpsd/Makefile (working copy)
@@ -66,6 +66,12 @@
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libgps.so.* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/gpsd $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/config
+ $(INSTALL_DATA) ./files/gpsd.config $(1)/etc/config/gpsd
+ $(INSTALL_DIR) $(1)/etc/init.d
+ $(INSTALL_BIN) ./files/gpsd.init $(1)/etc/init.d/gpsd
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/usb
+ $(INSTALL_DATA) ./files/gpsd.hotplug $(1)/etc/hotplug.d/usb/20-gpsd
endef
$(eval $(call BuildPackage,gpsd))
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel