From 7cc09e7cfc46d1b6f7b44c888f016f4f0c355272 Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 31 May 2026 15:34:40 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20persistent=20deprecated=20?= =?UTF-8?q?settings=20and=20ROOT=5FURL=20mismatch=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two issues with existing persistent volumes: 1. Deprecated app.ini settings ([cors].X_FRAME_OPTIONS, [picture].DISABLE_GRAVATAR, [picture].ENABLE_FEDERATED_AVATAR) were baked into the volume config from the old template and never removed on subsequent container starts. 2. ROOT_URL/DOMAIN/SSH_DOMAIN were substituted once on first run from the container hostname and never updated when GITEA_SERVER/GITEA_PROTO env vars changed, causing the "Mismatched ROOT_URL" warning. Fix: add migration + dynamic resync in __update_conf_files (08-gitea.sh) that runs on every startup against both the persistent (/config/gitea) and runtime (/etc/gitea) copies of app.ini, so changes take effect immediately without a second restart. Set GITEA_PROTO=https and GITEA_SERVER=git.casjay.work to populate the correct ROOT_URL at container start. - rootfs/usr/local/etc/docker/init.d/08-gitea.sh: add dynamic ROOT_URL resync and deprecated-setting removal to __update_conf_files rootfs/usr/local/etc/docker/init.d/08-gitea.sh --- .../usr/local/etc/docker/init.d/08-gitea.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 1bdb12f..0bf9962 100755 --- a/rootfs/usr/local/etc/docker/init.d/08-gitea.sh +++ b/rootfs/usr/local/etc/docker/init.d/08-gitea.sh @@ -353,6 +353,27 @@ __update_conf_files() { sed -i "s|REPLACE_GITEA_INTERNAL_TOKEN|$GITEA_INTERNAL_TOKEN|g" "$CONF_DIR/app.ini" sed -i "s|REPLACE_GITEA_LFS_JWT_SECRET|$GITEA_LFS_JWT_SECRET|g" "$CONF_DIR/app.ini" fi + # Re-stamp dynamic values and remove deprecated settings on every startup. + # Applied to both the persistent copy (/config/gitea) and the runtime copy + # (/etc/gitea) so Gitea sees the correct values on this boot without needing + # a second restart. + for _ini_file in "$CONF_DIR/app.ini" "$ETC_DIR/app.ini"; do + [ -f "$_ini_file" ] || continue + # Sync ROOT_URL, DOMAIN, and SSH_DOMAIN from current env vars + sed -i "s|^ROOT_URL[[:space:]]*=.*|ROOT_URL = ${SERVICE_PROTOCOL:-http}://${HOSTNAME}|" "$_ini_file" + sed -i "s|^DOMAIN[[:space:]]*=.*|DOMAIN = ${HOSTNAME}|" "$_ini_file" + sed -i "s|^SSH_DOMAIN[[:space:]]*=.*|SSH_DOMAIN = ${HOSTNAME}|" "$_ini_file" + # Remove deprecated [cors].X_FRAME_OPTIONS (moved to [security] in Gitea v1.26) + awk 'BEGIN{in_s=0}/^\[/{in_s=0}/^\[cors\]/{in_s=1}in_s&&/^X_FRAME_OPTIONS/{next}{print}' \ + "$_ini_file" > /tmp/_gitea_conf.ini && mv /tmp/_gitea_conf.ini "$_ini_file" + # Remove deprecated [picture].DISABLE_GRAVATAR (moved to admin panel in Gitea v1.18) + awk 'BEGIN{in_s=0}/^\[/{in_s=0}/^\[picture\]/{in_s=1}in_s&&/^DISABLE_GRAVATAR/{next}{print}' \ + "$_ini_file" > /tmp/_gitea_conf.ini && mv /tmp/_gitea_conf.ini "$_ini_file" + # Remove deprecated [picture].ENABLE_FEDERATED_AVATAR (moved to admin panel in Gitea v1.18) + awk 'BEGIN{in_s=0}/^\[/{in_s=0}/^\[picture\]/{in_s=1}in_s&&/^ENABLE_FEDERATED_AVATAR/{next}{print}' \ + "$_ini_file" > /tmp/_gitea_conf.ini && mv /tmp/_gitea_conf.ini "$_ini_file" + done + unset _ini_file if [ -n "$DATA_DIR" ] && [ -d "$DATA_DIR" ]; then find "$DATA_DIR" -type d -exec chmod 0777 {} \; chown -Rf $SERVICE_USER:$SERVICE_GROUP "$DATA_DIR" 2>/dev/null