diff options
author | Brandon Bayer <bbayer@multitech.com> | 2016-10-12 12:03:46 -0500 |
---|---|---|
committer | Brandon Bayer <bbayer@multitech.com> | 2016-10-13 16:37:10 -0500 |
commit | fbd8159eec0bbeb8a819d9da81268b9006bd3a7b (patch) | |
tree | 591b0c179bd2006566db8226a450ff348fd82278 /recipes-connectivity/lora/lora-packet-forwarder | |
parent | 410efb21199a03e49ed8ac6db523854f8a1ae6b6 (diff) | |
download | meta-mlinux-fbd8159eec0bbeb8a819d9da81268b9006bd3a7b.tar.gz meta-mlinux-fbd8159eec0bbeb8a819d9da81268b9006bd3a7b.tar.bz2 meta-mlinux-fbd8159eec0bbeb8a819d9da81268b9006bd3a7b.zip |
lora-pkt-fwd: add init file and set iot.semtech.com as default server
Diffstat (limited to 'recipes-connectivity/lora/lora-packet-forwarder')
4 files changed, 71 insertions, 7 deletions
diff --git a/recipes-connectivity/lora/lora-packet-forwarder/local_conf.json b/recipes-connectivity/lora/lora-packet-forwarder/local_conf.json new file mode 100644 index 0000000..6576072 --- /dev/null +++ b/recipes-connectivity/lora/lora-packet-forwarder/local_conf.json @@ -0,0 +1,7 @@ +{ + "gateway_conf": { + "server_address": "iot.semtech.com", + "serv_port_up": 1680, + "serv_port_down": 1680 + } +} diff --git a/recipes-connectivity/lora/lora-packet-forwarder/local_conf.json.3.0.0 b/recipes-connectivity/lora/lora-packet-forwarder/local_conf.json.3.0.0 deleted file mode 100644 index 3c2af80..0000000 --- a/recipes-connectivity/lora/lora-packet-forwarder/local_conf.json.3.0.0 +++ /dev/null @@ -1,7 +0,0 @@ -{ - "gateway_conf": { - "server_address": "localhost", - "serv_port_up": 1780, - "serv_port_down": 1782 - } -} diff --git a/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.default b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.default new file mode 100644 index 0000000..0f92640 --- /dev/null +++ b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.default @@ -0,0 +1,2 @@ +# set to "yes" or "no" to control starting on boot +ENABLED="no" diff --git a/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init new file mode 100755 index 0000000..5fec143 --- /dev/null +++ b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init @@ -0,0 +1,62 @@ +#!/bin/bash + +NAME="lora-packet-forwarder" +ENABLED="yes" + +START_STOP_DAEMON="/usr/sbin/start-stop-daemon" + +[ -f /etc/default/$NAME ] && source /etc/default/$NAME + +run_dir=/var/run/lora +pkt_fwd=/opt/lora/lora_pkt_fwd +pkt_fwd_pidfile=$run_dir/lora-pkt-fwd-1.pid +log_file=/var/log/lora-pkt-fwd.log + +do_start() { + echo -n "Starting $NAME: " + + mkdir -p $run_dir + + # start packet forwarder + $START_STOP_DAEMON --start --background --make-pidfile \ + --pidfile $pkt_fwd_pidfile --startas /bin/bash --chdir "/opt/lora/" \ + -- -c "exec $pkt_fwd > $log_file 2>&1" + + renice -n -20 -p $(pgrep $(basename $pkt_fwd)) + + echo "OK" +} + +do_stop() { + echo -n "Stopping $NAME: " + $START_STOP_DAEMON --stop --quiet --oknodo --pidfile $pkt_fwd_pidfile --retry 5 + rm -f $pkt_fwd_pidfile + echo "OK" +} + +if [ "$ENABLED" != "yes" ]; then + echo "$NAME: disabled in /etc/default" + exit +fi + +case "$1" in + "start") + do_start + ;; + "stop") + do_stop + ;; + "restart") + ## Stop the service and regardless of whether it was + ## running or not, start it again. + do_stop + do_start + ;; + *) + ## If no parameters are given, print which are avaiable. + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + + |