Skip to content

Commit 89f705a

Browse files
committed
Update config example for .deb packages.
1 parent c7897a2 commit 89f705a

File tree

3 files changed

+131
-13
lines changed

3 files changed

+131
-13
lines changed

.goreleaser.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ nfpm:
3636
"packaging/files/lora-gateway-bridge.rotate": "/etc/logrotate.d/lora-gateway-bridge"
3737
"packaging/files/lora-gateway-bridge.init": "/usr/lib/lora-gateway-bridge/scripts/lora-gateway-bridge.init"
3838
"packaging/files/lora-gateway-bridge.service": "/usr/lib/lora-gateway-bridge/scripts/lora-gateway-bridge.service"
39+
config_files:
40+
"packaging/files/lora-gateway-bridge.toml": "/etc/lora-gateway-bridge/lora-gateway-bridge.toml"
3941
scripts:
4042
postinstall: "packaging/scripts/post-install.sh"
4143
postremove: "packaging/scripts/post-remove.sh"
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+

packaging/scripts/post-install.sh

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,47 @@ fi
3939
mkdir -p "$LOG_DIR"
4040
chown $DAEMON_USER:$DAEMON_GROUP "$LOG_DIR"
4141

42-
# create configuration directory
43-
if [[ ! -d /etc/$NAME ]]; then
44-
mkdir /etc/$NAME
45-
chown $DAEMON_USER:$DAEMON_GROUP /etc/$NAME
42+
# set the configuration owner / permissions
43+
if [[ -f /etc/$NAME/$NAME.toml ]]; then
44+
chown -R $DAEMON_USER:$DAEMON_GROUP /etc/$NAME
4645
chmod 750 /etc/$NAME
46+
chmod 640 /etc/$NAME/$NAME.toml
4747
fi
4848

49-
# create example configuration file
50-
if [[ ! -f /etc/$NAME/$NAME.toml ]]; then
51-
$NAME configfile > /etc/$NAME/$NAME.toml
52-
chown $DAEMON_USER:$DAEMON_GROUP /etc/$NAME/$NAME.toml
53-
chmod 640 /etc/$NAME/$NAME.toml
49+
# show message on install
50+
if [[ $? -eq 0 ]]; then
5451
echo -e "\n\n\n"
5552
echo "---------------------------------------------------------------------------------"
56-
echo "A sample configuration file has been copied to: /etc/$NAME/$NAME.toml"
57-
echo "After setting the correct values, run the following command to start $NAME:"
53+
echo "The configuration file is located at:"
54+
echo " /etc/$NAME/$NAME.toml"
55+
echo ""
56+
echo "Some helpful commands for $NAME:"
5857
echo ""
5958
which systemctl &>/dev/null
6059
if [[ $? -eq 0 ]]; then
61-
echo "$ sudo systemctl start $NAME"
60+
echo "Start:"
61+
echo " $ sudo systemctl start $NAME"
62+
echo ""
63+
echo "Restart:"
64+
echo " $ sudo systemctl restart $NAME"
65+
echo ""
66+
echo "Stop:"
67+
echo " $ sudo systemctl stop $NAME"
68+
echo ""
69+
echo "Display logs:"
70+
echo " $ sudo journalctl -f -n 100 -u $NAME"
6271
else
63-
echo "$ sudo /etc/init.d/$NAME start"
72+
echo "Start:"
73+
echo " $ sudo /etc/init.d/$NAME start"
74+
echo ""
75+
echo "Restart:"
76+
echo " $ sudo /etc/init.d/$NAME restart"
77+
echo ""
78+
echo "Stop:"
79+
echo " $ sudo /etc/init.d/$NAME stop"
80+
echo ""
81+
echo "Display logs:"
82+
echo " $ sudo tail -f -n 100 $LOG_DIR"
6483
fi
6584
echo "---------------------------------------------------------------------------------"
6685
echo -e "\n\n\n"
@@ -74,6 +93,7 @@ else
7493
install_init
7594
fi
7695

96+
# restart on upgrade
7797
if [[ -n $2 ]]; then
7898
restart_service
7999
fi

0 commit comments

Comments
 (0)