diff options
author | Jason Reiss <jreiss@multitech.com> | 2016-12-20 08:47:27 -0600 |
---|---|---|
committer | Jason Reiss <jreiss@multitech.com> | 2016-12-20 08:47:27 -0600 |
commit | c4c440ac53c69df3d7f75dcadc040cea89ff340c (patch) | |
tree | 6acd55f7eab1c848dffd052f82df94f62fff4d47 /recipes-connectivity/lora/lora-packet-forwarder/mtcap | |
parent | 97fe7114ff532b2017dd2abc5cba620c216ff8f3 (diff) | |
download | meta-mlinux-c4c440ac53c69df3d7f75dcadc040cea89ff340c.tar.gz meta-mlinux-c4c440ac53c69df3d7f75dcadc040cea89ff340c.tar.bz2 meta-mlinux-c4c440ac53c69df3d7f75dcadc040cea89ff340c.zip |
lora: move packet forwarder init and default scripts into machine specific folders
Diffstat (limited to 'recipes-connectivity/lora/lora-packet-forwarder/mtcap')
-rw-r--r-- | recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.default | 2 | ||||
-rwxr-xr-x | recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init | 69 |
2 files changed, 71 insertions, 0 deletions
diff --git a/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.default b/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.default new file mode 100644 index 0000000..be7dcd5 --- /dev/null +++ b/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.default @@ -0,0 +1,2 @@ +# set to "yes" or "no" to control starting on boot +ENABLED="yes" diff --git a/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init b/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init new file mode 100755 index 0000000..9ffaf6d --- /dev/null +++ b/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init @@ -0,0 +1,69 @@ +#!/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 +cfg_file=/opt/lora/global_conf.json + +do_start() { + echo "Starting $NAME: " + + eui=$(mts-io-sysfs show lora/eui) + # Remove colons + clean_eui="${eui//:/}" + echo "Setting gateway_id in $cfg_file to $clean_eui" + sed -i "s/\"gateway_ID\": \".*\"/\"gateway_ID\": \"$clean_eui\"/" $cfg_file + + 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/$NAME" + 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 + + |