Minor bug fix
This commit is contained in:
@@ -20,3 +20,7 @@
|
|||||||
## 0.2.3
|
## 0.2.3
|
||||||
|
|
||||||
- Minor bug fix
|
- Minor bug fix
|
||||||
|
|
||||||
|
## 0.2.4
|
||||||
|
|
||||||
|
- Minor bug fix
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: Visquitto
|
name: Visquitto
|
||||||
version: "0.2.3"
|
version: "0.2.4"
|
||||||
slug: visquitto
|
slug: visquitto
|
||||||
description: Second private Mosquitto broker for bitopa nodes
|
description: Second private Mosquitto broker for bitopa nodes
|
||||||
arch:
|
arch:
|
||||||
|
|||||||
+12
-23
@@ -4,18 +4,17 @@ set -e
|
|||||||
CONFIG=/config
|
CONFIG=/config
|
||||||
SHARE=/share/visquitto
|
SHARE=/share/visquitto
|
||||||
PASSWD=/data/passwd
|
PASSWD=/data/passwd
|
||||||
|
CERTDIR=/data/certs
|
||||||
FINAL=/tmp/mosquitto.conf
|
FINAL=/tmp/mosquitto.conf
|
||||||
|
|
||||||
mkdir -p "$SHARE" /data/mosquitto
|
mkdir -p "$SHARE" /data/mosquitto "$CERTDIR"
|
||||||
chown -R mosquitto:mosquitto /data/mosquitto
|
chown -R mosquitto:mosquitto /data/mosquitto
|
||||||
|
|
||||||
CAFILE=$(jq -r '.cafile' /data/options.json)
|
CAFILE=$(jq -r '.cafile' /data/options.json)
|
||||||
CERTFILE=$(jq -r '.certfile' /data/options.json)
|
CERTFILE=$(jq -r '.certfile' /data/options.json)
|
||||||
KEYFILE=$(jq -r '.keyfile' /data/options.json)
|
KEYFILE=$(jq -r '.keyfile' /data/options.json)
|
||||||
|
|
||||||
CERTDIR=/data/certs
|
# ---- Certificates: copied at every start, readable by mosquitto ----
|
||||||
mkdir -p "$CERTDIR"
|
|
||||||
|
|
||||||
for f in "$CAFILE" "$CERTFILE" "$KEYFILE"; do
|
for f in "$CAFILE" "$CERTFILE" "$KEYFILE"; do
|
||||||
[ -f "/ssl/$f" ] || { echo "Missing /ssl/$f" >&2; exit 1; }
|
[ -f "/ssl/$f" ] || { echo "Missing /ssl/$f" >&2; exit 1; }
|
||||||
done
|
done
|
||||||
@@ -28,7 +27,6 @@ chmod 644 "$CERTDIR/ca.pem" "$CERTDIR/cert.pem"
|
|||||||
chmod 600 "$CERTDIR/key.pem"
|
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
|
||||||
allow_anonymous false
|
allow_anonymous false
|
||||||
password_file $PASSWD
|
password_file $PASSWD
|
||||||
@@ -38,34 +36,27 @@ persistence_location /data/mosquitto/
|
|||||||
listener 1993
|
listener 1993
|
||||||
|
|
||||||
listener 9993
|
listener 9993
|
||||||
cafile /ssl/$CAFILE
|
cafile $CERTDIR/ca.pem
|
||||||
certfile /ssl/$CERTFILE
|
certfile $CERTDIR/cert.pem
|
||||||
keyfile /ssl/$KEYFILE
|
keyfile $CERTDIR/key.pem
|
||||||
tls_version tlsv1.2
|
tls_version tlsv1.2
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Default ACL file: used only if the user's acl file doesn't set acl_file
|
|
||||||
cat > "$CONFIG/acl" <<EOF
|
cat > "$CONFIG/acl" <<EOF
|
||||||
acl_file $CONFIG/accesscontrollist
|
acl_file $CONFIG/accesscontrollist
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Default access control list: grants nothing
|
|
||||||
cat > "$CONFIG/accesscontrollist" <<EOF
|
cat > "$CONFIG/accesscontrollist" <<EOF
|
||||||
# Default ACL: no rules, all access denied
|
# Default ACL: no rules, all access denied
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# ---- User customization in /share (created once, never overwritten) ----
|
# ---- User customization in /share (created once, never overwritten) ----
|
||||||
|
|
||||||
if [ ! -f "$SHARE/mosquitto.conf" ]; then
|
if [ ! -f "$SHARE/mosquitto.conf" ]; then
|
||||||
cat > "$SHARE/mosquitto.conf" <<EOF
|
echo "# Extra Mosquitto options, appended to the default config" > "$SHARE/mosquitto.conf"
|
||||||
# Extra Mosquitto options, appended to the default config
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$SHARE/acl" ]; then
|
if [ ! -f "$SHARE/acl" ]; then
|
||||||
cat > "$SHARE/acl" <<EOF
|
echo "acl_file /share/visquitto/accesscontrollist" > "$SHARE/acl"
|
||||||
acl_file /share/visquitto/accesscontrollist
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$SHARE/accesscontrollist" ]; then
|
if [ ! -f "$SHARE/accesscontrollist" ]; then
|
||||||
@@ -76,13 +67,12 @@ if [ ! -f "$SHARE/accesscontrollist" ]; then
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown mosquitto:mosquitto "$SHARE/mosquitto.conf" "$SHARE/acl" "$SHARE/accesscontrollist"
|
chown mosquitto:mosquitto "$SHARE/mosquitto.conf" "$SHARE/acl" "$SHARE/accesscontrollist" \
|
||||||
chown mosquitto:mosquitto "$CONFIG/acl" "$CONFIG/accesscontrollist"
|
"$CONFIG/acl" "$CONFIG/accesscontrollist"
|
||||||
chmod 600 "$SHARE/accesscontrollist" "$SHARE/acl" "$CONFIG/accesscontrollist" "$CONFIG/acl"
|
chmod 600 "$SHARE/acl" "$SHARE/accesscontrollist" "$CONFIG/acl" "$CONFIG/accesscontrollist"
|
||||||
chmod 644 "$SHARE/mosquitto.conf"
|
chmod 644 "$SHARE/mosquitto.conf"
|
||||||
|
|
||||||
# ---- Users from the panel ----
|
# ---- Users from the panel ----
|
||||||
|
|
||||||
rm -f "$PASSWD"
|
rm -f "$PASSWD"
|
||||||
touch "$PASSWD"
|
touch "$PASSWD"
|
||||||
jq -r '.users[] | [.username, .password] | @tsv' /data/options.json |
|
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
|
[ -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"
|
cat "$CONFIG/mosquitto.conf" > "$FINAL"
|
||||||
echo >> "$FINAL"
|
echo >> "$FINAL"
|
||||||
cat "$SHARE/mosquitto.conf" >> "$FINAL"
|
cat "$SHARE/mosquitto.conf" >> "$FINAL"
|
||||||
|
|||||||
Reference in New Issue
Block a user