install.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/bash
  2. #
  3. # This script setups Redash along with supervisor, nginx, PostgreSQL and Redis. It was written to be used on
  4. # Ubuntu 16.04. Technically it can work with other Ubuntu versions, but you might get non compatible versions
  5. # of PostgreSQL, Redis and maybe some other dependencies.
  6. #
  7. # This script is not idempotent and if it stops in the middle, you can't just run it again. You should either
  8. # understand what parts of it to exclude or just start over on a new VM (assuming you're using a VM).
  9. set -eu
  10. REDASH_BASE_PATH=/app/code/redash
  11. REDASH_BRANCH="${REDASH_BRANCH:-master}" # Default branch/version to master if not specified in REDASH_BRANCH env var
  12. REDASH_VERSION=${REDASH_VERSION-2.0.1.b3080} # Install latest version if not specified in REDASH_VERSION env var
  13. LATEST_URL="https://s3.amazonaws.com/redash-releases/redash.${REDASH_VERSION}.tar.gz"
  14. VERSION_DIR="/app/code/redash/redash.${REDASH_VERSION}"
  15. REDASH_TARBALL=/tmp/redash.tar.gz
  16. FILES_BASE_URL=https://raw.githubusercontent.com/getredash/redash/${REDASH_BRANCH}/setup/ubuntu/files
  17. cd /tmp/
  18. verify_root() {
  19. # Verify running as root:
  20. if [ "$(id -u)" != "0" ]; then
  21. if [ $# -ne 0 ]; then
  22. echo "Failed running with sudo. Exiting." 1>&2
  23. exit 1
  24. fi
  25. echo "This script must be run as root. Trying to run with sudo."
  26. sudo bash "$0" --with-sudo
  27. exit 0
  28. fi
  29. }
  30. extract_redash_sources() {
  31. wget "$LATEST_URL" -O "$REDASH_TARBALL"
  32. mkdir "$VERSION_DIR"
  33. tar -C "$VERSION_DIR" -xvf "$REDASH_TARBALL"
  34. ln -nfs "$VERSION_DIR" /app/code/redash/current
  35. ln -fs /app/data/.env /app/code/redash/.env
  36. #ln -nfs /app/code/redash/.env /app/code/redash/current/.env
  37. }
  38. install_python_packages() {
  39. pip install --upgrade pip
  40. # TODO: venv?
  41. pip install setproctitle # setproctitle is used by Celery for "pretty" process titles
  42. pip install -r /app/code/redash/current/requirements.txt
  43. pip install -r /app/code/redash/current/requirements_all_ds.txt
  44. }
  45. verify_root
  46. extract_redash_sources
  47. install_python_packages