Minor bug fix
This commit is contained in:
@@ -20,3 +20,7 @@
|
||||
## 0.2.3
|
||||
|
||||
- Minor bug fix
|
||||
|
||||
## 0.2.4
|
||||
|
||||
- Minor bug fix
|
||||
|
||||
@@ -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:
|
||||
|
||||
+12
-23
@@ -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" <<EOF
|
||||
allow_anonymous false
|
||||
password_file $PASSWD
|
||||
@@ -38,34 +36,27 @@ persistence_location /data/mosquitto/
|
||||
listener 1993
|
||||
|
||||
listener 9993
|
||||
cafile /ssl/$CAFILE
|
||||
certfile /ssl/$CERTFILE
|
||||
keyfile /ssl/$KEYFILE
|
||||
cafile $CERTDIR/ca.pem
|
||||
certfile $CERTDIR/cert.pem
|
||||
keyfile $CERTDIR/key.pem
|
||||
tls_version tlsv1.2
|
||||
EOF
|
||||
|
||||
# Default ACL file: used only if the user's acl file doesn't set acl_file
|
||||
cat > "$CONFIG/acl" <<EOF
|
||||
acl_file $CONFIG/accesscontrollist
|
||||
EOF
|
||||
|
||||
# Default access control list: grants nothing
|
||||
cat > "$CONFIG/accesscontrollist" <<EOF
|
||||
# Default ACL: no rules, all access denied
|
||||
EOF
|
||||
|
||||
# ---- User customization in /share (created once, never overwritten) ----
|
||||
|
||||
if [ ! -f "$SHARE/mosquitto.conf" ]; then
|
||||
cat > "$SHARE/mosquitto.conf" <<EOF
|
||||
# Extra Mosquitto options, appended to the default config
|
||||
EOF
|
||||
echo "# Extra Mosquitto options, appended to the default config" > "$SHARE/mosquitto.conf"
|
||||
fi
|
||||
|
||||
if [ ! -f "$SHARE/acl" ]; then
|
||||
cat > "$SHARE/acl" <<EOF
|
||||
acl_file /share/visquitto/accesscontrollist
|
||||
EOF
|
||||
echo "acl_file /share/visquitto/accesscontrollist" > "$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"
|
||||
|
||||
Reference in New Issue
Block a user