From c5b212bf47eaf734a2abc2ce29f24d2c943bc690 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 08:11:07 +0000 Subject: [PATCH 2/4] maintainerr: replace /opt/data with /config/data in Dockerfile and ha_entrypoint Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/21b5a0d9-5483-4227-b0f2-e047708cfbca Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- maintainerr/Dockerfile | 3 ++- maintainerr/rootfs/ha_entrypoint.sh | 25 +++++++------------------ 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/maintainerr/Dockerfile b/maintainerr/Dockerfile index 4cfc72cb6..84c8f468a 100644 --- a/maintainerr/Dockerfile +++ b/maintainerr/Dockerfile @@ -64,7 +64,8 @@ COPY --from=ha_tools /out/ / # Add rootfs COPY rootfs/ / RUN chmod +x /entrypoint.sh \ - && find /etc/cont-init.d /etc/cont-finish.d -type f -name "*.sh" -exec chmod +x {} \; 2>/dev/null || true + && find /etc/cont-init.d /etc/cont-finish.d -type f -name "*.sh" -exec chmod +x {} \; 2>/dev/null || true \ + && find / -type f \( -name "*.js" -o -name "*.ts" -o -name "*.json" -o -name "*.sh" -o -name "*.yml" -o -name "*.yaml" -o -name "*.env" -o -name "*.conf" -o -name "*.cfg" \) ! -path "/proc/*" ! -path "/sys/*" ! -path "/dev/*" -exec grep -l "/opt/data" {} \; 2>/dev/null | xargs -r sed -i 's|/opt/data|/config/data|g' # Install bashio standalone RUN BASHIO_VERSION="0.14.3" && \ diff --git a/maintainerr/rootfs/ha_entrypoint.sh b/maintainerr/rootfs/ha_entrypoint.sh index 2acfa8067..e4cda4434 100755 --- a/maintainerr/rootfs/ha_entrypoint.sh +++ b/maintainerr/rootfs/ha_entrypoint.sh @@ -18,11 +18,10 @@ if [ -d /etc/cont-init.d ]; then fi # ─── Setup persistent data directory ───────────────────────────────────────── -# 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. +# The upstream app hardcodes /opt/data for its database and logs. +# The Dockerfile rewrites all /opt/data references to /config/data at build time. +# At runtime we copy any seed data from /opt/data to /config/data (persistent +# via addon_config:rw) without overwriting existing files. DATA_DIR="/config/data" echo "[Maintainerr] Setting up data directory: $DATA_DIR" mkdir -p "$DATA_DIR" @@ -30,22 +29,12 @@ mkdir -p "$DATA_DIR"/logs chmod -R 777 "$DATA_DIR" chown -R node:node "$DATA_DIR" -# Preserve any seed data from the Docker volume before replacing it. -# /opt/data is a Docker VOLUME mount and cannot be removed, so instead of -# replacing the directory with a symlink, we symlink each item inside it. -if [ -d /opt/data ] && [ ! -L /opt/data ]; then +# Copy any seed/existing data from /opt/data to /config/data (don't overwrite) +if [ -d /opt/data ] && [ "$(ls -A /opt/data 2>/dev/null)" ]; then + echo "[Maintainerr] Copying existing files from /opt/data to $DATA_DIR..." cp -rn /opt/data/. "$DATA_DIR/" 2>/dev/null || true - # Remove contents inside /opt/data (the directory itself stays) - rm -rf /opt/data/* fi -# Create symlinks for each item in $DATA_DIR inside /opt/data -for item in "$DATA_DIR"/*; do - [ -e "$item" ] || continue - name="$(basename "$item")" - ln -sfn "$item" "/opt/data/$name" -done - # Only chown on first run to avoid slow startup on large directories if [ ! -f "$DATA_DIR/.initialized" ]; then chown -R node:node "$DATA_DIR" From 316bf67a5f57ebf7a146ea37df0d0bf553184a26 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 8 Apr 2026 10:26:58 +0200 Subject: [PATCH 3/4] Update maintainerr/Dockerfile Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- maintainerr/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/maintainerr/Dockerfile b/maintainerr/Dockerfile index 84c8f468a..1816b23af 100644 --- a/maintainerr/Dockerfile +++ b/maintainerr/Dockerfile @@ -65,7 +65,11 @@ COPY --from=ha_tools /out/ / COPY rootfs/ / RUN chmod +x /entrypoint.sh \ && find /etc/cont-init.d /etc/cont-finish.d -type f -name "*.sh" -exec chmod +x {} \; 2>/dev/null || true \ - && find / -type f \( -name "*.js" -o -name "*.ts" -o -name "*.json" -o -name "*.sh" -o -name "*.yml" -o -name "*.yaml" -o -name "*.env" -o -name "*.conf" -o -name "*.cfg" \) ! -path "/proc/*" ! -path "/sys/*" ! -path "/dev/*" -exec grep -l "/opt/data" {} \; 2>/dev/null | xargs -r sed -i 's|/opt/data|/config/data|g' + && set -- /entrypoint.sh; \ + [ -d /opt/app ] && set -- "$@" /opt/app; \ + [ -d /etc/cont-init.d ] && set -- "$@" /etc/cont-init.d; \ + [ -d /etc/cont-finish.d ] && set -- "$@" /etc/cont-finish.d; \ + find "$@" -type f \( -name "*.js" -o -name "*.ts" -o -name "*.json" -o -name "*.sh" -o -name "*.yml" -o -name "*.yaml" -o -name "*.env" -o -name "*.conf" -o -name "*.cfg" \) -exec grep -l "/opt/data" {} + 2>/dev/null | xargs -r sed -i 's|/opt/data|/config/data|g' # Install bashio standalone RUN BASHIO_VERSION="0.14.3" && \ From bd04f79897aa8db513d7fb59fce228c28c13c134 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 8 Apr 2026 08:29:08 +0000 Subject: [PATCH 4/4] =?UTF-8?q?maintainerr:=20fix=20permission=20ordering?= =?UTF-8?q?=20=E2=80=94=20copy=20seed=20data=20before=20chmod/chown?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/e4fba11b-c2eb-407c-bf95-fff2c908246d Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- maintainerr/rootfs/ha_entrypoint.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/maintainerr/rootfs/ha_entrypoint.sh b/maintainerr/rootfs/ha_entrypoint.sh index e4cda4434..7521aa1aa 100755 --- a/maintainerr/rootfs/ha_entrypoint.sh +++ b/maintainerr/rootfs/ha_entrypoint.sh @@ -24,10 +24,7 @@ fi # via addon_config:rw) without overwriting existing files. DATA_DIR="/config/data" echo "[Maintainerr] Setting up data directory: $DATA_DIR" -mkdir -p "$DATA_DIR" -mkdir -p "$DATA_DIR"/logs -chmod -R 777 "$DATA_DIR" -chown -R node:node "$DATA_DIR" +mkdir -p "$DATA_DIR" "$DATA_DIR/logs" # Copy any seed/existing data from /opt/data to /config/data (don't overwrite) if [ -d /opt/data ] && [ "$(ls -A /opt/data 2>/dev/null)" ]; then @@ -35,7 +32,8 @@ if [ -d /opt/data ] && [ "$(ls -A /opt/data 2>/dev/null)" ]; then cp -rn /opt/data/. "$DATA_DIR/" 2>/dev/null || true fi -# Only chown on first run to avoid slow startup on large directories +# Apply permissions/ownership once so copied files are also covered +chmod -R 777 "$DATA_DIR" if [ ! -f "$DATA_DIR/.initialized" ]; then chown -R node:node "$DATA_DIR" touch "$DATA_DIR/.initialized"