forgejo/docker/rootless/usr/local/bin/docker-setup.sh

64 lines
2.6 KiB
Bash
Raw Normal View History

#!/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
mkdir -p ${GITEA_CUSTOM} && chmod 0700 ${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
# 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
#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
# Substitute the environment variables in the template
[BRANDING] container images: set APP_NAME (cherry picked from commit 12d7bc447edb272327200389c73bb04bb5fccc14) (cherry picked from commit 1335b17fc35b8b873b94435fddcc23c5cdf0117e) (cherry picked from commit 0d7da06c47ac3a7278602871b95234f823e11f1d) (cherry picked from commit 095c1ab679bce39dbaa89e8a86eaeab8a9b823ad) (cherry picked from commit 2220f00d09e2692d10e0d07f1e8ae2232a636a7d) (cherry picked from commit f0be8bbdbfb758fd13f2f9325358ad292f6c030c) (cherry picked from commit 15188180a15adb58bbde418018612561b68b6927) (cherry picked from commit 96c471d7d36a24824835b254bf785689f898d715) (cherry picked from commit 709052f1e79bbb0ee417f8001c9c0dbd03e78791) (cherry picked from commit 98cd2f5deee05ae9be67250c85fc17e31eaaf28a) (cherry picked from commit a1014654b13e338eaf35cd96d6115fe88459480f) (cherry picked from commit a16f4dc51dce3f9d22cf899186fc61931a82f35e) (cherry picked from commit abbed33d1699daa99620acdec5322846f562cb8d) (cherry picked from commit 4871447def0794027227280059bdfa29cacc0a23) (cherry picked from commit ea1218b237017fa3ca3e5204afd56a18e8336650) (cherry picked from commit 6dd67d60de567e70a36524db940b8e88420251c0) (cherry picked from commit 71761f04afff6d1552c5604fcf7f9b5a27cf01ba) (cherry picked from commit 7cb28a3a06b1b665a6ac9d2687c79ef5ceed0dba) (cherry picked from commit d116336cb5a2df68260fbec42b606fa35c27ba30) (cherry picked from commit 4138a698b2744f504cc6e3590ab8b14753cb719d) (cherry picked from commit 38c572bc1928fc138503a88b66aa8e6d1c06aa6e) (cherry picked from commit 94c759b47f93dde23473d45eff2309dce5055d8a) (cherry picked from commit e1f52bf1d5087df6c7905afc08a7cbada6854f7f) (cherry picked from commit 8bc7000cfa7d0caa87f99c07543f36925fbe984b) (cherry picked from commit fa60007c3464a8d7fc278df1f6d51fb40c6ed130) (cherry picked from commit 0328db39c9a9359046aea0a422002a3072509345) (cherry picked from commit d028010b64e9d12dc3698fadd8b6f017ea2762ef) (cherry picked from commit 0283c920f01e8ec599613f8e28fa39157f698e4c) (cherry picked from commit f5bdf3e11f93c508d03ce38d66550aadeb41abdd) (cherry picked from commit e3beb523007fe87951a4e901596aaef965de0771) (cherry picked from commit a63d5afc91a5c7f29969c5ed722c6718c1452e6d) (cherry picked from commit 7d43e1a828139d20b5baafe1df706e11ed4d83a8) (cherry picked from commit a551fbd0fa00231a886c101d5fe438b184c01b93) (cherry picked from commit cdff0ddbb67237638d60ed5a6180670813ce24d0) (cherry picked from commit f2462ab1d0d0bf70c9d6cec4408bb6f9a05a6019) (cherry picked from commit 7231dcc0a7a16b8f1dc6a5a67e589cdf9ee310ed) (cherry picked from commit 1cbe55f8329f5ec70aaef39d6c66551f555e0b96) (cherry picked from commit 483d9534989bb6abdc65d87eed1f4806ea78f6eb) (cherry picked from commit e0b863d2e9b983c77a63199a14c50e1724688c1e) (cherry picked from commit 34dc719b4d55e87832f7dd38152d8503a9438ec0) (cherry picked from commit 200f1ddec3129f8722265531817bf4489ef02f6e) (cherry picked from commit 892435f00f6b22fa41bc572d58e1f3168677d3d2) (cherry picked from commit 188d1d387a933812a88e58241ac8fe3ceb1a1d36) (cherry picked from commit 8589533bfebf21233ca91a4b90d41532e34efad2) (cherry picked from commit 8e7e83ffe59044e67f954f20bce3a5be901e7777) (cherry picked from commit 4f86171d68d6a363d7c813cd8eb439ed656d3c6d) (cherry picked from commit ece61fd4f649e48e14811ffc2e20deae487244b8) (cherry picked from commit ff34eb0023be8e07e37cf63787bfc7187f9da3a6) (cherry picked from commit 845b0ecc8cbea1a7985b7623c92237f1bbf5710c)
2022-12-25 16:25:25 +01:00
APP_NAME=${APP_NAME:-"Forgejo: Beyond coding. We forge."} \
RUN_MODE=${RUN_MODE:-"prod"} \
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
# Replace app.ini settings with env variables in the form GITEA__SECTION_NAME__KEY_NAME
environment-to-ini --config ${GITEA_APP_INI}