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"