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

52 lines
1.8 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
#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 89924d07a5a19b76581eededd7dd0345db06c341) (cherry picked from commit f46d4c36169e9eb37a5e4d287a3b7b7def259b77) (cherry picked from commit e764ad3a037a9f78c01d39f02a9b7c8a2e301662) (cherry picked from commit e48b72fa3807fae61679f6995ce91c692f3828d1) (cherry picked from commit 89bfab17dbb3c63980b139e9e2a10c4e925873e9)
2022-12-25 15:25:25 +00: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}