From 65138b04e7df19b5c5f181e54f1730f80e783a75 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sun, 20 Mar 2022 23:45:27 +0200 Subject: [PATCH] fix(zigbee2mqtt): create an initial file (#2233) * fix(zigbee2mqtt): create an initial file * empty vars * isntall * empty vars * dummy * tst non empty * whops * test * skip insatll * Update charts/stable/zigbee2mqtt/values.yaml --- charts/stable/zigbee2mqtt/Chart.yaml | 2 +- charts/stable/zigbee2mqtt/questions.yaml | 4 +- charts/stable/zigbee2mqtt/values.yaml | 64 ++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/charts/stable/zigbee2mqtt/Chart.yaml b/charts/stable/zigbee2mqtt/Chart.yaml index d095bed81c2..d024fa67de5 100644 --- a/charts/stable/zigbee2mqtt/Chart.yaml +++ b/charts/stable/zigbee2mqtt/Chart.yaml @@ -19,7 +19,7 @@ maintainers: name: zigbee2mqtt sources: - https://github.com/Koenkk/zigbee2mqtt -version: 2.0.7 +version: 2.0.8 annotations: truecharts.org/catagories: | - media diff --git a/charts/stable/zigbee2mqtt/questions.yaml b/charts/stable/zigbee2mqtt/questions.yaml index 46f4eaccfa5..aa57a6a6568 100644 --- a/charts/stable/zigbee2mqtt/questions.yaml +++ b/charts/stable/zigbee2mqtt/questions.yaml @@ -205,7 +205,7 @@ questions: description: "The internal(!) port on the container the Application runs on" schema: type: int - default: 8080 + default: 10103 - variable: serviceexpert group: "Networking and Services" @@ -327,7 +327,7 @@ questions: label: "ReadOnly Root Filesystem" schema: type: boolean - default: true + default: false - variable: allowPrivilegeEscalation label: "Allow Privilege Escalation" schema: diff --git a/charts/stable/zigbee2mqtt/values.yaml b/charts/stable/zigbee2mqtt/values.yaml index 89402e701ab..093350786ce 100644 --- a/charts/stable/zigbee2mqtt/values.yaml +++ b/charts/stable/zigbee2mqtt/values.yaml @@ -20,6 +20,7 @@ env: securityContext: runAsNonRoot: false + readOnlyRootFilesystem: false podSecurityContext: runAsUser: 0 @@ -35,3 +36,66 @@ persistence: data: enabled: true mountPath: "/data" + +initContainers: + init-config: + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + volumeMounts: + - name: data + mountPath: "/data" + env: + - name: ZIGBEE2MQTT_CONFIG_FRONTEND_PORT + value: "{{ .Values.service.main.ports.main.port }}" + - name: ZIGBEE2MQTT_CONFIG_EXPIRIMENTAL_NEW_API + value: "{{ .Values.env.ZIGBEE2MQTT_CONFIG_EXPIRIMENTAL_NEW_API }}" + - name: ZIGBEE2MQTT_CONFIG_PERMIT_JOIN + value: "{{ .Values.env.ZIGBEE2MQTT_CONFIG_PERMIT_JOIN }}" + - name: ZIGBEE2MQTT_CONFIG_EXPIRIMENTAL_NEW_API + value: "{{ .Values.env.ZIGBEE2MQTT_CONFIG_EXPIRIMENTAL_NEW_API }}" + - name: ZIGBEE2MQTT_CONFIG_MQTT_SERVER + value: "{{ .Values.env.ZIGBEE2MQTT_CONFIG_MQTT_SERVER }}" + - name: ZIGBEE2MQTT_CONFIG_MQTT_USER + value: "{{ .Values.secret.ZIGBEE2MQTT_CONFIG_MQTT_USER }}" + - name: ZIGBEE2MQTT_CONFIG_MQTT_PASSWORD + value: "{{ .Values.secret.ZIGBEE2MQTT_CONFIG_MQTT_PASSWORD }}" + - name: ZIGBEE2MQTT_CONFIG_MQTT_BASE_TOPIC + value: "{{ .Values.env.ZIGBEE2MQTT_CONFIG_MQTT_BASE_TOPIC }}" + - name: ZIGBEE2MQTT_CONFIG_SERIAL_PORT + value: "{{ .Values.env.ZIGBEE2MQTT_CONFIG_SERIAL_PORT }}" + - name: ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER + value: "{{ .Values.env.ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER }}" + command: ["/bin/sh", "-c"] + args: + - > + if [ -f /data/configuration.yaml ]; + then + echo "Initial configuration exists. Skipping"; + else + echo "Creating initial configuration"; + touch /data/configuration.yaml; + echo "# Configuration bellow will be always be overridden" >> /data/configuration.yaml; + echo "# from environment settings on the Scale Apps UI." >> /data/configuration.yaml; + echo "# You however will not see this values change in the file." >> /data/configuration.yaml; + echo "##########################################################" >> /data/configuration.yaml; + echo "experimental:" >> /data/configuration.yaml; + echo " new_api: $ZIGBEE2MQTT_CONFIG_EXPIRIMENTAL_NEW_API" >> /data/configuration.yaml; + echo "frontend:" >> /data/configuration.yaml; + echo " port: $ZIGBEE2MQTT_CONFIG_FRONTEND_PORT" >> /data/configuration.yaml; + echo "permit_join: $ZIGBEE2MQTT_CONFIG_PERMIT_JOIN" >> /data/configuration.yaml; + echo "mqtt:" >> /data/configuration.yaml; + echo " server: $ZIGBEE2MQTT_CONFIG_MQTT_SERVER" >> /data/configuration.yaml; + echo " base_topic: $ZIGBEE2MQTT_CONFIG_MQTT_BASE_TOPIC" >> /data/configuration.yaml; + if [ ! -z "$ZIGBEE2MQTT_CONFIG_MQTT_USER" ]; + then + echo " user: $ZIGBEE2MQTT_CONFIG_MQTT_USER" >> /data/configuration.yaml; + fi; + if [ ! -z "$ZIGBEE2MQTT_CONFIG_MQTT_PASSWORD" ]; + then + echo " password: $ZIGBEE2MQTT_CONFIG_MQTT_PASSWORD" >> /data/configuration.yaml; + fi; + echo "serial:" >> /data/configuration.yaml; + echo " port: $ZIGBEE2MQTT_CONFIG_SERIAL_PORT" >> /data/configuration.yaml; + echo " adapter: $ZIGBEE2MQTT_CONFIG_SERIAL_ADAPTER" >> /data/configuration.yaml; + echo "##########################################################" >> /data/configuration.yaml; + echo 'Initial configuration file created at "/data/configuration.yaml"'; + fi;