Skip to content

Commit

Permalink
[FEAT] JSON with credentials, log of tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
ggfto committed Feb 21, 2024
1 parent 8673d71 commit 6caf1a8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/bin/sh
if [ ! -f /mosquitto/config/pwfile ]; then
echo "pwfile not present..."
if [ -n "$USER" ] && [ -n "$PASSWORD" ]; then
echo "setting up credentials..."
mosquitto_passwd -b -c /mosquitto/config/pwfile "$USER" "$PASSWORD"
echo "{'user':'$USER','pass':'$PASSWORD'}" >> /home/mqtt_auth.json
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 "setting up anonymous mode..."
echo "allow_anonymous true" >> /mosquitto/config/mosquitto.conf
fi
else
echo "pwfile present, skipping credential configuration...
fi
exec mosquitto -c /mosquitto/config/mosquitto.conf

0 comments on commit 6caf1a8

Please sign in to comment.