diff options
author | Mykyta Dorokhin <mykyta.dorokhin@globallogic.com> | 2017-05-26 13:46:04 -0500 |
---|---|---|
committer | Mykyta Dorokhin <mykyta.dorokhin@globallogic.com> | 2017-05-26 13:47:02 -0500 |
commit | fdffad3583c0c6621284e4d4e9183ef10c3c7c66 (patch) | |
tree | 152b370474e1e7ba132a1290e96796962d759388 /recipes-connectivity/lora/lora-packet-forwarder/mtcap | |
parent | 92782f6ed4f50ae753534a9c095e09a8f89fa4d3 (diff) | |
download | meta-mlinux-fdffad3583c0c6621284e4d4e9183ef10c3c7c66.tar.gz meta-mlinux-fdffad3583c0c6621284e4d4e9183ef10c3c7c66.tar.bz2 meta-mlinux-fdffad3583c0c6621284e4d4e9183ef10c3c7c66.zip |
merge lora-packet-forwarder mtcdt and mtcap init scripts into one
Diffstat (limited to 'recipes-connectivity/lora/lora-packet-forwarder/mtcap')
-rwxr-xr-x | recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init | 132 |
1 files changed, 0 insertions, 132 deletions
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 deleted file mode 100755 index b17a3d8..0000000 --- a/recipes-connectivity/lora/lora-packet-forwarder/mtcap/lora-packet-forwarder.init +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash - -NAME="lora-packet-forwarder" -ENABLED="yes" - -[ -f /etc/default/$NAME ] && source /etc/default/$NAME - -run_dir=/var/run/lora -conf_file=/var/config/lora/global_conf.json -conf_file_local=/var/config/lora/local_conf.json -opt_conf_file=/opt/lora/global_conf.json -opt_conf_file_local=/opt/lora/local_conf.json -log_file=/var/log/lora-pkt-fwd.log - -pkt_fwd=$run_dir/1/lora_pkt_fwd -pkt_fwd_log=/var/log/lora-pkt-fwd-1.log -pkt_fwd_pidfile=$run_dir/lora-pkt-fwd-1.pid - -lora_mtcap_id="MTCAP-LORA" -lora_mtcap_id868="MTCAP-LORA-868" -lora_mtcap_id915="MTCAP-LORA-915" - -read_lora_hw_info() { - # product-id of first lora card - lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null) - lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null) - # remove all colons - lora_eui_raw=${lora_eui//:/} - lora_hw=$(mts-io-sysfs show lora/hw-version 2> /dev/null) -} - -hardware_found() { - if [[ "$lora_id" =~ "$lora_mtcap_id" ]]; then - # - # create /opt/lora/global_conf.json based on detected LORA card - # - if [ "$lora_id" = "$lora_mtcap_id868" ]; then - GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.EU868 - elif [ "$lora_id" = "$lora_mtcap_id915" ]; then - GLOBAL_CONF=/opt/lora/global_conf.json.MTCAP_LORA_1_5.US915 - else - return 1 - fi - - cp $GLOBAL_CONF $opt_conf_file - echo "Setting gateway_id in $opt_conf_file to $lora_eui_raw" - sed -i "s/\"gateway_ID\": \".*\"/\"gateway_ID\": \"$lora_eui_raw\"/" $opt_conf_file - - # - # copy global_json.conf and local_json.conf files to /var/config/ if it is not there yet - # - if ! [ -f $conf_file ]; then - mkdir -p /var/config/lora/ - cp $opt_conf_file $conf_file - cp $opt_conf_file_local $conf_file_local - fi - - ln -sf /opt/lora/lora_pkt_fwd $pkt_fwd - else - return 1 - fi - -} - -do_start() { - # create run directory - mkdir -p $run_dir/1 - rm -rf $run_dir/1/* - - read_lora_hw_info - - if hardware_found; then - echo "Found $lora_id with $lora_hw hardware" - else - echo "$0: LORA not detected" - exit 1 - fi - - # copy conf files to the run directory - if [ -f $conf_file ]; then - cp $conf_file $run_dir/1/ - fi - - if [ -f $conf_file_local ]; then - cp $conf_file_local $run_dir/1/ - fi - - # start packet forwarder - echo -n "Starting $NAME: " - /usr/sbin/start-stop-daemon --chdir $run_dir/1 --background --start --make-pidfile \ - --pidfile $pkt_fwd_pidfile --startas /bin/bash -- -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 - |