12 Commits

Author SHA1 Message Date
Alexandre
99316c3faa Merge pull request #2330 from alexbelgium/codex/fix-issue-#2327-comment-3705177064
Handle legacy 'firefly' DB migration, fix MariaDB defaults, and bump version
2026-01-03 12:38:58 +01:00
Alexandre
3e5e62b63b Refactor 99-run.sh for better database handling
Updated the script to use 'with-contenv' for bashio and improved database migration logic.
2026-01-03 12:38:38 +01:00
Alexandre
ae34ee80cb Change shebang to use env for bashio 2026-01-03 11:46:58 +01:00
github-actions
7c1cec2993 GitHub bot: changelog 2026-01-03 09:22:50 +00:00
Alexandre
f1ab5f46a1 Handle Zoneminder DB migration and bump version 2026-01-03 10:06:16 +01:00
Alexandre
a040f6009a Remove '--no-cache' from build arguments
Removed the '--no-cache' argument from the build command.
2026-01-03 09:43:04 +01:00
Alexandre
8ab945785a Update version from 4.4.12 to 4.4.15 2026-01-03 09:24:59 +01:00
Alexandre
25f0bcf0dc Update Dockerfile 2026-01-03 09:24:40 +01:00
GitHub Actions
e55175c1e6 Revert 'Update version from 4.4.12 to 4.4.15' [nobuild] 2026-01-03 08:02:04 +00:00
Alexandre
1f3eae0f32 Update upstream version to 4.4.15 2026-01-03 08:58:56 +01:00
Alexandre
2c4d606575 Update version from 4.4.12 to 4.4.15 2026-01-03 08:58:37 +01:00
Alexandre
193a35e4ac Update Dockerfile 2026-01-03 08:58:19 +01:00
9 changed files with 268 additions and 109 deletions

View File

@@ -199,7 +199,6 @@ jobs:
with: with:
args: | args: |
${{ env.BUILD_ARGS }} \ ${{ env.BUILD_ARGS }} \
--no-cache \
--${{ matrix.arch }} \ --${{ matrix.arch }} \
--target "/data/${{ matrix.addon }}" \ --target "/data/${{ matrix.addon }}" \
--image "${{ steps.check.outputs.image }}" \ --image "${{ steps.check.outputs.image }}" \

View File

