blob: 3002c63393dd3d6413099059ef0a1c36ac4c1408 [file] [log] [blame]
#!/bin/bash
for FOLDER in /data/gitea/log /data/git /data/ssh; do
mkdir -p ${FOLDER}
done
if [ ! -d /data/git/.ssh ]; then
mkdir -p /data/git/.ssh
fi
if [ ! -f /data/git/.ssh/environment ]; then
echo "GITEA_CUSTOM=$GITEA_CUSTOM" >| /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
# Substitude the environment variables in the template
env -i \
APP_NAME="${APP_NAME:-"Gitea: Git with a cup of tea"}" \
RUN_MODE="${RUN_MODE:-"dev"}" \
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:-""}" \
ALLOW_ONLY_EXTERNAL_REGISTRATION="${ALLOW_ONLY_EXTERNAL_REGISTRATION:-"false"}" \
OFFLINE_MODE="${OFFLINE_MODE:-"true"}" \
MINIO_ENDPOINT="${MINIO_ENDPOINT:-""}" \
MINIO_ACCESS_KEY_ID="${MINIO_ACCESS_KEY_ID:-""}" \
MINIO_SECRET_ACCESS_KEY="${MINIO_SECRET_ACCESS_KEY:-""}" \
MINIO_BUCKET="${MINIO_BUCKET:-""}" \
MAILER_FROM="${MAILER_FROM:-""}" \
MAILER_HOST="${MAILER_HOST:-""}" \
MAILER_PORT="${MAILER_PORT:-""}" \
MAILER_USER="${MAILER_USER:-""}" \
MAILER_PASSWORD="${MAILER_PASSWORD:-""}" \
envsubst < /etc/templates/app.ini > ${GITEA_CUSTOM}/conf/app.ini
cat ${GITEA_CUSTOM}/conf/app.ini
fi
if [ $# -gt 0 ]; then
exec "$@"
else
exec /app/gitea/gitea web
fi