Skip to content

Commit cd5eda0

Browse files
Merge pull request #10 from waggle-sensor/switch-device-templates
Periodic pull and update device templates
2 parents 7ab1def + 8801456 commit cd5eda0

3 files changed

Lines changed: 38 additions & 11 deletions

File tree

Dockerfile

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
1+
# If you migrate to chirpstack=>4.7v, a migration needs to be done
2+
#check this: https://www.chirpstack.io/docs/chirpstack/changelog.html#v470
13
FROM chirpstack/chirpstack:4.6
24

3-
ENV TTN_REPO=https://github.com/TheThingsNetwork/lorawan-devices
4-
ENV TTN_VERSION=277e69a79347ceba2593e1da08117d0e3329ecda
5+
ENV DEVICE_TEMPLATES_REPO=https://github.com/waggle-sensor/wes-lorawan-device-templates
6+
ENV TARGET_DIR=/opt/lorawan-devices
57

68
USER root
79

8-
RUN apk update && apk add --no-cache git
10+
# Install packages
11+
RUN apk update && apk add --no-cache git bash sudo
912

10-
RUN git clone ${TTN_REPO} -b master --single-branch /opt/lorawan-devices ; \
11-
cd /opt/lorawan-devices ; \
12-
git checkout ${TTN_VERSION} ; \
13-
rm -rf .git
13+
# clone DEVICE_TEMPLATES_REPO
14+
RUN git clone ${DEVICE_TEMPLATES_REPO} -b master --single-branch ${TARGET_DIR}
15+
16+
# Copy script into the container
17+
COPY device-templates.sh /usr/local/bin/device-templates.sh
18+
19+
# add crond to be used with sudo by nobody user &
20+
# add global env vars to be used in cron &
21+
# Set permissions &
22+
# Set up cron job
23+
RUN echo 'nobody ALL=(ALL) NOPASSWD: /usr/sbin/crond' > /etc/sudoers && \
24+
printenv > /etc/environment && \
25+
chown -R nobody:nogroup ${TARGET_DIR} /etc/environment && \
26+
chmod 755 /usr/local/bin/device-templates.sh && \
27+
echo '0 * * * * /usr/local/bin/device-templates.sh' > /etc/crontabs/root
1428

1529
# restore the running as `nobody` as is defined by chirpstack docker image
1630
USER nobody:nogroup

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Waggle Edge Stack Chirpstack Application Server
22

3-
This is an extension of the [Chirpstack Appliction Server (v4)](https://www.chirpstack.io/docs/chirpstack/changelog.html) adding [The Things Network LoRaWAN device profile templates](https://github.com/TheThingsNetwork/lorawan-devices).
3+
This is an extension of the [Chirpstack Appliction Server (v4)](https://www.chirpstack.io/docs/chirpstack/changelog.html) adding [Waggle's LoRaWAN device profile templates](https://github.com/waggle-sensor/wes-lorawan-device-templates).
44

5-
This project simply clones the The Things Network LoRaWAN github repository into the Chirpstack application server Docker image, allowing for the LoRaWAN device profiles to be imported.
6-
7-
> Note: the specific version chosen of the [The Things Network LoRaWAN device profile templates](https://github.com/TheThingsNetwork/lorawan-devices) was the last version that had `Apache License 2.0`. Newer version cannot be replicated. You are, however, permitted to reuse or extract information about an individual end device.
5+
This project clones our LoRaWAN device profile templates into the Chirpstack application server Docker image, allowing for the LoRaWAN device profiles to be periodically pulled and imported to chirpstack.
86

97
References:
108
- https://www.chirpstack.io/docs/chirpstack/use/device-profile-templates.html

device-templates.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash -l
2+
3+
# Clone or update the repository
4+
if [ ! -d "$TARGET_DIR" ]; then
5+
echo "device-templates: Cloning repository $DEVICE_TEMPLATES_REPO to $TARGET_DIR"
6+
git clone "$DEVICE_TEMPLATES_REPO" -b master --single-branch "$TARGET_DIR"
7+
else
8+
echo "device-templates: Updating repository in $TARGET_DIR"
9+
cd "$TARGET_DIR"
10+
git pull
11+
fi
12+
13+
# Run the Chirpstack command to import device templates
14+
echo "device-templates: Running Chirpstack import device-templates command"
15+
chirpstack -c /etc/chirpstack-waggle import-legacy-lorawan-devices-repository -d "$TARGET_DIR"

0 commit comments

Comments
 (0)