2018-12-18 02:08:53 +01:00
|
|
|
#!/usr/bin/env bash
|
2017-01-19 01:42:04 +01:00
|
|
|
|
|
|
|
# Use this script to provision dependencies for your Zulip installation.
|
|
|
|
# This script is idempotent, so it can be restarted at any time, and it
|
|
|
|
# will usually run fairly quickly when your dependencies are up to date.
|
|
|
|
|
2017-01-14 11:19:26 +01:00
|
|
|
set -e
|
|
|
|
if [ "$EUID" -eq 0 ]; then
|
|
|
|
echo "Error: The provision script must not be run as root" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-10-20 02:58:33 +02:00
|
|
|
if [ -e "$(dirname "${BASH_SOURCE[0]}")/../.vagrant" ] && [ ! -e /home/vagrant ]; then
|
|
|
|
echo 'Error: provision should be run inside the Vagrant environment.' >&2
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
echo 'Try `vagrant up --provision`.' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-09-03 00:29:59 +02:00
|
|
|
os="$(. /etc/os-release && echo "$ID $VERSION_ID")"
|
|
|
|
case "$os" in
|
2022-04-19 03:18:48 +02:00
|
|
|
'ubuntu 14.04' | 'ubuntu 16.04' | 'ubuntu 18.04' | 'debian 10')
|
2020-09-03 00:29:59 +02:00
|
|
|
echo "Error: $os is no longer a supported platform for Zulip." >&2
|
|
|
|
if [ -e /home/vagrant ]; then
|
|
|
|
# shellcheck disable=SC2016
|
|
|
|
echo 'To upgrade, run `vagrant destroy`, and then recreate the Vagrant guest.' >&2
|
|
|
|
echo 'See: https://zulip.readthedocs.io/en/latest/development/setup-vagrant.html' >&2
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
python_version="$(python3 --version)"
|
|
|
|
case "$python_version" in
|
2022-04-19 03:18:48 +02:00
|
|
|
Python\ 3.[0-7].*)
|
|
|
|
echo 'Error: Zulip requires an OS with Python 3.8 or later.' >&2
|
2020-09-03 00:29:59 +02:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2018-08-03 02:14:49 +02:00
|
|
|
FAIL='\033[91m'
|
|
|
|
WARNING='\033[93m'
|
|
|
|
ENDC='\033[0m'
|
2018-01-25 12:35:27 +01:00
|
|
|
|
2019-01-05 00:15:36 +01:00
|
|
|
# Make the script independent of the location from where it is executed
|
2020-10-15 04:55:57 +02:00
|
|
|
PARENT_PATH=$(
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
|
|
pwd -P
|
|
|
|
)
|
2017-01-14 11:19:26 +01:00
|
|
|
cd "$PARENT_PATH"
|
|
|
|
mkdir -p ../var/log
|
|
|
|
LOG_PATH="../var/log/provision.log"
|
|
|
|
|
2020-10-15 04:55:57 +02:00
|
|
|
echo "PROVISIONING STARTING." >>$LOG_PATH
|
2017-01-14 11:19:26 +01:00
|
|
|
|
2017-01-17 23:23:59 +01:00
|
|
|
# PYTHONUNBUFFERED is important to ensure that tracebacks don't get
|
|
|
|
# lost far above where they should be in the output.
|
|
|
|
export PYTHONUNBUFFERED=1
|
2017-08-09 23:38:55 +02:00
|
|
|
./lib/provision.py "$@" 2>&1 | tee -a "$LOG_PATH"
|
2017-01-14 11:19:26 +01:00
|
|
|
failed=${PIPESTATUS[0]}
|
|
|
|
|
2019-07-19 03:36:59 +02:00
|
|
|
if [ "$failed" -ne 0 ]; then
|
2018-01-25 12:35:27 +01:00
|
|
|
echo -e "$FAIL"
|
2019-07-19 03:36:59 +02:00
|
|
|
echo "Provisioning failed (exit code $failed)!"
|
2017-01-14 11:19:26 +01:00
|
|
|
echo
|
2017-01-19 01:42:04 +01:00
|
|
|
echo "* Look at the traceback(s) above to find more about the errors."
|
|
|
|
echo "* Resolve the errors or get help on chat."
|
|
|
|
echo "* If you can fix this yourself, you can re-run tools/provision at any time."
|
|
|
|
echo "* Logs are here: zulip/var/log/provision.log"
|
2018-01-25 12:35:27 +01:00
|
|
|
echo -e "$ENDC"
|
2019-07-19 03:36:59 +02:00
|
|
|
exit "$failed"
|
2021-03-15 18:39:44 +01:00
|
|
|
elif [ "$VIRTUAL_ENV" != "/srv/zulip-py3-venv" ] && [ -z "${SKIP_VENV_SHELL_WARNING}" ]; then
|
2018-01-25 12:35:27 +01:00
|
|
|
echo -e "$WARNING"
|
2018-02-05 20:40:44 +01:00
|
|
|
echo "WARNING: This shell does not have the Zulip Python 3 virtualenv activated."
|
|
|
|
echo "Zulip commands will fail until you activate the virtualenv."
|
2017-05-11 13:59:07 +02:00
|
|
|
echo
|
|
|
|
echo "To update the shell, run:"
|
|
|
|
echo " source /srv/zulip-py3-venv/bin/activate"
|
2018-08-03 02:14:49 +02:00
|
|
|
# shellcheck disable=SC2016
|
2018-05-05 19:48:09 +02:00
|
|
|
echo 'or just close this shell and start a new one (with Vagrant, `vagrant ssh`).'
|
2018-01-25 12:35:27 +01:00
|
|
|
echo -en "$ENDC"
|
2017-01-14 11:19:26 +01:00
|
|
|
fi
|
|
|
|
exit 0
|