gitea: always overwrite /config/app.ini when real file exists

Gitea's install wizard uses an atomic SaveTo that replaces the symlink
at /data/gitea/conf/app.ini with a real file containing the completed
install config. On the next restart /config/app.ini (the pre-wizard
template) already exists, so the previous guard skipped the copy and
the rm deleted the real installed config, wiping DB/security settings.

Always copy the real file over /config/app.ini regardless of whether
the target already exists.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D46Ef3nZZdbVuwUpPhCd4T
This commit is contained in:
Claude
2026-06-19 12:22:19 +00:00
parent 37148e39f6
commit 7a45680d01

View File

@@ -9,12 +9,13 @@ set -e
# Ensure the gitea conf directory exists
mkdir -p /data/gitea/conf
# If a real file (not a symlink) exists, migrate it to /config so users can edit it
# If a real file (not a symlink) exists, move it to /config.
# This covers both the initial migration from older installs and the post-wizard
# case where Gitea's atomic SaveTo replaces the symlink with the completed config.
# Always overwrite /config/app.ini so the installed settings are never discarded.
if [ -f "/data/gitea/conf/app.ini" ] && [ ! -L "/data/gitea/conf/app.ini" ]; then
if [ ! -f "/config/app.ini" ]; then
bashio::log.info "Migrating app.ini to addon_config folder for direct access"
cp /data/gitea/conf/app.ini /config/app.ini
fi
bashio::log.info "Moving app.ini to addon_config folder for direct access"
cp /data/gitea/conf/app.ini /config/app.ini
rm /data/gitea/conf/app.ini
fi