From 3c6d596d1888c76d805e981abef9ec7143b051d7 Mon Sep 17 00:00:00 2001 From: ludeeus Date: Sun, 12 May 2019 13:22:26 +0200 Subject: [PATCH] Fix premission issues when 'allow_anonymous' is enabled --- mqtt/rootfs/etc/cont-init.d/mosquitto.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mqtt/rootfs/etc/cont-init.d/mosquitto.sh b/mqtt/rootfs/etc/cont-init.d/mosquitto.sh index 69a6e90..88d8450 100644 --- a/mqtt/rootfs/etc/cont-init.d/mosquitto.sh +++ b/mqtt/rootfs/etc/cont-init.d/mosquitto.sh @@ -39,8 +39,6 @@ bashio::log.info 'Adding configuration for MQTT Server...' echo "log_type websockets"; echo "persistence true"; echo "persistence_location $PERSISTENCE_LOCATION"; - echo "acl_file $ACL_FILE"; - echo "password_file $PWFILE"; echo "listener 1883" echo "protocol mqtt" echo "listener 1884"; @@ -48,6 +46,17 @@ bashio::log.info 'Adding configuration for MQTT Server...' echo "socket_domain ipv4"; } > "$CONFIG" +# Allow anonymous auth? +if bashio::config.true 'allow_anonymous'; then + echo "allow_anonymous true" >> "$CONFIG" +else + { + echo "allow_anonymous false"; + echo "acl_file $ACL_FILE"; + echo "password_file $PWFILE"; + } >> "$CONFIG" +fi + # Set SSL configurtations if bashio::config.true 'ssl'; then { @@ -65,13 +74,6 @@ if bashio::config.true 'ssl'; then } >> "$CONFIG" fi -# Allow anonymous auth? -if bashio::config.true 'allow_anonymous'; then - echo "allow_anonymous true" >> "$CONFIG" -else - echo "allow_anonymous false" >> "$CONFIG" -fi - # Set username and password for the broker for user in $(bashio::config 'mqttusers|keys'); do bashio::config.require.username "mqttusers[${user}].username"