diff --git a/maintainerr/CHANGELOG.md b/maintainerr/CHANGELOG.md index d16c4f1a2..134ca6ae1 100644 --- a/maintainerr/CHANGELOG.md +++ b/maintainerr/CHANGELOG.md @@ -1,6 +1,6 @@ ## 3.2.0-2 (2026-03-31) -- Fix configuration lost after container restart by using persistent addon_config directory +- Fix configuration lost after container restart by symlinking /opt/data to persistent /config directory ## 3.2.0 (2026-03-28) - Update to latest version from maintainerr/maintainerr (changelog : https://github.com/maintainerr/maintainerr/releases) diff --git a/maintainerr/rootfs/ha_entrypoint.sh b/maintainerr/rootfs/ha_entrypoint.sh index 0ca852ab8..b782fc602 100755 --- a/maintainerr/rootfs/ha_entrypoint.sh +++ b/maintainerr/rootfs/ha_entrypoint.sh @@ -24,26 +24,28 @@ if [ -d /etc/cont-init.d ]; then fi # ─── Setup persistent data directory ───────────────────────────────────────── -# /opt/data is a Docker VOLUME in the upstream image; it is NOT persistent -# across addon updates/reinstalls in HA. Use the addon_config directory -# which is mapped by "addon_config:rw" in config.yaml and survives restarts. -HA_DATA_DIR="/addon_configs/maintainerr" -echo "[Maintainerr] Setting up data directory: $HA_DATA_DIR" -mkdir -p "$HA_DATA_DIR" +# The upstream app hardcodes /opt/data for its database and logs +# (typeOrmConfig.ts → /opt/data/maintainerr.sqlite, logs → /opt/data/logs/). +# /opt/data is declared as a Docker VOLUME in the upstream image, which is NOT +# persistent across addon updates/reinstalls in HA. +# Redirect /opt/data → /config (persistent via addon_config:rw) with a symlink. +DATA_DIR="/config" +echo "[Maintainerr] Setting up data directory: $DATA_DIR" +mkdir -p "$DATA_DIR" -# Copy any seed / initial data from the upstream volume on first run -if [ -d /opt/data ] && [ ! -f "$HA_DATA_DIR/.initialized" ]; then - cp -rn /opt/data/. "$HA_DATA_DIR/" 2>/dev/null || true +# Preserve any seed data from the Docker volume before replacing it +if [ -d /opt/data ] && [ ! -L /opt/data ]; then + cp -rn /opt/data/. "$DATA_DIR/" 2>/dev/null || true + rm -rf /opt/data fi +ln -sfn "$DATA_DIR" /opt/data # Only chown on first run to avoid slow startup on large directories -if [ ! -f "$HA_DATA_DIR/.initialized" ]; then - chown -R node:node "$HA_DATA_DIR" - touch "$HA_DATA_DIR/.initialized" +if [ ! -f "$DATA_DIR/.initialized" ]; then + chown -R node:node "$DATA_DIR" + touch "$DATA_DIR/.initialized" fi - -# Tell Maintainerr to use the persistent directory -export DATA_DIR="$HA_DATA_DIR" +export DATA_DIR # ─── Start Maintainerr as unprivileged node user ───────────────────────────── echo "[Maintainerr] Starting application on port ${UI_PORT:-6246}..."