本站源代码
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.

55 line
2.1KB

  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. SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
  24. HTTP_PORT=${HTTP_PORT:-"3000"} \
  25. ROOT_URL=${ROOT_URL:-""} \
  26. DISABLE_SSH=${DISABLE_SSH:-"false"} \
  27. SSH_PORT=${SSH_PORT:-"22"} \
  28. SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \
  29. LFS_START_SERVER=${LFS_START_SERVER:-"false"} \
  30. DB_TYPE=${DB_TYPE:-"sqlite3"} \
  31. DB_HOST=${DB_HOST:-"localhost:3306"} \
  32. DB_NAME=${DB_NAME:-"gitea"} \
  33. DB_USER=${DB_USER:-"root"} \
  34. DB_PASSWD=${DB_PASSWD:-""} \
  35. INSTALL_LOCK=${INSTALL_LOCK:-"false"} \
  36. DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \
  37. REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \
  38. SECRET_KEY=${SECRET_KEY:-""} \
  39. envsubst < /etc/templates/app.ini > ${GITEA_CUSTOM}/conf/app.ini
  40. chown ${USER}:git ${GITEA_CUSTOM}/conf/app.ini
  41. fi
  42. # only chown if current owner is not already the gitea ${USER}. No recursive check to save time
  43. if ! [[ $(ls -ld /data/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/gitea; fi
  44. if ! [[ $(ls -ld /app/gitea | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /app/gitea; fi
  45. if ! [[ $(ls -ld /data/git | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /data/git; fi
  46. chmod 0755 /data/gitea /app/gitea /data/git
上海开阖软件有限公司 沪ICP备12045867号-1