mirror of
https://github.com/aljazceru/addons.git
synced 2026-02-04 12:44:20 +01:00
Mqtt customize (#143)
* new options + version pump * add default options for include_dir * init customize configs * map share RO * Update run.sh * Update Dockerfile
This commit is contained in:
@@ -4,7 +4,7 @@ FROM %%BASE_IMAGE%%
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
# Setup base
|
||||
RUN apk add --no-cache tzdata jq mosquitto
|
||||
RUN apk add --no-cache jq mosquitto
|
||||
|
||||
# Copy data
|
||||
COPY run.sh /
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
{
|
||||
"name": "Mosquitto broker",
|
||||
"version": "0.8",
|
||||
"version": "1.0",
|
||||
"slug": "mosquitto",
|
||||
"description": "An Open Source MQTT broker",
|
||||
"url": "https://home-assistant.io/addons/mosquitto/",
|
||||
"startup": "before",
|
||||
"startup": "system",
|
||||
"boot": "auto",
|
||||
"ports": {
|
||||
"1883/tcp": 1883,
|
||||
"8883/tcp": 8883
|
||||
},
|
||||
"map": ["ssl"],
|
||||
"map": ["ssl", "share"],
|
||||
"options": {
|
||||
"plain": true,
|
||||
"ssl": false,
|
||||
"anonymous": true,
|
||||
"logins": [],
|
||||
"customize": {
|
||||
"active": false,
|
||||
"folder": "moquitto"
|
||||
},
|
||||
"certfile": "fullchain.pem",
|
||||
"keyfile": "privkey.pem"
|
||||
},
|
||||
@@ -26,6 +30,10 @@
|
||||
"logins": [
|
||||
{"username": "str", "password": "str"}
|
||||
],
|
||||
"customize": {
|
||||
"active": "bool",
|
||||
"folder": "str"
|
||||
},
|
||||
"certfile": "str",
|
||||
"keyfile": "str"
|
||||
},
|
||||
|
||||
@@ -16,3 +16,4 @@ persistence_location /data/
|
||||
# User settings
|
||||
#password_file /data/users.db
|
||||
#allow_anonymous false
|
||||
#include_dir /share/mosquitto
|
||||
|
||||
@@ -9,6 +9,7 @@ LOGINS=$(jq --raw-output ".logins | length" $CONFIG_PATH)
|
||||
ANONYMOUS=$(jq --raw-output ".anonymous" $CONFIG_PATH)
|
||||
KEYFILE=$(jq --raw-output ".keyfile" $CONFIG_PATH)
|
||||
CERTFILE=$(jq --raw-output ".certfile" $CONFIG_PATH)
|
||||
CUSTOMIZE_ACTIVE=$(jq --raw-output ".customize.active" $CONFIG_PATH)
|
||||
|
||||
PLAIN_CONFIG="
|
||||
listener 1883
|
||||
@@ -36,6 +37,12 @@ if [ "$ANONYMOUS" == "false" ]; then
|
||||
sed -i "s/#allow_anonymous/allow_anonymous/g" /etc/mosquitto.conf
|
||||
fi
|
||||
|
||||
# Allow customize configs from share
|
||||
if [ "$CUSTOMIZE_ACTIVE" == "true" ]; then
|
||||
CUSTOMIZE_FOLDER=$(jq --raw-output ".customize.folder" $CONFIG_PATH)
|
||||
sed -i "s|#include_dir .*|include_dir /share/$CUSTOMIZE_FOLDER|g" /etc/mosquitto.conf
|
||||
fi
|
||||
|
||||
# Generate user data
|
||||
if [ "$LOGINS" -gt "0" ]; then
|
||||
sed -i "s/#password_file/password_file/g" /etc/mosquitto.conf
|
||||
|
||||
Reference in New Issue
Block a user