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.

35 lines
1005 B

  1. #!/usr/bin/env bash
  2. set -o errexit
  3. root="$(dirname "$0")/../.."
  4. app="${root}/app"
  5. venv="${root}/venv"
  6. if [[ ! -f "${venv}/bin/python" ]]; then
  7. echo "Creating virtualenv"
  8. mkdir -p "${venv}"
  9. python3 -m venv "${venv}"
  10. "${venv}/bin/pip" install --upgrade pip setuptools
  11. fi
  12. echo "Installing dependencies"
  13. apt-get update && apt-get install -y g++ unixodbc-dev # pyodbc build dependencies
  14. "${venv}/bin/pip" install -r "${app}/requirements.txt"
  15. echo "Initializing database"
  16. "${venv}/bin/python" "${app}/manage.py" wait_for_db
  17. "${venv}/bin/python" "${app}/manage.py" migrate
  18. "${venv}/bin/python" "${app}/manage.py" create_roles
  19. if [[ -n "${ADMIN_USERNAME}" ]] && [[ -n "${ADMIN_PASSWORD}" ]] && [[ -n "${ADMIN_EMAIL}" ]]; then
  20. "${venv}/bin/python" "${app}/manage.py" create_admin \
  21. --username "${ADMIN_USERNAME}" \
  22. --password "${ADMIN_PASSWORD}" \
  23. --email "${ADMIN_EMAIL}" \
  24. --noinput \
  25. || true
  26. fi
  27. echo "Starting django"
  28. "${venv}/bin/python" -u "${app}/manage.py" runserver "$@"