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.

setup 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. if [ ! -d /data/git/.ssh ]; then
  3. mkdir -p /data/git/.ssh
  4. chmod 700 /data/git/.ssh
  5. fi
  6. if [ ! -f /data/git/.ssh/environment ]; then
  7. echo "GITEA_CUSTOM=$GITEA_CUSTOM" >| /data/git/.ssh/environment
  8. chmod 600 /data/git/.ssh/environment
  9. elif ! grep -q "^GITEA_CUSTOM=$GITEA_CUSTOM$" /data/git/.ssh/environment; then
  10. sed -i /^GITEA_CUSTOM=/d /data/git/.ssh/environment
  11. echo "GITEA_CUSTOM=$GITEA_CUSTOM" >> /data/git/.ssh/environment
  12. fi
  13. if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then
  14. mkdir -p ${GITEA_CUSTOM}/conf
  15. # Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
  16. # INSTALL_LOCK is empty
  17. if [ -n "$SECRET_KEY" ] && [ -z "$INSTALL_LOCK" ]; then
  18. INSTALL_LOCK=true
  19. fi
  20. # Substitude the environment variables in the template
  21. APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \
  22. RUN_MODE=${RUN_MODE:-"dev"} \
  23. DOMAIN=${DOMAIN:-"localhost"} \
  24. SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
  25. HTTP_PORT=${HTTP_PORT:-"3000"} \
  26. ROOT_URL=${ROOT_URL:-""} \
  27. DISABLE_SSH=${DISABLE_SSH:-"false"} \
  28. SSH_PORT=${SSH_PORT:-"22"} \
  29. SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \
  30. LFS_START_SERVER=${LFS_START_SERVER:-"false"} \
  31. DB_TYPE=${DB_TYPE:-"sqlite3"} \
  32. DB_HOST=${DB_HOST:-"localhost:3306"} \
  33. DB_NAME=${DB_NAME:-"gitea"} \
  34. DB_USER=${DB_USER:-"root"} \
  35. DB_PASSWD=${DB_PASSWD:-""} \
  36. INSTALL_LOCK=${INSTALL_LOCK:-"false"} \
  37. DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \
  38. REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \
  39. SECRET_KEY=${SECRET_KEY:-""} \
  40. envsubst < /etc/templates/app.ini > ${GITEA_CUSTOM}/conf/app.ini
  41. chown ${USER}:git ${GITEA_CUSTOM}/conf/app.ini
  42. fi
  43. # only chown if current owner is not already the gitea ${USER}. No recursive check to save time
  44. if ! [[ $(ls -ld /data/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/gitea; fi
  45. if ! [[ $(ls -ld /app/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /app/gitea; fi
  46. if ! [[ $(ls -ld /data/git | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/git; fi
  47. chmod 0755 /data/gitea /app/gitea /data/git