|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Prepare git folder |
| 4 | +mkdir -p ${HOME} && chmod 0700 ${HOME} |
| 5 | +if [ ! -w ${HOME} ]; then echo "${HOME} is not writable"; exit 1; fi |
| 6 | + |
| 7 | +# Prepare custom folder |
| 8 | +mkdir -p ${GITEA_CUSTOM} && chmod 0700 ${GITEA_CUSTOM} |
| 9 | +if [ ! -w ${GITEA_CUSTOM} ]; then echo "${GITEA_CUSTOM} is not writable"; exit 1; fi |
| 10 | + |
| 11 | +# Prepare temp folder |
| 12 | +mkdir -p ${GITEA_TEMP} && chmod 0700 ${GITEA_TEMP} |
| 13 | +if [ ! -w ${GITEA_TEMP} ]; then echo "${GITEA_TEMP} is not writable"; exit 1; fi |
| 14 | + |
| 15 | +#Prepare config file |
| 16 | +if [ ! -f ${GITEA_APP_INI} ]; then |
| 17 | + |
| 18 | + #Prepare config file folder |
| 19 | + GITEA_APP_INI_DIR=$(dirname ${GITEA_APP_INI}) |
| 20 | + mkdir -p ${GITEA_APP_INI_DIR} && chmod 0700 ${GITEA_APP_INI_DIR} |
| 21 | + if [ ! -w ${GITEA_APP_INI_DIR} ]; then echo "${GITEA_APP_INI_DIR} is not writable"; exit 1; fi |
| 22 | + |
| 23 | + # Set INSTALL_LOCK to true only if SECRET_KEY is not empty and |
| 24 | + # INSTALL_LOCK is empty |
| 25 | + if [ -n "$SECRET_KEY" ] && [ -z "$INSTALL_LOCK" ]; then |
| 26 | + INSTALL_LOCK=true |
| 27 | + fi |
| 28 | + |
| 29 | + # Substitude the environment variables in the template |
| 30 | + APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \ |
| 31 | + RUN_MODE=${RUN_MODE:-"dev"} \ |
| 32 | + RUN_USER=${USER:-"git"} \ |
| 33 | + SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \ |
| 34 | + HTTP_PORT=${HTTP_PORT:-"3000"} \ |
| 35 | + ROOT_URL=${ROOT_URL:-""} \ |
| 36 | + DISABLE_SSH=${DISABLE_SSH:-"false"} \ |
| 37 | + SSH_PORT=${SSH_PORT:-"2222"} \ |
| 38 | + SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-$SSH_PORT} \ |
| 39 | + DB_TYPE=${DB_TYPE:-"sqlite3"} \ |
| 40 | + DB_HOST=${DB_HOST:-"localhost:3306"} \ |
| 41 | + DB_NAME=${DB_NAME:-"gitea"} \ |
| 42 | + DB_USER=${DB_USER:-"root"} \ |
| 43 | + DB_PASSWD=${DB_PASSWD:-""} \ |
| 44 | + INSTALL_LOCK=${INSTALL_LOCK:-"false"} \ |
| 45 | + DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \ |
| 46 | + REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \ |
| 47 | + SECRET_KEY=${SECRET_KEY:-""} \ |
| 48 | + envsubst < /etc/templates/app.ini > ${GITEA_APP_INI} |
| 49 | +fi |
0 commit comments