#!/bin/sh # generic variables GITEA_DIRS="/data/gitea/conf /data/gitea/log /data/git /data/ssh" # ensuring s6 service files permissions chmod +x /etc/s6/**/* ### COPIED FROM ORIGINAL /usr/bin/entrypoint if [ "${USER}" != "git" ]; then # rename user sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd # switch sshd config to different user sed -i -e "s/AllowUsers git/AllowUsers ${USER}/g" /etc/ssh/sshd_config fi ## Change GID for USER? if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group sed -i -e "s/^${USER}:\([^:]*\):\([0-9]*\):[0-9]*/${USER}:\1:\2:${USER_GID}/" /etc/passwd fi ## Change UID for USER? if [ -n "${USER_UID}" ] && [ "${USER_UID}" != "`id -u ${USER}`" ]; then sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:\([0-9]*\)/${USER}:\1:${USER_UID}:\2/" /etc/passwd fi ### END OF COPY # create missing dirs if they doesn't exist for DIR in $GITEA_DIRS; do mkdir -p $DIR done # configuration bootstrap (if configuration file exists it takes precedence over shell variables) set -a if [ -f /data/gitea/conf/app.ini ]; then DB_HOST=$(iniget /data/gitea/conf/app.ini database HOST) DB_TYPE=$(iniget /data/gitea/conf/app.ini database DB_TYPE) DB_USER=$(iniget /data/gitea/conf/app.ini database USER) DB_NAME=$(iniget /data/gitea/conf/app.ini database NAME) DB_PASSWD=$(iniget /data/gitea/conf/app.ini database NAME) else DB_HOST="localhost:3306" DB_TYPE="mysql" DB_USER=${DB_USER:-"gitea"} DB_NAME=${DB_NAME:-"gitea"} if [ -z "${DB_PASSWD}" ] ; then export DB_PASSWD=$(pwgen -1 32) echo "Automagically generated database password: $DB_PASSWD" fi fi set +a exec /bin/s6-svscan /etc/s6