From 7772e489e0e336bf427527aefe49ce7f5b9ac255 Mon Sep 17 00:00:00 2001 From: Saman Sajedi Date: Mon, 5 Oct 2026 15:36:44 +0330 Subject: [PATCH] Minor bug fix --- visquitto/CHANGELOG.md | 4 ++++ visquitto/config.yaml | 2 +- visquitto/run.sh | 35 ++++++++++++----------------------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/visquitto/CHANGELOG.md b/visquitto/CHANGELOG.md index 9ca0f94..14817b4 100644 --- a/visquitto/CHANGELOG.md +++ b/visquitto/CHANGELOG.md @@ -20,3 +20,7 @@ ## 0.2.3 - Minor bug fix + +## 0.2.4 + +- Minor bug fix diff --git a/visquitto/config.yaml b/visquitto/config.yaml index 0e5448c..2798d39 100644 --- a/visquitto/config.yaml +++ b/visquitto/config.yaml @@ -1,5 +1,5 @@ name: Visquitto -version: "0.2.3" +version: "0.2.4" slug: visquitto description: Second private Mosquitto broker for bitopa nodes arch: diff --git a/visquitto/run.sh b/visquitto/run.sh index 5e062c7..66a7312 100644 --- a/visquitto/run.sh +++ b/visquitto/run.sh @@ -4,18 +4,17 @@ set -e CONFIG=/config SHARE=/share/visquitto PASSWD=/data/passwd +CERTDIR=/data/certs FINAL=/tmp/mosquitto.conf -mkdir -p "$SHARE" /data/mosquitto +mkdir -p "$SHARE" /data/mosquitto "$CERTDIR" chown -R mosquitto:mosquitto /data/mosquitto CAFILE=$(jq -r '.cafile' /data/options.json) CERTFILE=$(jq -r '.certfile' /data/options.json) KEYFILE=$(jq -r '.keyfile' /data/options.json) -CERTDIR=/data/certs -mkdir -p "$CERTDIR" - +# ---- Certificates: copied at every start, readable by mosquitto ---- for f in "$CAFILE" "$CERTFILE" "$KEYFILE"; do [ -f "/ssl/$f" ] || { echo "Missing /ssl/$f" >&2; exit 1; } done @@ -28,7 +27,6 @@ chmod 644 "$CERTDIR/ca.pem" "$CERTDIR/cert.pem" chmod 600 "$CERTDIR/key.pem" # ---- Defaults in /config (regenerated at every start) ---- - cat > "$CONFIG/mosquitto.conf" < "$CONFIG/acl" < "$CONFIG/accesscontrollist" < "$SHARE/mosquitto.conf" < "$SHARE/mosquitto.conf" fi if [ ! -f "$SHARE/acl" ]; then - cat > "$SHARE/acl" < "$SHARE/acl" fi if [ ! -f "$SHARE/accesscontrollist" ]; then @@ -76,13 +67,12 @@ if [ ! -f "$SHARE/accesscontrollist" ]; then EOF fi -chown mosquitto:mosquitto "$SHARE/mosquitto.conf" "$SHARE/acl" "$SHARE/accesscontrollist" -chown mosquitto:mosquitto "$CONFIG/acl" "$CONFIG/accesscontrollist" -chmod 600 "$SHARE/accesscontrollist" "$SHARE/acl" "$CONFIG/accesscontrollist" "$CONFIG/acl" +chown mosquitto:mosquitto "$SHARE/mosquitto.conf" "$SHARE/acl" "$SHARE/accesscontrollist" \ + "$CONFIG/acl" "$CONFIG/accesscontrollist" +chmod 600 "$SHARE/acl" "$SHARE/accesscontrollist" "$CONFIG/acl" "$CONFIG/accesscontrollist" chmod 644 "$SHARE/mosquitto.conf" # ---- Users from the panel ---- - rm -f "$PASSWD" touch "$PASSWD" jq -r '.users[] | [.username, .password] | @tsv' /data/options.json | @@ -94,8 +84,7 @@ chmod 600 "$PASSWD" [ -s "$PASSWD" ] || echo "Warning: no users defined, nobody can log in" >&2 -# ---- Build the final config: defaults + user config + ACL ---- - +# ---- Final config: defaults + user config + ACL ---- cat "$CONFIG/mosquitto.conf" > "$FINAL" echo >> "$FINAL" cat "$SHARE/mosquitto.conf" >> "$FINAL"