@@ -1,3 +1,5 @@
## 4.4.15 (03-01-2026)
- Minor bugs fixed
## 4.4.13 (20-12-2025) ## 4.4.13 (20-12-2025)
- Update to latest version from ente-io/ente (changelog : https://github.com/ente-io/ente/releases) - Update to latest version from ente-io/ente (changelog : https://github.com/ente-io/ente/releases)

View File

@@ -1,116 +1,138 @@
#============================# #============================#
# ALEXBELGIUM'S DOCKERFILE # # ALEXBELGIUM'S DOCKERFILE #
#============================# #============================#
#=== Home Assistant Addon ENTE (server+web UI) ===# # Home Assistant Add-on ENTE (server + web UI)
######################################################## ########################################################
# 0 Build the enteweb static frontend (multistage) # # 0) Build the ente-web static front-end (multi-stage) #
######################################################## ########################################################
FROM node:22-alpine AS web-builder FROM node:22-bookworm-slim AS web-builder
# ---- buildtime selector; set `--build-arg ENTE_WEB_TAG=v3.6.0` if you # Build-time selector; set `--build-arg ENTE_WEB_TAG=vX.Y.Z` if you want a specific release
# want a specific release instead of main
ARG ENTE_WEB_TAG=main ARG ENTE_WEB_TAG=main
# ---- tools we need to build (git, yarn)
ENV RUSTUP_HOME=/usr/local/rustup \ ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \ CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH PATH=/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN apk add --no-cache \ # Tools needed to build (git, rust, wasm-pack, yarn classic)
git curl ca-certificates build-base \ RUN set -eux; \
&& curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable \ apt-get update; \
&& rustup target add wasm32-unknown-unknown \ apt-get install -y --no-install-recommends \
&& npm install -g wasm-pack@0.13.1 git \
curl \
ca-certificates \
build-essential \
pkg-config \
python3 \
; \
rm -rf /var/lib/apt/lists/*; \
\
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable; \
rustup target add wasm32-unknown-unknown; \
\
corepack enable; \
corepack prepare yarn@1.22.22 --activate; \
npm install -g wasm-pack@0.13.1
# ---- pull the web source # Pull the web source
WORKDIR /src WORKDIR /src
RUN git clone --depth 1 --branch "${ENTE_WEB_TAG}" https://github.com/ente-io/ente.git . RUN git clone --depth 1 --branch "${ENTE_WEB_TAG}" https://github.com/ente-io/ente.git .
# ---- build web workspace (lives in ./web) # Build web workspace (lives in ./web)
WORKDIR /src/web WORKDIR /src/web
ENV NEXT_PUBLIC_ENTE_ENDPOINT=ENTE_API_ORIGIN_PLACEHOLDER \ ENV NEXT_PUBLIC_ENTE_ENDPOINT=ENTE_API_ORIGIN_PLACEHOLDER \
NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=ENTE_ALBUMS_ORIGIN_PLACEHOLDER NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT=ENTE_ALBUMS_ORIGIN_PLACEHOLDER
RUN yarn config set network-timeout 900000 -g \
&& yarn install --frozen-lockfile \ RUN set -eux; \
&& yarn build:photos \ yarn config set network-timeout 900000 -g; \
&& yarn build:accounts \ yarn install --frozen-lockfile; \
&& yarn build:auth \ yarn build:photos; \
&& yarn build:cast yarn build:accounts; \
yarn build:auth; \
yarn build:cast
################# #################
# 1 Base image # # 1) Base image #
################# #################
FROM ghcr.io/ente-io/server:latest FROM ghcr.io/ente-io/server:latest
################## ##################
# 2 Tune image # # 2) Tune image #
################## ##################
ENV S6_CMD_WAIT_FOR_SERVICES=1 \ ENV S6_CMD_WAIT_FOR_SERVICES=1 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \ S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SERVICES_GRACETIME=0 S6_SERVICES_GRACETIME=0
USER root USER root
# --- LSIO helper --- # --- LSIO helper ---
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_lsio.sh" /ha_lsio.sh ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_lsio.sh" /ha_lsio.sh
ARG CONFIGLOCATION="/config" ARG CONFIGLOCATION="/config"
RUN chmod 744 /ha_lsio.sh && \ RUN set -eux; \
if grep -qr "lsio" /etc; then /ha_lsio.sh "$CONFIGLOCATION"; fi && \ chmod 744 /ha_lsio.sh; \
if grep -qr "lsio" /etc; then /ha_lsio.sh "$CONFIGLOCATION"; fi; \
rm /ha_lsio.sh rm /ha_lsio.sh
# --- MinIO, psql client etc. --- # --- MinIO, psql client etc.
RUN set -eux; \ RUN set -eux; \
BUILD_ARCH=$(uname -m) \ BUILD_ARCH="$(uname -m)"; \
&& echo "${BUILD_ARCH}" \ echo "${BUILD_ARCH}"; \
&& BUILD_ARCH=${BUILD_ARCH:-x86} \ ARCH="amd64"; \
&& if [[ "${BUILD_ARCH}" == *aarch64* ]]; then ARCH="arm64"; fi \ if echo "${BUILD_ARCH}" | grep -Eq 'aarch64|armv8|arm64'; then ARCH="arm64"; fi; \
&& if [[ "${BUILD_ARCH}" == *armv8* ]]; then ARCH="arm64"; fi \ apk add --no-cache bash curl ca-certificates wget jq tini postgresql15-client; \
&& if [[ "${BUILD_ARCH}" == *arm64* ]]; then ARCH="arm64"; fi \ curl -fsSL "https://dl.min.io/server/minio/release/linux-${ARCH}/minio" -o /usr/local/bin/minio; \
&& if [[ "${BUILD_ARCH}" == *x86* ]]; then ARCH="amd64"; fi \ curl -fsSL "https://dl.min.io/client/mc/release/linux-${ARCH}/mc" -o /usr/local/bin/mc; \
&& apk add --no-cache \
bash curl ca-certificates wget jq tini postgresql15-client; \
curl -fsSL https://dl.min.io/server/minio/release/linux-"$ARCH"/minio -o /usr/local/bin/minio; \
curl -fsSL https://dl.min.io/client/mc/release/linux-"$ARCH"/mc -o /usr/local/bin/mc; \
chmod +x /usr/local/bin/minio /usr/local/bin/mc chmod +x /usr/local/bin/minio /usr/local/bin/mc
RUN apk add --no-cache \ RUN apk add --no-cache \
lsb-release curl gnupg wget tini jq sudo \ lsb-release curl gnupg wget tini jq sudo \
postgresql postgresql-client postgresql postgresql-client
# ---------- enteweb bundle ---------- # ---------- ente-web bundle ----------
RUN apk add --no-cache nginx RUN apk add --no-cache nginx
# static files built in the previous stage # Static files built in the previous stage
COPY --from=web-builder /src/web/apps/photos/out /www/photos COPY --from=web-builder /src/web/apps/photos/out /www/photos
COPY --from=web-builder /src/web/apps/accounts/out /www/accounts COPY --from=web-builder /src/web/apps/accounts/out /www/accounts
COPY --from=web-builder /src/web/apps/auth/out /www/auth COPY --from=web-builder /src/web/apps/auth/out /www/auth
COPY --from=web-builder /src/web/apps/cast/out /www/cast COPY --from=web-builder /src/web/apps/cast/out /www/cast
################## ############################
# 3 Install addon helpers # # 3) Install add-on helpers #
################## ############################
COPY rootfs/ / COPY rootfs/ /
ARG MODULES="00-banner.sh 01-custom_script.sh 00-global_var.sh 00-local_mounts.sh 00-smb_mounts.sh" ARG MODULES="00-banner.sh 01-custom_script.sh 00-global_var.sh 00-local_mounts.sh 00-smb_mounts.sh"
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automodules.sh" /ha_automodules.sh ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_automodules.sh" /ha_automodules.sh
RUN chmod 744 /ha_automodules.sh && /ha_automodules.sh "$MODULES" && rm /ha_automodules.sh RUN set -eux; \
chmod 744 /ha_automodules.sh; \
/ha_automodules.sh "$MODULES"; \
rm /ha_automodules.sh
ENV PACKAGES="sudo jq yamllint nginx" ENV PACKAGES="sudo jq yamllint nginx"
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" /ha_autoapps.sh ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_autoapps.sh" /ha_autoapps.sh
RUN chmod 744 /ha_autoapps.sh && /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh RUN set -eux; \
chmod 744 /ha_autoapps.sh; \
/ha_autoapps.sh "$PACKAGES"; \
rm /ha_autoapps.sh
###############
################ # 4) Entrypoint
# 4 Entrypoint # ###############
################
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint.sh" /ha_entrypoint.sh ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint.sh" /ha_entrypoint.sh
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" /ha_entrypoint_modif.sh ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint_modif.sh" /ha_entrypoint_modif.sh
RUN chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh && \ RUN set -eux; \
/ha_entrypoint_modif.sh && rm /ha_entrypoint_modif.sh chmod 777 /ha_entrypoint.sh /ha_entrypoint_modif.sh; \
/ha_entrypoint_modif.sh; \
rm /ha_entrypoint_modif.sh
ENTRYPOINT ["/usr/bin/env"] ENTRYPOINT ["/usr/bin/env"]
CMD ["/ha_entrypoint.sh"] CMD ["/ha_entrypoint.sh"]
############ ############
# 5 Labels # # 5) Labels
############ ############
ARG BUILD_VERSION BUILD_ARCH BUILD_DATE BUILD_NAME BUILD_DESCRIPTION BUILD_REF BUILD_REPOSITORY ARG BUILD_VERSION BUILD_ARCH BUILD_DATE BUILD_NAME BUILD_DESCRIPTION BUILD_REF BUILD_REPOSITORY
LABEL \ LABEL \
@@ -130,6 +152,6 @@ LABEL \
org.opencontainers.image.version=${BUILD_VERSION} org.opencontainers.image.version=${BUILD_VERSION}
################# #################
# 6 Finish line # # 6) Finish line
################# #################
EXPOSE 3000 3001 3002 3003 3004 EXPOSE 3000 3001 3002 3003 3004

View File

@@ -120,6 +120,6 @@ schema:
slug: ente slug: ente
udev: true udev: true
url: https://github.com/alexbelgium/hassio-addons url: https://github.com/alexbelgium/hassio-addons
version: "4.4.12" version: "4.4.15"
video: true video: true
webui: http://[HOST]:[PORT:3000] webui: http://[HOST]:[PORT:3000]

View File

@@ -5,5 +5,5 @@
"slug": "ente", "slug": "ente",
"source": "github", "source": "github",
"upstream_repo": "ente-io/ente", "upstream_repo": "ente-io/ente",
"upstream_version": "4.4.13" "upstream_version": "4.4.15"
} }

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) ## 1.36.37 (23-12-2025)
- Update to latest version from zoneminder-containers/zoneminder-base (changelog : https://github.com/zoneminder-containers/zoneminder-base/releases) - 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 - 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 slug: zoneminder
udev: true udev: true
url: https://github.com/alexbelgium/hassio-addons url: https://github.com/alexbelgium/hassio-addons
version: "1.36.37" version: "1.36.37-2"
webui: "[PROTO:ssl]://[HOST]:[PORT:80]/zm" 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"/events ]; then mkdir "$CONFIGSOURCE"/events; fi
if [ ! -d "$CONFIGSOURCE"/sounds ]; then mkdir "$CONFIGSOURCE"/sounds; fi if [ ! -d "$CONFIGSOURCE"/sounds ]; then mkdir "$CONFIGSOURCE"/sounds; fi
if [ ! -d "$IMAGESOURCE" ]; then mkdir "$IMAGESOURCE"; fi if [ ! -d "$IMAGESOURCE" ]; then mkdir "$IMAGESOURCE"; fi
if [ ! -d "$CONFIGSOURCE"/mysql ]; then mkdir "$CONFIGSOURCE"/mysql; fi
# Make sure permissions are right # Make sure permissions are right
echo "... checking permissions" echo "... checking permissions"
chown -R "$(id -u):$(id -g)" "$CONFIGSOURCE" chown -R "$(id -u):$(id -g)" "$CONFIGSOURCE"/events "$CONFIGSOURCE"/sounds "$IMAGESOURCE"
chown -R "$(id -u):$(id -g)" "$IMAGESOURCE" chown -R mysql:mysql "$CONFIGSOURCE"/mysql
# Make symlinks # Make symlinks
echo "... making symlinks" echo "... making symlinks"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bashio #!/usr/bin/with-contenv bashio
# shellcheck shell=bash # shellcheck shell=bash
set -e set -euo pipefail
# hadolint ignore=SC2155 # hadolint ignore=SC2155
################# #################
@@ -8,10 +8,10 @@ set -e
################# #################
CONFIGSOURCE="/config/addons_config/zoneminder" CONFIGSOURCE="/config/addons_config/zoneminder"
if [ ! -f "$CONFIGSOURCE"/zm.conf ]; then mkdir -p "$CONFIGSOURCE"
# Copy conf files if [ ! -f "$CONFIGSOURCE/zm.conf" ]; then
cp /etc/zm/zm.conf "$CONFIGSOURCE" cp -f /etc/zm/zm.conf "$CONFIGSOURCE/zm.conf"
fi fi
################### ###################
@@ -19,59 +19,191 @@ fi
################### ###################
bashio::log.info "Defining database" bashio::log.info "Defining database"
case "$(bashio::config "DB_CONNECTION")" in
# Use MariaDB case "$(bashio::config "DB_CONNECTION")" in
mariadb_addon) mariadb_addon)
bashio::log.info "Using MariaDB addon. Requirements : running MariaDB addon. Detecting values..." bashio::log.info "Using MariaDB addon. Detecting values..."
if ! bashio::services.available 'mysql'; then if ! bashio::services.available 'mysql'; then
bashio::log.fatal \ bashio::log.fatal "Local database access should be provided by the MariaDB addon"
"Local database access should be provided by the MariaDB addon" bashio::exit.nok "Please ensure it is installed and started"
bashio::exit.nok \
"Please ensure it is installed and started"
fi fi
# Use values DB_CONNECTION="mysql"
DB_CONNECTION=mysql remoteDB="1"
ZM_DB_HOST=$(bashio::services "mysql" "host") ZM_DB_HOST="$(bashio::services "mysql" "host")"
ZM_DB_PORT=$(bashio::services "mysql" "port") ZM_DB_PORT="$(bashio::services "mysql" "port")"
ZM_DB_NAME=firefly ZM_DB_NAME="zm"
ZM_DB_USER=$(bashio::services "mysql" "username") ZM_DB_USER="$(bashio::services "mysql" "username")"
ZM_DB_PASS=$(bashio::services "mysql" "password") ZM_DB_PASS="$(bashio::services "mysql" "password")"
export DB_CONNECTION export DB_CONNECTION remoteDB ZM_DB_HOST ZM_DB_PORT ZM_DB_NAME ZM_DB_USER ZM_DB_PASS
export remoteDB=1
export ZM_DB_HOST && bashio::log.blue "ZM_DB_HOST=$ZM_DB_HOST"
export ZM_DB_PORT && bashio::log.blue "ZM_DB_PORT=$ZM_DB_PORT"
export ZM_DB_NAME && bashio::log.blue "ZM_DB_NAME=$ZM_DB_NAME"
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" # DO NOT log passwords
bashio::log.blue "ZM_DB_HOST=${ZM_DB_HOST}"
bashio::log.blue "ZM_DB_PORT=${ZM_DB_PORT}"
bashio::log.blue "ZM_DB_NAME=${ZM_DB_NAME}"
bashio::log.blue "ZM_DB_USER=${ZM_DB_USER}"
bashio::log.warning "ZoneMinder is using the MariaDB addon"
bashio::log.warning "Please ensure this is included in your backups" bashio::log.warning "Please ensure this is included in your backups"
bashio::log.warning "Uninstalling the MariaDB addon will remove any data" bashio::log.warning "Uninstalling the MariaDB addon will remove any data"
bashio::log.info "Creating database for Firefly-iii if required" # Common mysql invocation (batch + no headers)
mysql_base=(
mysql
-u "${ZM_DB_USER}"
-p"${ZM_DB_PASS}"
-h "${ZM_DB_HOST}"
-P "${ZM_DB_PORT}"
--batch
--skip-column-names
)
db_exists() {
local db="$1"
local out
out="$("${mysql_base[@]}" -e \
"SELECT schema_name FROM information_schema.schemata WHERE schema_name='${db}';" \
2>/dev/null || true)"
[ -n "$out" ]
}
table_count() {
local db="$1"
# If schema doesn't exist, count should be 0
"${mysql_base[@]}" -e \
"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='${db}';" \
2>/dev/null || echo 0
}
is_likely_zoneminder_db() {
# Returns 0 if DB looks like ZoneMinder, 1 otherwise
local db="$1"
if ! db_exists "$db"; then
return 1
fi
# Strong ZoneMinder signature: Config + Monitors (required)
local zm_required
zm_required="$("${mysql_base[@]}" -e \
"SELECT COUNT(*) FROM information_schema.tables
WHERE table_schema='${db}'
AND LOWER(table_name) IN ('config','monitors');" \
2>/dev/null || echo 0)"
# Firefly-ish signature tables (heuristic blacklist)
local ff_sig
ff_sig="$("${mysql_base[@]}" -e \
"SELECT COUNT(*) FROM information_schema.tables
WHERE table_schema='${db}'
AND LOWER(table_name) IN (
'accounts','transactions','transaction_journals','categories',
'budgets','bills','tags','piggy_banks','rules','rule_groups'
);" \
2>/dev/null || echo 0)"
[ "${zm_required:-0}" -ge 2 ] && [ "${ff_sig:-0}" -eq 0 ]
}
create_db_if_missing() {
local db="$1"
"${mysql_base[@]}" -e "CREATE DATABASE IF NOT EXISTS \`${db}\`;" >/dev/null
}
# --- Legacy fix: previous buggy addon used DB name 'firefly' ---
LEGACY_DB_NAME="firefly"
need_migration="0"
if db_exists "$LEGACY_DB_NAME"; then
if is_likely_zoneminder_db "$LEGACY_DB_NAME"; then
legacy_tables="$(table_count "$LEGACY_DB_NAME")"
target_tables="0"
if db_exists "$ZM_DB_NAME"; then
target_tables="$(table_count "$ZM_DB_NAME")"
fi
# Only migrate if:
# - legacy has data
# - target has 0 tables (either missing or empty)
if [ "${legacy_tables:-0}" -gt 0 ] && [ "${target_tables:-0}" -eq 0 ]; then
need_migration="1"
else
bashio::log.info "Legacy DB '${LEGACY_DB_NAME}' detected but migration skipped (target not empty or legacy empty)."
fi
else
bashio::log.warning "Database '${LEGACY_DB_NAME}' exists but does NOT look like ZoneMinder. Skipping migration to avoid touching a real Firefly database."
fi
fi
# IMPORTANT: do NOT pre-create target DB before deciding on migration.
# Create target only when needed (migration) and finally ensure it exists for normal start.
if [ "$need_migration" = "1" ]; then
bashio::log.warning "Detected legacy ZoneMinder DB named '${LEGACY_DB_NAME}'. Migrating to '${ZM_DB_NAME}'..."
create_db_if_missing "$ZM_DB_NAME"
dump_bin=""
if command -v mysqldump >/dev/null 2>&1; then
dump_bin="mysqldump"
elif command -v mariadb-dump >/dev/null 2>&1; then
dump_bin="mariadb-dump"
fi
if [ -z "$dump_bin" ]; then
bashio::log.warning "mysqldump/mariadb-dump not available; please migrate manually."
else
if "$dump_bin" \
-u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \
-h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \
--routines --events --triggers \
"${LEGACY_DB_NAME}" | \
mysql \ mysql \
-u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \ -u "${ZM_DB_USER}" -p"${ZM_DB_PASS}" \
-h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \ -h "${ZM_DB_HOST}" -P "${ZM_DB_PORT}" \
-e "CREATE DATABASE IF NOT EXISTS \`firefly\` ;" "${ZM_DB_NAME}"; then
bashio::log.info "Legacy database migration completed."
bashio::log.warning "Optional: you may now drop '${LEGACY_DB_NAME}' manually if desired."
else
bashio::log.warning "Legacy database migration failed; please migrate manually."
fi
fi
fi
# Ensure target DB exists for ZoneMinder startup (after migration decision)
bashio::log.info "Ensuring ZoneMinder database '${ZM_DB_NAME}' exists"
create_db_if_missing "$ZM_DB_NAME"
;; ;;
# Use remote
external) external)
bashio::log.info "Using remote database. Requirement: filling all addon options fields, and making sure the database already exists" bashio::log.info "Using remote database. Requirement: filling all addon options fields, and making sure the database already exists"
for conditions in "ZM_DB_HOST" "ZM_DB_PORT" "ZM_DB_NAME" "ZM_DB_USER" "ZM_DB_PASS"; do
if ! bashio::config.has_value "$conditions"; then for key in "ZM_DB_HOST" "ZM_DB_PORT" "ZM_DB_NAME" "ZM_DB_USER" "ZM_DB_PASS"; do
bashio::exit.nok "Remote database has been specified but $conditions is not defined in addon options" if ! bashio::config.has_value "$key"; then
bashio::exit.nok "Remote database has been specified but $key is not defined in addon options"
fi fi
done done
DB_CONNECTION="mysql"
remoteDB="1"
ZM_DB_HOST="$(bashio::config "ZM_DB_HOST")"
ZM_DB_PORT="$(bashio::config "ZM_DB_PORT")"
ZM_DB_NAME="$(bashio::config "ZM_DB_NAME")"
ZM_DB_USER="$(bashio::config "ZM_DB_USER")"
ZM_DB_PASS="$(bashio::config "ZM_DB_PASS")"
export DB_CONNECTION remoteDB ZM_DB_HOST ZM_DB_PORT ZM_DB_NAME ZM_DB_USER ZM_DB_PASS
bashio::log.blue "ZM_DB_HOST=${ZM_DB_HOST}"
bashio::log.blue "ZM_DB_PORT=${ZM_DB_PORT}"
bashio::log.blue "ZM_DB_NAME=${ZM_DB_NAME}"
bashio::log.blue "ZM_DB_USER=${ZM_DB_USER}"
# DO NOT log passwords
;; ;;
# Use remote
*) *)
bashio::log.info "Using internal database" bashio::log.info "Using internal database"
;; ;;
esac esac
############## ##############
@@ -79,5 +211,4 @@ esac
############## ##############
bashio::log.info "Please wait while the app is loading !" bashio::log.info "Please wait while the app is loading !"
exec /usr/local/bin/entrypoint.sh
./usr/local/bin/entrypoint.sh