-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Add user and password options
- Loading branch information
Showing
4 changed files
with
28 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
FROM eclipse-mosquitto | ||
RUN apk add --no-cache mosquitto-clients | ||
COPY entrypoint.sh /entrypoint.sh | ||
COPY .mqtt/mosquitto.conf /mosquitto/config/mosquitto.conf | ||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
EXPOSE 1883 | ||
EXPOSE 9001 |
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,13 @@ | ||
#!/bin/sh | ||
if [ ! -f /mosquitto/config/pwfile ]; then | ||
if [ -n "$USER" ] && [ -n "$PASSWORD" ]; then | ||
mosquitto_passwd -b -c /mosquitto/config/pwfile "$USER" "$PASSWORD" | ||
chmod 700 /mosquitto/config/pwfile | ||
chown mosquitto:mosquitto /mosquitto/config/pwfile | ||
echo "password_file /mosquitto/config/pwfile" >> /mosquitto/config/mosquitto.conf | ||
echo "allow_anonymous false" >> /mosquitto/config/mosquitto.conf | ||
else | ||
echo "allow_anonymous true" >> /mosquitto/config/mosquitto.conf | ||
fi | ||
fi | ||
exec mosquitto -c /mosquitto/config/mosquitto.conf |