-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enables authentication for MQTT
fixes #13
- Loading branch information
1 parent
e4c664a
commit a3ded95
Showing
15 changed files
with
82 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
FROM arm64v8/eclipse-mosquitto:2.0.10 | ||
FROM arm64v8/eclipse-mosquitto:2.0.14 | ||
|
||
COPY mosquitto.conf /mosquitto/config/mosquitto.conf | ||
COPY mosquitto.conf /mosquitto/config/mosquitto.conf | ||
COPY docker-entrypoint.sh . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/ash | ||
set -e | ||
|
||
# Configure auth | ||
if [[ -z "${MQTT_USER}" || -z "${MQTT_PASSWORD}" ]]; then | ||
echo "Using un-authenticated configuration" | ||
else | ||
echo "Configruing username/password authentication" | ||
sed -i -e 's/^#password_file$/password_file \/mosquitto\/config\/passwd/g' -e 's/^allow_anonymous true$/allow_anonymous false/' /mosquitto/config/mosquitto.conf | ||
mosquitto_passwd -c -b /mosquitto/config/passwd "${MQTT_USER}" "${MQTT_PASSWORD}" | ||
fi | ||
|
||
# Set permissions | ||
user="$(id -u)" | ||
if [ "$user" = '0' ]; then | ||
[ -d "/mosquitto" ] && chown -R mosquitto:mosquitto /mosquitto || true | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# NGINX | ||
|
||
This container configures NGINX as a reverse proxy on the externally URL of the application. | ||
The proxy at the moment either routes to the Grafana dashboard or to the MQTT queue. | ||
The proxy at the moment either routes to the [Grafana dashboard](../dashboard/README.md) or to the[MQTT server](../mqtt/README.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
FROM arm64v8/telegraf:1.15.4 | ||
FROM telegraf:1.19 | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y vim netcat \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY telegraf.conf /etc/telegraf/telegraf.conf | ||
COPY entrypoint.sh /entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Configure auth | ||
if [[ -z "${MQTT_USER}" || -z "${MQTT_PASSWORD}" ]]; then | ||
echo "Using un-authenticated configuration" | ||
else | ||
echo "Configuring username/password authentication" | ||
sed -i -e 's/^ # username =.*/ username = \"'"${MQTT_USER}"'\"/g' -e 's/^ # password =.*/ password = \"'"${MQTT_PASSWORD}"'\"/g' /etc/telegraf/telegraf.conf | ||
fi | ||
|
||
if [ "${1:0:1}" = '-' ]; then | ||
set -- telegraf "$@" | ||
fi | ||
|
||
if [ $EUID -ne 0 ]; then | ||
exec "$@" | ||
else | ||
# Allow telegraf to send ICMP packets and bind to privliged ports | ||
setcap cap_net_raw,cap_net_bind_service+ep /usr/bin/telegraf || echo "Failed to set additional capabilities on /usr/bin/telegraf" | ||
|
||
exec setpriv --reuid telegraf --init-groups "$@" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters