Skip to content

Commit 056bd57

Browse files
committed
Add packaging script for Tektelic Kona Mega gateway.
Closes #124.
1 parent fde79b4 commit 056bd57

File tree

4 files changed

+196
-0
lines changed

4 files changed

+196
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
NAME="lora-gateway-bridge"
2+
DESC="LoRa Gateway Bridge"
3+
DAEMON_BIN=/opt/$NAME/$NAME
4+
DAEMON_CONF=/etc/$NAME
5+
DAEMON_PID=/var/run/$NAME.pid
6+
7+
function do_start {
8+
echo "Starting $NAME"
9+
start-stop-daemon \
10+
--start \
11+
--background \
12+
--make-pidfile \
13+
--pidfile $DAEMON_PID \
14+
--exec $DAEMON_BIN
15+
}
16+
17+
function do_stop {
18+
echo "Stopping $NAME"
19+
start-stop-daemon \
20+
--stop \
21+
--oknodo \
22+
--quiet \
23+
--pidfile $DAEMON_PID
24+
}
25+
26+
case "$1" in
27+
"start")
28+
do_start
29+
;;
30+
"stop")
31+
do_stop
32+
;;
33+
"restart")
34+
do_stop
35+
do_start
36+
;;
37+
*)
38+
echo "Usage: $1 {start|stop|restart}"
39+
exit 1
40+
;;
41+
esac
42+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
check process lora-gateway-bridge pidfile /var/run/lora-gateway-bridge.pid
2+
start program = "/bin/bash -c '/etc/init.d/lora-gateway-bridge start'"
3+
stop program = "/bin/bash -c '/etc/init.d/lora-gateway-bridge stop'"
4+
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# This configuration provides a Semtech UDP packet-forwarder backend and
2+
# integrates with a MQTT broker. Many options and defaults have been omitted
3+
# for simplicity.
4+
#
5+
# See https://www.loraserver.io/lora-gateway-bridge/install/config/ for a full
6+
# configuration example and documentation.
7+
8+
9+
# Gateway backend configuration.
10+
[backend]
11+
# Backend type.
12+
type="semtech_udp"
13+
14+
# Semtech UDP packet-forwarder backend.
15+
[backend.semtech_udp]
16+
17+
# ip:port to bind the UDP listener to
18+
#
19+
# Example: 0.0.0.0:1700 to listen on port 1700 for all network interfaces.
20+
# This is the listeren to which the packet-forwarder forwards its data
21+
# so make sure the 'serv_port_up' and 'serv_port_down' from your
22+
# packet-forwarder matches this port.
23+
udp_bind = "0.0.0.0:1700"
24+
25+
# Managed packet-forwarder configuration.
26+
#
27+
# By configuring one or multiple managed packet-forwarder sections, the
28+
# LoRa Gateway Bridge updates the configuration when the backend receives
29+
# a configuration change, after which it will restart the packet-forwarder.
30+
#
31+
# Example (this configuration can be repeated):
32+
#
33+
# [[backend.semtech_udp.configuration]]
34+
# # Gateway ID.
35+
# #
36+
# # The LoRa Gateway Bridge will only apply the configuration updates for this
37+
# # gateway ID.
38+
# gateway_id="0102030405060708"
39+
40+
# # Base configuration file.
41+
# #
42+
# # This file will be used as base-configuration and will not be overwritten on
43+
# # a configuration update. This file needs to exist and contains the base
44+
# # configuration and vendor specific
45+
# base_file="/etc/lora-packet-forwarder/global_conf.json"
46+
47+
# # Output configuration file.
48+
# #
49+
# # This will be the final configuration for the packet-forwarder, containing
50+
# # a merged version of the base configuration + the requested configuration
51+
# # update.
52+
# # Warning: this file will be overwritten on a configuration update!
53+
# output_file="/etc/lora-packet-forwarder/local_conf.json"
54+
55+
# # Restart command.
56+
# #
57+
# # This command is issued by the LoRa Gateway Bridge on a configuration
58+
# # change. Make sure the LoRa Gateway Bridge process has sufficient
59+
# # permissions to execute this command.
60+
# restart_command="/etc/init.d/lora-packet-forwarder restart"
61+
62+
# Integration configuration.
63+
[integration]
64+
# Payload marshaler.
65+
#
66+
# This defines how the MQTT payloads are encoded. Valid options are:
67+
# * protobuf: Protobuf encoding (this will become the LoRa Gateway Bridge v3 default)
68+
# * json: JSON encoding (easier for debugging, but less compact than 'protobuf')
69+
marshaler="protobuf"
70+
71+
# MQTT integration configuration.
72+
[integration.mqtt]
73+
# Event topic template.
74+
event_topic_template="gateway/{{ .GatewayID }}/event/{{ .EventType }}"
75+
76+
# Command topic template.
77+
command_topic_template="gateway/{{ .GatewayID }}/command/#"
78+
79+
# MQTT authentication.
80+
[integration.mqtt.auth]
81+
# Type defines the MQTT authentication type to use.
82+
#
83+
# Set this to the name of one of the sections below.
84+
type="generic"
85+
86+
# Generic MQTT authentication.
87+
[integration.mqtt.auth.generic]
88+
# MQTT server (e.g. scheme://host:port where scheme is tcp, ssl or ws)
89+
server="tcp://127.0.0.1:1883"
90+
91+
# Connect with the given username (optional)
92+
username=""
93+
94+
# Connect with the given password (optional)
95+
password=""
96+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/env bash
2+
3+
PACKAGE_NAME="lora-gateway-bridge"
4+
PACKAGE_VERSION="3.0.1"
5+
REV="r1"
6+
7+
8+
PACKAGE_URL="https://artifacts.loraserver.io/downloads/lora-gateway-bridge/lora-gateway-bridge_${PACKAGE_VERSION}_linux_armv5.tar.gz"
9+
DIR=`dirname $0`
10+
PACKAGE_DIR="${DIR}/package"
11+
12+
# Cleanup
13+
rm -rf $PACKAGE_DIR
14+
15+
# CONTROL
16+
mkdir -p $PACKAGE_DIR/CONTROL
17+
cat > $PACKAGE_DIR/CONTROL/control << EOF
18+
Package: $PACKAGE_NAME
19+
Version: $PACKAGE_VERSION-$REV
20+
Architecture: kona_mega
21+
Maintainer: Orne Brocaar <[email protected]>
22+
Priority: optional
23+
Section: network
24+
Source: N/A
25+
Description: LoRa Gateway Bridge
26+
EOF
27+
28+
cat > $PACKAGE_DIR/CONTROL/postinst << EOF
29+
/usr/bin/monit reload
30+
EOF
31+
chmod 755 $PACKAGE_DIR/CONTROL/postinst
32+
33+
cat > $PACKAGE_DIR/CONTROL/conffiles << EOF
34+
/etc/$PACKAGE_NAME/$PACKAGE_NAME.toml
35+
EOF
36+
37+
# Files
38+
mkdir -p $PACKAGE_DIR/opt/$PACKAGE_NAME
39+
mkdir -p $PACKAGE_DIR/etc/$PACKAGE_NAME
40+
mkdir -p $PACKAGE_DIR/etc/monit.d
41+
mkdir -p $PACKAGE_DIR/etc/init.d
42+
43+
cp files/$PACKAGE_NAME.toml $PACKAGE_DIR/etc/$PACKAGE_NAME/$PACKAGE_NAME.toml
44+
cp files/$PACKAGE_NAME.monit $PACKAGE_DIR/etc/monit.d/$PACKAGE_NAME
45+
cp files/$PACKAGE_NAME.init $PACKAGE_DIR/etc/init.d/$PACKAGE_NAME
46+
wget -P $PACKAGE_DIR/opt/$PACKAGE_NAME $PACKAGE_URL
47+
tar zxf $PACKAGE_DIR/opt/$PACKAGE_NAME/*.tar.gz -C $PACKAGE_DIR/opt/$PACKAGE_NAME
48+
rm $PACKAGE_DIR/opt/$PACKAGE_NAME/*.tar.gz
49+
50+
# Package
51+
opkg-build -o root -g root $PACKAGE_DIR
52+
53+
# Cleanup
54+
rm -rf $PACKAGE_DIR

0 commit comments

Comments
 (0)