From fbd8159eec0bbeb8a819d9da81268b9006bd3a7b Mon Sep 17 00:00:00 2001 From: Brandon Bayer Date: Wed, 12 Oct 2016 12:03:46 -0500 Subject: lora-pkt-fwd: add init file and set iot.semtech.com as default server --- .../lora/lora-packet-forwarder/local_conf.json | 7 +++ .../lora-packet-forwarder/local_conf.json.3.0.0 | 7 --- .../lora-packet-forwarder.default | 2 + .../lora-packet-forwarder.init | 62 ++++++++++++++++++++++ 4 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 recipes-connectivity/lora/lora-packet-forwarder/local_conf.json delete mode 100644 recipes-connectivity/lora/lora-packet-forwarder/local_conf.json.3.0.0 create mode 100644 recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.default create mode 100755 recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder.init (limited to 'recipes-connectivity/lora/lora-packet-forwarder') 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 + + -- cgit v1.2.3