2020-11-01 06:28:22 +05:30
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Prepare git folder
|
|
|
|
mkdir -p ${HOME} && chmod 0700 ${HOME}
|
|
|
|
if [ ! -w ${HOME} ]; then echo "${HOME} is not writable"; exit 1; fi
|
|
|
|
|
|
|
|
# Prepare custom folder
|
2022-08-19 20:35:07 +05:30
|
|
|
mkdir -p ${GITEA_CUSTOM} && chmod 0700 ${GITEA_CUSTOM}
|
2020-11-01 06:28:22 +05:30
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2024-04-22 08:23:04 +05:30
|
|
|
# TODO: remove on next major version release
|
|
|
|
# Honour legacy config file if existing, but inform the user
|
|
|
|
if [ -f ${GITEA_APP_INI_LEGACY} ] && [ ${GITEA_APP_INI} != ${GITEA_APP_INI_LEGACY} ]; then
|
|
|
|
GITEA_APP_INI_DEFAULT=/var/lib/gitea/custom/conf/app.ini
|
|
|
|
echo -e \
|
|
|
|
"\033[33mWARNING\033[0m: detected configuration file in deprecated default path ${GITEA_APP_INI_LEGACY}." \
|
|
|
|
"The new default is ${GITEA_APP_INI_DEFAULT}. To remove this warning, choose one of the options:\n" \
|
|
|
|
"* Move ${GITEA_APP_INI_LEGACY} to ${GITEA_APP_INI_DEFAULT} (or to \$GITEA_APP_INI if you want to override this variable)\n" \
|
|
|
|
"* Explicitly override GITEA_APP_INI=${GITEA_APP_INI_LEGACY} in the container environment"
|
|
|
|
GITEA_APP_INI=${GITEA_APP_INI_LEGACY}
|
|
|
|
fi
|
|
|
|
|
2020-11-01 06:28:22 +05:30
|
|
|
#Prepare config file
|
|
|
|
if [ ! -f ${GITEA_APP_INI} ]; then
|
|
|
|
|
|
|
|
#Prepare config file folder
|
|
|
|
GITEA_APP_INI_DIR=$(dirname ${GITEA_APP_INI})
|
|
|
|
mkdir -p ${GITEA_APP_INI_DIR} && chmod 0700 ${GITEA_APP_INI_DIR}
|
|
|
|
if [ ! -w ${GITEA_APP_INI_DIR} ]; then echo "${GITEA_APP_INI_DIR} is not writable"; exit 1; fi
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2021-07-08 17:08:13 +05:30
|
|
|
# Substitute the environment variables in the template
|
2022-12-25 20:55:25 +05:30
|
|
|
APP_NAME=${APP_NAME:-"Forgejo: Beyond coding. We forge."} \
|
2020-12-01 01:22:04 +05:30
|
|
|
RUN_MODE=${RUN_MODE:-"prod"} \
|
2020-11-01 06:28:22 +05:30
|
|
|
RUN_USER=${USER:-"git"} \
|
|
|
|
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
|
|
|
|
HTTP_PORT=${HTTP_PORT:-"3000"} \
|
|
|
|
ROOT_URL=${ROOT_URL:-""} \
|
|
|
|
DISABLE_SSH=${DISABLE_SSH:-"false"} \
|
|
|
|
SSH_PORT=${SSH_PORT:-"2222"} \
|
|
|
|
SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-$SSH_PORT} \
|
|
|
|
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_APP_INI}
|
|
|
|
fi
|
2021-02-24 00:51:44 +05:30
|
|
|
|
|
|
|
# Replace app.ini settings with env variables in the form GITEA__SECTION_NAME__KEY_NAME
|
|
|
|
environment-to-ini --config ${GITEA_APP_INI}
|