You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

entrypoint 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/sh
  2. # generic variables
  3. GITEA_DIRS="/data/gitea/conf /data/gitea/log /data/git /data/ssh /data/ssl"
  4. # ensuring s6 service files permissions
  5. chmod +x /etc/s6/**/*
  6. ### COPIED FROM ORIGINAL /usr/bin/entrypoint
  7. if [ "${USER}" != "git" ]; then
  8. # rename user
  9. sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd
  10. # switch sshd config to different user
  11. sed -i -e "s/AllowUsers git/AllowUsers ${USER}/g" /etc/ssh/sshd_config
  12. fi
  13. ## Change GID for USER?
  14. if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then
  15. sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group
  16. sed -i -e "s/^${USER}:\([^:]*\):\([0-9]*\):[0-9]*/${USER}:\1:\2:${USER_GID}/" /etc/passwd
  17. fi
  18. ## Change UID for USER?
  19. if [ -n "${USER_UID}" ] && [ "${USER_UID}" != "`id -u ${USER}`" ]; then
  20. sed -i -e "s/^${USER}:\([^:]*\):[0-9]*:\([0-9]*\)/${USER}:\1:${USER_UID}:\2/" /etc/passwd
  21. fi
  22. ### END OF COPY
  23. # create missing dirs if they doesn't exist
  24. for DIR in $GITEA_DIRS; do
  25. mkdir -p $DIR
  26. done
  27. # configuration bootstrap (if configuration file exists it takes precedence over shell variables)
  28. set -a
  29. if [ -f /data/gitea/conf/app.ini ]; then
  30. DB_HOST=$(iniget /data/gitea/conf/app.ini database HOST)
  31. DB_TYPE=$(iniget /data/gitea/conf/app.ini database DB_TYPE)
  32. DB_USER=$(iniget /data/gitea/conf/app.ini database USER)
  33. DB_NAME=$(iniget /data/gitea/conf/app.ini database NAME)
  34. DB_PASSWD=$(iniget /data/gitea/conf/app.ini database NAME)
  35. ROOT_URL=$(iniget /data/gitea/conf/app.ini server ROOT_URL)
  36. else
  37. DB_HOST="localhost:3306"
  38. DB_TYPE="mysql"
  39. DB_USER=${DB_USER:-"gitea"}
  40. DB_NAME=${DB_NAME:-"gitea"}
  41. if [ -z "${DB_PASSWD}" ]; then
  42. export DB_PASSWD=$(pwgen -1 32)
  43. echo "Automagically generated database password: $DB_PASSWD"
  44. fi
  45. if [ -n $DOMAIN ]; then
  46. if [ -n $ENABLE_SSL ]; then
  47. ROOT_URL=https://$DOMAIN
  48. else
  49. ROOT_URL=http://$DOMAIN
  50. fi
  51. if [ -z $SSH_DOMAIN ]; then
  52. SSH_DOMAIN=$DOMAIN
  53. fi
  54. else
  55. if [ -n $ENABLE_SSL ]; then
  56. echo "Can't use ENABLE_SSL without DOMAIN set"
  57. exit 1
  58. fi
  59. fi
  60. fi
  61. set +a
  62. exec /bin/s6-svscan /etc/s6