|
|
@@ -34,9 +34,6 @@ chmod 600 "$CERTDIR/key.pem"
|
|
|
|
|
|
|
|
|
|
|
|
# ---- Defaults in /config (regenerated at every start) ----
|
|
|
|
# ---- Defaults in /config (regenerated at every start) ----
|
|
|
|
cat > "$CONFIG/mosquitto.conf" <<EOF
|
|
|
|
cat > "$CONFIG/mosquitto.conf" <<EOF
|
|
|
|
protocol mqtt
|
|
|
|
|
|
|
|
allow_anonymous false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log_dest stdout
|
|
|
|
log_dest stdout
|
|
|
|
log_type error
|
|
|
|
log_type error
|
|
|
|
log_type warning
|
|
|
|
log_type warning
|
|
|
@@ -47,7 +44,7 @@ persistence true
|
|
|
|
persistence_location $DATA/
|
|
|
|
persistence_location $DATA/
|
|
|
|
max_queued_messages 8192
|
|
|
|
max_queued_messages 8192
|
|
|
|
|
|
|
|
|
|
|
|
plugin_load acl_file /usr/lib/mosquitto_acl_file.so
|
|
|
|
plugin_load acl_file /usr/lib/mosquitto_acl_file.so
|
|
|
|
plugin_load password_file /usr/lib/mosquitto_password_file.so
|
|
|
|
plugin_load password_file /usr/lib/mosquitto_password_file.so
|
|
|
|
|
|
|
|
|
|
|
|
include_dir $SHARE
|
|
|
|
include_dir $SHARE
|
|
|
@@ -55,6 +52,7 @@ include_dir $SHARE
|
|
|
|
# Plain listener (host port 1993): password users only
|
|
|
|
# Plain listener (host port 1993): password users only
|
|
|
|
listener 1883
|
|
|
|
listener 1883
|
|
|
|
protocol mqtt
|
|
|
|
protocol mqtt
|
|
|
|
|
|
|
|
allow_anonymous false
|
|
|
|
plugin_use password_file
|
|
|
|
plugin_use password_file
|
|
|
|
plugin_opt_password_file $PASSWD
|
|
|
|
plugin_opt_password_file $PASSWD
|
|
|
|
plugin_use acl_file
|
|
|
|
plugin_use acl_file
|
|
|
@@ -63,6 +61,7 @@ plugin_opt_acl_file $DATA/acl_plain
|
|
|
|
# TLS listener (host port 9993): client certificate required
|
|
|
|
# TLS listener (host port 9993): client certificate required
|
|
|
|
listener 8883
|
|
|
|
listener 8883
|
|
|
|
protocol mqtt
|
|
|
|
protocol mqtt
|
|
|
|
|
|
|
|
allow_anonymous false
|
|
|
|
cafile $CERTDIR/ca.pem
|
|
|
|
cafile $CERTDIR/ca.pem
|
|
|
|
certfile $CERTDIR/cert.pem
|
|
|
|
certfile $CERTDIR/cert.pem
|
|
|
|
keyfile $CERTDIR/key.pem
|
|
|
|
keyfile $CERTDIR/key.pem
|
|
|
@@ -76,7 +75,6 @@ plugin_opt_acl_file $DATA/acl_tls
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
# plain ACL
|
|
|
|
# plain ACL
|
|
|
|
echo "# Default ACL for the plain listener: no rules, all access denied" > "$CONFIG/acl_plain"
|
|
|
|
|
|
|
|
cat > "$CONFIG/acl_plain" <<EOF
|
|
|
|
cat > "$CONFIG/acl_plain" <<EOF
|
|
|
|
# ============================================================
|
|
|
|
# ============================================================
|
|
|
|
# Not certified devices
|
|
|
|
# Not certified devices
|
|
|
@@ -100,13 +98,17 @@ topic read cert/enroll/+/renew
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
# TLS ACL
|
|
|
|
# TLS ACL
|
|
|
|
echo "# Default ACL for the TLS listener: no rules, all access denied" > "$CONFIG/acl_tls"
|
|
|
|
|
|
|
|
cat > "$CONFIG/acl_tls" <<EOF
|
|
|
|
cat > "$CONFIG/acl_tls" <<EOF
|
|
|
|
# Default rule for every certificate client. %u is the certificate CN.
|
|
|
|
# Default rule for every certificate client. %u is the certificate CN.
|
|
|
|
pattern readwrite clients/%u/#
|
|
|
|
pattern readwrite clients/%u/#
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
# ---- User customization in /share (created once, never overwritten) ----
|
|
|
|
# ---- User customization in /share (created once, never overwritten) ----
|
|
|
|
|
|
|
|
if grep -qE '^\s*(listener|port|bind_address)\b' "$SHARE/mosquitto.conf"; then
|
|
|
|
|
|
|
|
echo "ERROR: $SHARE/mosquitto.conf must not define listeners (listener/port/bind_address)." >&2
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f "$SHARE/mosquitto.conf" ]; then
|
|
|
|
if [ ! -f "$SHARE/mosquitto.conf" ]; then
|
|
|
|
echo "# Extra global Mosquitto options (loaded with include_dir, before the listeners)" > "$SHARE/mosquitto.conf"
|
|
|
|
echo "# Extra global Mosquitto options (loaded with include_dir, before the listeners)" > "$SHARE/mosquitto.conf"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|