Handle Zoneminder DB migration and bump version

This commit is contained in:
Alexandre
2026-01-03 10:06:16 +01:00
parent 52eab72dd4
commit f1ab5f46a1
4 changed files with 48 additions and 7 deletions

View File

@@ -1,4 +1,8 @@
## 1.36.37-2 (03-01-2026)
- Fix MariaDB addon defaults and migrate legacy database name when detected
- Ensure MySQL data directory is created with correct ownership
## 1.36.37 (23-12-2025)
- Update to latest version from zoneminder-containers/zoneminder-base (changelog : https://github.com/zoneminder-containers/zoneminder-base/releases)
- The Home Assistant project has deprecated support for the armv7, armhf and i386 architectures. Support wil be fully dropped in the upcoming Home Assistant 2025.12 release

View File

@@ -95,5 +95,5 @@ services:
slug: zoneminder
udev: true
url: https://github.com/alexbelgium/hassio-addons
version: "1.36.37"
version: "1.36.37-2"
webui: "[PROTO:ssl]://[HOST]:[PORT:80]/zm"

View File

@@ -19,11 +19,12 @@ if [ ! -d "$CONFIGSOURCE" ]; then mkdir "$CONFIGSOURCE"; fi
if [ ! -d "$CONFIGSOURCE"/events ]; then mkdir "$CONFIGSOURCE"/events; fi
if [ ! -d "$CONFIGSOURCE"/sounds ]; then mkdir "$CONFIGSOURCE"/sounds; fi
if [ ! -d "$IMAGESOURCE" ]; then mkdir "$IMAGESOURCE"; fi
if [ ! -d "$CONFIGSOURCE"/mysql ]; then mkdir "$CONFIGSOURCE"/mysql; fi
# Make sure permissions are right
echo "... checking permissions"
chown -R "$(id -u):$(id -g)" "$CONFIGSOURCE"
chown -R "$(id -u):$(id -g)" "$IMAGESOURCE"
chown -R "$(id -u):$(id -g)" "$CONFIGSOURCE"/events "$CONFIGSOURCE"/sounds "$IMAGESOURCE"
chown -R mysql:mysql "$CONFIGSOURCE"/mysql
# Make symlinks
echo "... making symlinks"

View File

@@ -35,7 +35,7 @@ case "$(bashio::config "DB_CONNECTION")" in
DB_CONNECTION=mysql
ZM_DB_HOST=$(bashio::services "mysql" "host")
ZM_DB_PORT=$(bashio::services "mysql" "port")
ZM_DB_NAME=firefly
ZM_DB_NAME=zm
ZM_DB_USER=$(bashio::services "mysql" "username")
ZM_DB_PASS=$(bashio::services "mysql" "password")
export DB_CONNECTION
@@ -46,15 +46,51 @@ case "$(bashio::config "DB_CONNECTION")" in
export ZM_DB_USER && bashio::log.blue "ZM_DB_USER=$ZM_DB_USER"
export ZM_DB_PASS && bashio::log.blue "ZM_DB_PASS=$ZM_DB_PASS"
bashio::log.warning "Firefly-iii is using the Maria DB addon"
bashio::log.warning "Zoneminder is using the MariaDB addon"
bashio::log.warning "Please ensure this is included in your backups"
bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
bashio::log.info "Creating database for Firefly-iii if required"
bashio::log.info "Creating database for Zoneminder if required"
mysql \
-u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \
-h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \
-e "CREATE DATABASE IF NOT EXISTS \`firefly\` ;"
-e "CREATE DATABASE IF NOT EXISTS \`${ZM_DB_NAME}\` ;"
legacy_db=$(mysql \
-u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \
-h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \
--batch --skip-column-names \
-e "SHOW DATABASES LIKE 'firefly';" || true)
if [ -n "$legacy_db" ]; then
target_db=$(mysql \
-u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \
-h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \
--batch --skip-column-names \
-e "SHOW DATABASES LIKE '${ZM_DB_NAME}';" || true)
if [ -z "$target_db" ]; then
bashio::log.warning "Detected legacy database 'firefly'. Attempting migration to '${ZM_DB_NAME}'."
mysql \
-u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \
-h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \
-e "CREATE DATABASE IF NOT EXISTS \`${ZM_DB_NAME}\` ;"
if command -v mysqldump >/dev/null 2>&1; then
if mysqldump \
-u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \
-h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \
--routines --events --triggers \
firefly | mysql \
-u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \
-h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \
"${ZM_DB_NAME}"; then
bashio::log.info "Legacy database migration completed."
else
bashio::log.warning "Legacy database migration failed; please migrate manually."
fi
else
bashio::log.warning "mysqldump not available; please migrate manually."
fi
fi
fi
;;
# Use remote