start.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # set -eu -o pipefail
  3. echo "=> local.py"
  4. sed -e "s/##APP_DOMAIN##/${APP_DOMAIN}/" \
  5. -e "s/##MAIL_DOMAIN##/${MAIL_DOMAIN}/" \
  6. -e "s/##MAIL_FROM##/${MAIL_FROM}/" \
  7. -e "s/##MAIL_SMTP_SERVER##/${MAIL_SMTP_SERVER}/" \
  8. -e "s/##MAIL_SMTP_PORT##/${MAIL_SMTP_PORT}/" \
  9. -e "s/##MAIL_SMTP_USERNAME##/${MAIL_SMTP_USERNAME}/" \
  10. -e "s/##MAIL_SMTP_PASSWORD##/${MAIL_SMTP_PASSWORD}/" \
  11. -e "s/##POSTGRESQL_DATABASE##/${POSTGRESQL_DATABASE}/" \
  12. -e "s/##POSTGRESQL_USERNAME##/${POSTGRESQL_USERNAME}/" \
  13. -e "s/##POSTGRESQL_PASSWORD##/${POSTGRESQL_PASSWORD}/" \
  14. -e "s/##POSTGRESQL_HOST##/${POSTGRESQL_HOST}/" \
  15. -e "s/##POSTGRESQL_PORT##/${POSTGRESQL_PORT}/" \
  16. /app/code/local.py > /run/local.py
  17. if [[ -n "${LDAP_SERVER:-}" ]]; then
  18. echo "=> setup ldap"
  19. sed -e "s/##LDAP_SERVER##/${LDAP_SERVER}/" \
  20. -e "s/##LDAP_PORT##/${LDAP_PORT}/" \
  21. -e "s/##LDAP_USERS_BASE_DN##/${LDAP_USERS_BASE_DN}/" \
  22. /app/code/local_ldap.py >> /run/local.py
  23. fi
  24. if [[ -n "${LDAP_SERVER:-}" ]]; then
  25. echo "=> Update conf.json with LDAP"
  26. sed -e "s/##APP_DOMAIN##/${APP_DOMAIN}/" /app/code/conf_ldap.json > /run/conf.json
  27. else
  28. echo "=> Update conf.json"
  29. sed -e "s/##APP_DOMAIN##/${APP_DOMAIN}/" /app/code/conf.json > /run/conf.json
  30. fi
  31. echo "=> Update nginx.conf"
  32. sed -e "s,##APP_DOMAIN##,${APP_DOMAIN}," /app/code/nginx.conf > /run/nginx.conf
  33. echo "=> Setup taiga virtual env"
  34. source /app/code/taiga/bin/activate
  35. cd /app/code/taiga-back
  36. if [[ ! -d /app/data/media/user ]]; then
  37. echo "=> New installation create inital project templates"
  38. echo "=> Run migration scripts"
  39. mkdir -p /app/data/media/user
  40. python manage.py migrate --noinput
  41. python manage.py loaddata initial_project_templates
  42. else
  43. echo "=> Run migration scripts"
  44. python manage.py migrate --noinput
  45. fi
  46. # this is done here since old taiga installations do not have a superadmin
  47. echo "=> Create superadmin"
  48. python manage.py loaddata initial_user
  49. echo "=> Make cloudron own /run"
  50. chown -R cloudron:cloudron /run
  51. chown -R cloudron:cloudron /app/data
  52. echo "=> Start nginx"
  53. nginx -c /run/nginx.conf &
  54. echo "=> Start taiga-back"
  55. PATH=/app/code/taiga/bin:$PATH
  56. HOME=/app/code
  57. PYTHONPATH=/app/code/taiga/lib/python3.5/site-packages
  58. cd /app/code/taiga-back
  59. exec /usr/local/bin/gosu cloudron:cloudron gunicorn -w 1 -t 60 --pythonpath=. -b 127.0.0.1:8001 taiga.wsgi