05b44a0ea3
(cherry picked from commit12d7bc447e
) (cherry picked from commit1335b17fc3
) (cherry picked from commit0d7da06c47
) (cherry picked from commit095c1ab679
) (cherry picked from commit2220f00d09
) (cherry picked from commitf0be8bbdbf
) (cherry picked from commit15188180a1
) (cherry picked from commit96c471d7d3
) (cherry picked from commit709052f1e7
) (cherry picked from commit98cd2f5dee
) (cherry picked from commita1014654b1
) (cherry picked from commita16f4dc51d
) (cherry picked from commitabbed33d16
) (cherry picked from commit4871447def
) (cherry picked from commitea1218b237
) (cherry picked from commit6dd67d60de
) (cherry picked from commit71761f04af
) (cherry picked from commit7cb28a3a06
) (cherry picked from commitd116336cb5
) (cherry picked from commit4138a698b2
) (cherry picked from commit38c572bc19
) (cherry picked from commit94c759b47f
) (cherry picked from commite1f52bf1d5
) (cherry picked from commit8bc7000cfa
) (cherry picked from commitfa60007c34
) (cherry picked from commit0328db39c9
) (cherry picked from commitd028010b64
) (cherry picked from commit0283c920f0
) (cherry picked from commitf5bdf3e11f
) (cherry picked from commite3beb52300
) (cherry picked from commita63d5afc91
) (cherry picked from commit7d43e1a828
) (cherry picked from commita551fbd0fa
) (cherry picked from commitcdff0ddbb6
) (cherry picked from commite0aadc9f4a
) (cherry picked from commita448c06caf
) (cherry picked from commitbd2055bff6
) (cherry picked from commit70400183e1
)
66 lines
2.7 KiB
Bash
Executable file
66 lines
2.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
if [ ! -d /data/git/.ssh ]; then
|
|
mkdir -p /data/git/.ssh
|
|
fi
|
|
|
|
# Set the correct permissions on the .ssh directory and authorized_keys file,
|
|
# or sshd will refuse to use them and lead to clone/push/pull failures.
|
|
# It could happen when users have copied their data to a new volume and changed the file permission by accident,
|
|
# and it would be very hard to troubleshoot unless users know how to check the logs of sshd which is started by s6.
|
|
chmod 700 /data/git/.ssh
|
|
if [ -f /data/git/.ssh/authorized_keys ]; then
|
|
chmod 600 /data/git/.ssh/authorized_keys
|
|
fi
|
|
|
|
if [ ! -f /data/git/.ssh/environment ]; then
|
|
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 ${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
|
|
if [ -n "$SECRET_KEY" ] && [ -z "$INSTALL_LOCK" ]; then
|
|
INSTALL_LOCK=true
|
|
fi
|
|
|
|
# Substitute the environment variables in the template
|
|
APP_NAME=${APP_NAME:-"Forgejo: Beyond coding. We forge."} \
|
|
RUN_MODE=${RUN_MODE:-"prod"} \
|
|
DOMAIN=${DOMAIN:-"localhost"} \
|
|
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
|
|
HTTP_PORT=${HTTP_PORT:-"3000"} \
|
|
ROOT_URL=${ROOT_URL:-""} \
|
|
DISABLE_SSH=${DISABLE_SSH:-"false"} \
|
|
SSH_PORT=${SSH_PORT:-"22"} \
|
|
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \
|
|
LFS_START_SERVER=${LFS_START_SERVER:-"false"} \
|
|
DB_TYPE=${DB_TYPE:-"sqlite3"} \
|
|
DB_HOST=${DB_HOST:-"localhost:3306"} \
|
|
DB_NAME=${DB_NAME:-"gitea"} \
|
|
DB_USER=${DB_USER:-"root"} \
|
|
DB_PASSWD=${DB_PASSWD:-""} \
|
|
INSTALL_LOCK=${INSTALL_LOCK:-"false"} \
|
|
DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \
|
|
REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \
|
|
SECRET_KEY=${SECRET_KEY:-""} \
|
|
envsubst < /etc/templates/app.ini > ${GITEA_CUSTOM}/conf/app.ini
|
|
|
|
chown ${USER}:git ${GITEA_CUSTOM}/conf/app.ini
|
|
fi
|
|
|
|
# Replace app.ini settings with env variables in the form GITEA__SECTION_NAME__KEY_NAME
|
|
environment-to-ini --config ${GITEA_CUSTOM}/conf/app.ini
|
|
|
|
# only chown if current owner is not already the gitea ${USER}. No recursive check to save time
|
|
if ! [[ $(ls -ld /data/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/gitea; fi
|
|
if ! [[ $(ls -ld /app/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /app/gitea; fi
|
|
if ! [[ $(ls -ld /data/git | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/git; fi
|
|
chmod 0755 /data/gitea /app/gitea /data/git
|