From 0453f888032c3bf4c3c879c9414f562716efb351 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Sun, 21 Jan 2024 18:15:29 +0200 Subject: [PATCH] chore(home-assistant): update db url always (#17460) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Description** ⚒️ Fixes # **⚙️ Type of change** - [ ] ⚙️ Feature/App addition - [ ] 🪛 Bugfix - [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] 🔃 Refactor of current code **🧪 How Has This Been Tested?** **📃 Notes:** **✔️ Checklist:** - [ ] ⚖️ My code follows the style guidelines of this project - [ ] 👀 I have performed a self-review of my own code - [ ] #️⃣ I have commented my code, particularly in hard-to-understand areas - [ ] 📄 I have made corresponding changes to the documentation - [ ] ⚠️ My changes generate no new warnings - [ ] 🧪 I have added tests to this description that prove my fix is effective or that my feature works - [ ] ⬆️ I increased versions for any altered app according to semantic versioning **➕ App addition** If this PR is an app addition please make sure you have done the following. - [ ] 🖼️ I have added an icon in the Chart's root directory called `icon.png` --- _Please don't blindly check all the boxes. Read them and only check those that apply. Those checkboxes are there for the reviewer to see what is this all about and the status of this PR with a quick glance._ --- charts/stable/home-assistant/Chart.yaml | 4 +- charts/stable/home-assistant/values.yaml | 47 +++++++++++------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/charts/stable/home-assistant/Chart.yaml b/charts/stable/home-assistant/Chart.yaml index c054bc2d5c9..00bc9f841d4 100644 --- a/charts/stable/home-assistant/Chart.yaml +++ b/charts/stable/home-assistant/Chart.yaml @@ -10,7 +10,7 @@ apiVersion: v2 appVersion: 2024.1.5 dependencies: - name: common - version: 17.2.22 + version: 17.2.27 repository: oci://tccr.io/truecharts condition: "" alias: "" @@ -36,4 +36,4 @@ sources: - https://github.com/truecharts/charts/tree/master/charts/stable/home-assistant - https://hub.docker.com/r/homeassistant/home-assistant type: application -version: 23.0.7 +version: 23.0.8 diff --git a/charts/stable/home-assistant/values.yaml b/charts/stable/home-assistant/values.yaml index 4942631af2d..74fd98afaab 100644 --- a/charts/stable/home-assistant/values.yaml +++ b/charts/stable/home-assistant/values.yaml @@ -51,37 +51,32 @@ configmap: data: init.sh: |- #!/bin/sh + {{ $haDBURL := (printf "%s?client_encoding=utf8" (.Values.cnpg.main.creds.std | trimAll "\"")) | quote }} config_file="/config/configuration.yaml" - if test -f "$config_file"; then - echo "configuration.yaml exists." - if grep -q recorder: "$config_file"; then - echo "configuration.yaml already contains recorder" - else - echo "" >> "$config_file" - cat /config/init/recorder.default >> "$config_file" - fi - if grep -q http: "$config_file"; then - echo "configuration.yaml already contains http section" - else - echo "" >> "$config_file" - cat /config/init/http.default >> "$config_file" - fi - else - echo "configuration.yaml does NOT exist." - cp /config/init/configuration.yaml.default "$config_file" - echo "" >> "$config_file" - cat /config/init/recorder.default >> "$config_file" - echo "" >> "$config_file" - cat /config/init/http.default >> "$config_file" - echo "" >> "$config_file" + default="/config/init" + if [ ! -f "$config" ]; then + echo "File [$config] does NOT exist. Creating..." + cp "$default/configuration.default" "$config" fi + if ! grep -q "recorder:" "$config"; then + echo "Section [recorder] does NOT exist in [$config]. Appending..." + echo "" >> "$config" + cat "$default/recorder.default" >> "$config" + fi + if ! grep -q "http:" "$config"; then + echo "Section [http] does NOT exist in [$config]. Appending..." + echo "" >> "$config" + cat "$default/http.default" >> "$config" + fi + + echo "Updating database URL" + yq -i '.recorder.db_url = "{{ $haDBURL }}"' "$config" + echo "Done" echo "Creating include files..." for include_file in groups.yaml automations.yaml scripts.yaml scenes.yaml; do - if test -f "/config/$include_file"; then - echo "$include_file exists." - else - echo "$include_file does NOT exist." + if ! -f "/config/$include_file"; then + echo "File [$include_file] missing. Creating" touch "/config/$include_file" fi done