Skip to content

[docker] support for custom GITEA_CUSTOM env var #6608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 13, 2019
14 changes: 10 additions & 4 deletions docker/etc/s6/gitea/setup
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ if [ ! -d /data/git/.ssh ]; then
fi

if [ ! -f /data/git/.ssh/environment ]; then
echo "GITEA_CUSTOM=/data/gitea" >| /data/git/.ssh/environment
echo "GITEA_CUSTOM=$GITEA_CUSTOM" >| /data/git/.ssh/environment
chmod 600 /data/git/.ssh/environment

elif ! grep -q "^GITEA_CUSTOM=$GITEA_CUSTOM$" /data/git/.ssh/environment; then
sed -i /^GITEA_CUSTOM=/d /data/git/.ssh/environment
echo "GITEA_CUSTOM=$GITEA_CUSTOM" >> /data/git/.ssh/environment
fi

if [ ! -f /data/gitea/conf/app.ini ]; then
mkdir -p /data/gitea/conf
if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then
mkdir -p ${GITEA_CUSTOM}/conf

# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
# INSTALL_LOCK is empty
Expand All @@ -36,7 +40,9 @@ if [ ! -f /data/gitea/conf/app.ini ]; then
DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \
REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \
SECRET_KEY=${SECRET_KEY:-""} \
envsubst < /etc/templates/app.ini > /data/gitea/conf/app.ini
envsubst < /etc/templates/app.ini > ${GITEA_CUSTOM}/conf/app.ini

chown ${USER}:git ${GITEA_CUSTOM}/conf/app.ini
fi

# only chown if current owner is not already the gitea ${USER}. No recursive check to save time
Expand Down
4 changes: 4 additions & 0 deletions docker/etc/s6/openssh/setup
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then
ssh-keygen -t ecdsa -b 256 -f /data/ssh/ssh_host_ecdsa_key -N "" > /dev/null
fi

if [ "${GITEA_CUSTOM}" != "/data/gitea" ]; then
sed -i "s#/data/gitea#${GITEA_CUSTOM}#" /etc/profile.d/gitea.sh
fi

chown root:root /data/ssh/*
chmod 0700 /data/ssh
chmod 0600 /data/ssh/*