123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #!/bin/sh
- # generic variables
- GITEA_DIRS="/data/gitea/conf /data/gitea/log /data/git /data/ssh /data/ssl"
-
- # 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)
- ROOT_URL=$(iniget /data/gitea/conf/app.ini server ROOT_URL)
- 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
-
- if [ -n $DOMAIN ]; then
- if [ -n $ENABLE_SSL ]; then
- ROOT_URL=https://$DOMAIN
- else
- ROOT_URL=http://$DOMAIN
- fi
-
- if [ -z $SSH_DOMAIN ]; then
- SSH_DOMAIN=$DOMAIN
- fi
- else
- if [ -n $ENABLE_SSL ]; then
- echo "Can't use ENABLE_SSL without DOMAIN set"
- exit 1
- fi
- fi
- fi
- set +a
-
- exec /bin/s6-svscan /etc/s6
|