mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-04-05 21:56:27 +02:00
Fix maintainerr persistence: symlink /opt/data → /config instead of wrong path change
The upstream app hardcodes /opt/data for database and logs. The Docker VOLUME at /opt/data is not persistent across HA addon updates. Symlink /opt/data → /config (persistent via addon_config:rw) so hardcoded paths write to persistent storage. Reverts incorrect /addon_configs path. Agent-Logs-Url: https://github.com/alexbelgium/hassio-addons/sessions/35758465-e22e-40d7-81c8-02d05c375a27 Co-authored-by: alexbelgium <44178713+alexbelgium@users.noreply.github.com>
This commit is contained in:
@@ -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}..."
|
||||
|
||||
Reference in New Issue
Block a user