mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-04-09 16:09:59 +02:00
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>
49 lines
2.1 KiB
Bash
Executable File
49 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# shellcheck shell=bash
|
|
set -e
|
|
|
|
###############################################################################
|
|
# Home Assistant Addon entrypoint for Maintainerr
|
|
# Runs cont-init.d scripts then drops privileges and starts the app.
|
|
###############################################################################
|
|
|
|
# ─── Run cont-init.d scripts ─────────────────────────────────────────────────
|
|
if [ -d /etc/cont-init.d ]; then
|
|
for script in /etc/cont-init.d/*.sh; do
|
|
[ -f "$script" ] || continue
|
|
sed -i '1s|.*|#!/usr/bin/env bashio|' "$script"
|
|
echo "[Maintainerr] Running init script: $script"
|
|
bashio "$script"
|
|
done
|
|
fi
|
|
|
|
# ─── Setup persistent data directory ─────────────────────────────────────────
|
|
# 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"
|
|
mkdir -p "$DATA_DIR"/logs
|
|
chmod -R 777 "$DATA_DIR"
|
|
chown -R node:node "$DATA_DIR"
|
|
|
|
# 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
|
|
fi
|
|
|
|
# Only chown on first run to avoid slow startup on large directories
|
|
if [ ! -f "$DATA_DIR/.initialized" ]; then
|
|
chown -R node:node "$DATA_DIR"
|
|
touch "$DATA_DIR/.initialized"
|
|
fi
|
|
export DATA_DIR
|
|
|
|
# ─── Start Maintainerr as unprivileged node user ─────────────────────────────
|
|
echo "[Maintainerr] Starting application on port ${UI_PORT:-6246}..."
|
|
exec gosu node /opt/app/start.sh
|
|
# exec nginx
|