From 9235b23a93125e36237042269d65e1b32bce39a4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:55:51 +0000 Subject: [PATCH] fix: symlink contents inside /opt/data instead of replacing Docker VOLUME The upstream Maintainerr image declares /opt/data as a Docker VOLUME. Attempting to rm -rf /opt/data fails with "Resource busy" because mount points cannot be removed. Instead, we now: 1. Copy seed data from /opt/data to /config (persistent storage) 2. Clear contents inside /opt/data (rm -rf /opt/data/*) 3. Symlink each item in /config back into /opt/data This ensures the VOLUME directory stays intact while all data is redirected to persistent storage. Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/82a46feb-2e9c-4c40-b193-614167e6d5c3 Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com> --- maintainerr/CHANGELOG.md | 3 +++ maintainerr/rootfs/ha_entrypoint.sh | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/maintainerr/CHANGELOG.md b/maintainerr/CHANGELOG.md index 134ca6ae1..1a9125673 100644 --- a/maintainerr/CHANGELOG.md +++ b/maintainerr/CHANGELOG.md @@ -1,4 +1,7 @@ +## 3.2.0-3 (2026-03-31) +- Fix addon never starts: symlink contents inside /opt/data instead of replacing the Docker VOLUME directory + ## 3.2.0-2 (2026-03-31) - Fix configuration lost after container restart by symlinking /opt/data to persistent /config directory diff --git a/maintainerr/rootfs/ha_entrypoint.sh b/maintainerr/rootfs/ha_entrypoint.sh index b782fc602..40b2f0cbd 100755 --- a/maintainerr/rootfs/ha_entrypoint.sh +++ b/maintainerr/rootfs/ha_entrypoint.sh @@ -31,14 +31,23 @@ fi # 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" +mkdir -p "$DATA_DIR" "$DATA_DIR/logs" -# Preserve any seed data from the Docker volume before replacing it +# 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 cp -rn /opt/data/. "$DATA_DIR/" 2>/dev/null || true - rm -rf /opt/data + # Remove contents inside /opt/data (the directory itself stays) + rm -rf /opt/data/* fi -ln -sfn "$DATA_DIR" /opt/data + +# 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