30 lines
1.6 KiB
Cheetah
30 lines
1.6 KiB
Cheetah
#!/bin/bash
|
|
|
|
# modified version of https://github.com/go-gitea/gitea/blob/d7dbe4feebac7805a4ca184f0989f58de8063d96/docker/rootless/usr/local/bin/docker-setup.sh
|
|
# also see https://github.com/go-gitea/gitea/pull/14762#issuecomment-829224656
|
|
|
|
# Prepare git folder
|
|
mkdir -p ${HOME} && chmod 0700 ${HOME}
|
|
if [ ! -w ${HOME} ]; then echo "${HOME} is not writable"; exit 1; fi
|
|
|
|
# Prepare custom folder
|
|
mkdir -p ${GITEA_CUSTOM} && chmod 0500 ${GITEA_CUSTOM}
|
|
|
|
# Prepare temp folder
|
|
mkdir -p ${GITEA_TEMP} && chmod 0700 ${GITEA_TEMP}
|
|
if [ ! -w ${GITEA_TEMP} ]; then echo "${GITEA_TEMP} is not writable"; exit 1; fi
|
|
|
|
# Seed app.ini into the WRITABLE config volume (/etc/gitea) from the read-only swarm config
|
|
# (mounted at /etc/gitea/app.ini.init). Gitea must be able to PERSIST settings to app.ini — e.g.
|
|
# Gitea 1.24+ (re)generates and SAVES the [oauth2] JWT_SECRET at LoadCommonSettings; with app.ini
|
|
# mounted directly as a read-only swarm config this fails fatally ("open /etc/gitea/app.ini:
|
|
# read-only file system") on (re)deploy. Seed when MISSING OR EMPTY (`! -s`, not `! -f`): upgrading
|
|
# from a release that mounted app.ini directly as a swarm config leaves a 0-byte placeholder at
|
|
# /etc/gitea/app.ini in the reattached config volume — `! -f` would treat that as "present" and skip,
|
|
# leaving Gitea to boot the install wizard on an empty config. A non-empty app.ini (Gitea's persisted
|
|
# state) is preserved across restarts; truncate/delete it to force a re-seed from the rendered config.
|
|
if [ ! -s /etc/gitea/app.ini ]; then
|
|
cp /etc/gitea/app.ini.init /etc/gitea/app.ini
|
|
fi
|
|
chmod 0600 /etc/gitea/app.ini 2>/dev/null || true
|