diff --git a/rootfs/usr/local/etc/docker/init.d/05-dockerd.sh b/rootfs/usr/local/etc/docker/init.d/05-dockerd.sh index e1e0191..268c651 100755 --- a/rootfs/usr/local/etc/docker/init.d/05-dockerd.sh +++ b/rootfs/usr/local/etc/docker/init.d/05-dockerd.sh @@ -267,7 +267,7 @@ __run_precopy() { # then replace the /etc/$SERVICE_NAME directory with a symlink to /config/$SERVICE_NAME # so both paths always resolve to the same processed config. if [ -d "$ETC_DIR" ] && ! [ -L "$ETC_DIR" ]; then - if [ ! -f "$CONF_DIR/daemon.json" ] || grep -q "REPLACE_" "$CONF_DIR/daemon.json" 2>/dev/null; then + if [ ! -f "$CONF_DIR/.initialized" ]; then mkdir -p "$CONF_DIR" cp -Rf "$ETC_DIR/." "$CONF_DIR/" 2>/dev/null || true fi @@ -491,6 +491,8 @@ __update_conf_files() { # define actions symlink "$DATA_DIR" "/var/lib/docker" chmod 777 "$DATA_DIR" "/var/lib/docker" + # Mark config as fully initialised so __run_precopy skips re-seeding on restart + touch "$CONF_DIR/.initialized" 2>/dev/null || true # allow custom functions if builtin type -t __update_conf_files_local | grep -q 'function'; then __update_conf_files_local; fi # exit function diff --git a/rootfs/usr/local/etc/docker/init.d/08-gitea.sh b/rootfs/usr/local/etc/docker/init.d/08-gitea.sh index 1ffa6d6..7e7a620 100755 --- a/rootfs/usr/local/etc/docker/init.d/08-gitea.sh +++ b/rootfs/usr/local/etc/docker/init.d/08-gitea.sh @@ -304,12 +304,13 @@ __run_precopy() { # during container startup, after the entrypoint's initial copy. Applying it here # (in the init.d phase) ensures it takes effect after Docker finishes network setup. [ -f "/usr/local/etc/resolv.conf" ] && cp -f "/usr/local/etc/resolv.conf" "/etc/resolv.conf" 2>/dev/null || true - # Seed /config/$SERVICE_NAME from the baked /etc copy if app.ini is missing - # or still contains unprocessed REPLACE_ tokens from a previous broken run, - # then replace the /etc/$SERVICE_NAME directory with a symlink to /config/$SERVICE_NAME + # Seed /config/$SERVICE_NAME from the baked /etc copy on first initialisation only. + # The marker file $CONF_DIR/.initialized is written after substitution completes; + # delete it to force a re-seed (e.g. after intentional config reset). + # Then replace the /etc/$SERVICE_NAME directory with a symlink to /config/$SERVICE_NAME # so both paths always resolve to the same processed config. if [ -d "$ETC_DIR" ] && ! [ -L "$ETC_DIR" ]; then - if [ ! -f "$CONF_DIR/app.ini" ] || grep -q "REPLACE_" "$CONF_DIR/app.ini" 2>/dev/null; then + if [ ! -f "$CONF_DIR/.initialized" ]; then mkdir -p "$CONF_DIR" cp -Rf "$ETC_DIR/." "$CONF_DIR/" 2>/dev/null || true fi @@ -434,6 +435,8 @@ __update_conf_files() { chown -Rf $SERVICE_USER:$SERVICE_GROUP "$DATA_DIR" 2>/dev/null fi [ -d "$DATABASE_DIR" ] && chown -Rf $SERVICE_USER:$SERVICE_GROUP "$DATABASE_DIR" 2>/dev/null + # Mark config as fully initialised so __run_precopy skips re-seeding on restart + touch "$CONF_DIR/.initialized" 2>/dev/null || true # allow custom functions if builtin type -t __update_conf_files_local | grep -q 'function'; then __update_conf_files_local; fi diff --git a/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh b/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh index 029bae0..d310eb4 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh @@ -337,7 +337,7 @@ __run_precopy() { # then replace the /etc/$SERVICE_NAME directory with a symlink to /config/$SERVICE_NAME # so both paths always resolve to the same processed config. if [ -d "$ETC_DIR" ] && ! [ -L "$ETC_DIR" ]; then - if [ ! -f "$CONF_DIR/default_config.yaml" ] || grep -q "REPLACE_" "$CONF_DIR/default_config.yaml" 2>/dev/null; then + if [ ! -f "$CONF_DIR/.initialized" ]; then mkdir -p "$CONF_DIR" cp -Rf "$ETC_DIR/." "$CONF_DIR/" 2>/dev/null || true fi @@ -439,6 +439,8 @@ __update_conf_files() { # - - - - - - - - - - - - - - - - - - - - - - - - - # define actions + # Mark config as fully initialised so __run_precopy skips re-seeding on restart + touch "$CONF_DIR/.initialized" 2>/dev/null || true # allow custom functions if builtin type -t __update_conf_files_local | grep -q 'function'; then __update_conf_files_local; fi # exit function