From 97c165b59a230832db144bedf2b1ef35e8e727e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 23 Jun 2026 08:55:32 +0000 Subject: [PATCH] birdnet-go: guard SQLite revert to only run when HA MariaDB host matches When mariadb_auto_config is disabled, only revert output.mysql.enabled to false (and re-enable SQLite) if config.yaml's output.mysql.host matches the HA MariaDB service host. This prevents clobbering a manually-configured MySQL block pointing at a different server on every addon restart. --- birdnet-go/CHANGELOG.md | 2 +- birdnet-go/rootfs/etc/cont-init.d/33-mariadb.sh | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/birdnet-go/CHANGELOG.md b/birdnet-go/CHANGELOG.md index 2243d3090f..8b145ba427 100644 --- a/birdnet-go/CHANGELOG.md +++ b/birdnet-go/CHANGELOG.md @@ -1,6 +1,6 @@ ## nightly-20260615-2 (2026-06-23) - MariaDB auto-config: create the `birdnet` database on first start if it does not exist (birdnet-go connects to a pre-existing schema and does not create it, causing "database doesn't exist" errors) -- MariaDB auto-config: disabling `mariadb_auto_config` now writes `output.mysql.enabled = false` and `output.sqlite.enabled = true` back to config.yaml, so turning the option off fully reverts to SQLite +- MariaDB auto-config: disabling `mariadb_auto_config` now reverts to SQLite only when `output.mysql.host` in config.yaml matches the HA MariaDB host (avoids clobbering manually-configured MySQL pointing at a different server) - Added `mariadb-client` to the addon packages so the `mysql` CLI used for database creation is available inside the container - MQTT auto-config now also enables BirdNET-Go's native Home Assistant MQTT auto-discovery: detection sensors appear in Home Assistant automatically with no manual YAML (existing UI/config.yaml edits are preserved) diff --git a/birdnet-go/rootfs/etc/cont-init.d/33-mariadb.sh b/birdnet-go/rootfs/etc/cont-init.d/33-mariadb.sh index 84bab92f89..c2f082dfaf 100755 --- a/birdnet-go/rootfs/etc/cont-init.d/33-mariadb.sh +++ b/birdnet-go/rootfs/etc/cont-init.d/33-mariadb.sh @@ -41,12 +41,17 @@ if ! bashio::config.true 'mariadb_auto_config'; then bashio::log.blue "Port : ${MYSQL_PORT}" bashio::log.green "---" if [ -f "$CONFIG_LOCATION" ]; then - # Revert any previously written mysql block so the app uses SQLite. + # Only revert if config.yaml points at the HA MariaDB host we would have + # written — a mysql block pointing at a different host was set manually. # shellcheck disable=SC2016 - yq -i -y \ - '.output.mysql.enabled = false - | .output.sqlite.enabled = true' \ - "$CONFIG_LOCATION" + CURRENT_MYSQL_HOST="$(yq -r '.output.mysql.host // empty' "$CONFIG_LOCATION" 2>/dev/null || true)" + if yq -e '.output.mysql.enabled == true' "$CONFIG_LOCATION" >/dev/null 2>&1 \ + && [ "${CURRENT_MYSQL_HOST}" = "${MYSQL_HOST}" ]; then + yq -i -y \ + '.output.mysql.enabled = false + | .output.sqlite.enabled = true' \ + "$CONFIG_LOCATION" + fi fi exit 0 fi