Merge pull request #2623 from alexbelgium/copilot/fix-addon-startup-issue

Fix Maintainerr addon startup failure: symlink contents inside Docker VOLUME instead of replacing it
This commit is contained in:
Alexandre
2026-03-31 22:36:11 +02:00
committed by GitHub
3 changed files with 19 additions and 5 deletions

View File

@@ -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

View File

@@ -65,6 +65,8 @@ devices:
- /dev/nvme0
- /dev/nvme1
- /dev/nvme2
environment:
- DATA_DIR: "/config"
image: ghcr.io/alexbelgium/maintainerr-{arch}
ingress: true
ingress_stream: true
@@ -87,5 +89,5 @@ schema:
TZ: str?
slug: maintainerr
url: https://github.com/alexbelgium/hassio-addons/tree/master/maintainerr
version: "3.2.0-2"
version: "3.2.0-3"
webui: "[PROTO:ssl]://[HOST]:[PORT:6246]"

View File

@@ -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