Files
zulip/tools/provision
Anders Kaseorg c669626666 provision: Fix shellcheck warnings.
In tools/provision line 13:
FAIL="\033[91m"
      ^-- SC1117: Backslash is literal in "\0". Prefer explicit escaping: "\\0".

In tools/provision line 14:
WARNING="\033[93m"
         ^-- SC1117: Backslash is literal in "\0". Prefer explicit escaping: "\\0".

In tools/provision line 15:
ENDC="\033[0m"
      ^-- SC1117: Backslash is literal in "\0". Prefer explicit escaping: "\\0".

In tools/provision line 19:
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
                              ^-- SC2128: Expanding an array without an index only gives the first element.

In tools/provision line 32:
if [ $failed = 1 ]; then
     ^-- SC2086: Double quote to prevent globbing and word splitting.

In tools/provision line 49:
    echo 'or just close this shell and start a new one (with Vagrant, `vagrant ssh`).'
         ^-- SC2016: Expressions don't expand in single quotes, use double quotes for that.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2018-08-03 09:15:27 -07:00

54 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# 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.
set -e
if [ "$EUID" -eq 0 ]; then
echo "Error: The provision script must not be run as root" >&2
exit 1
fi
FAIL='\033[91m'
WARNING='\033[93m'
ENDC='\033[0m'
#Make the script independent of the location from where it is
#executed
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$PARENT_PATH"
mkdir -p ../var/log
LOG_PATH="../var/log/provision.log"
echo "PROVISIONING STARTING." >> $LOG_PATH
# PYTHONUNBUFFERED is important to ensure that tracebacks don't get
# lost far above where they should be in the output.
export PYTHONUNBUFFERED=1
./lib/provision.py "$@" 2>&1 | tee -a "$LOG_PATH"
failed=${PIPESTATUS[0]}
if [ "$failed" = 1 ]; then
echo -e "$FAIL"
echo "Provisioning failed!"
echo
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"
echo -e "$ENDC"
exit 1
elif [ "$VIRTUAL_ENV" != "/srv/zulip-py3-venv" ] && [ -z "${TRAVIS}${SKIP_VENV_SHELL_WARNING}" ]; then
echo -e "$WARNING"
echo "WARNING: This shell does not have the Zulip Python 3 virtualenv activated."
echo "Zulip commands will fail until you activate the virtualenv."
echo
echo "To update the shell, run:"
echo " source /srv/zulip-py3-venv/bin/activate"
# shellcheck disable=SC2016
echo 'or just close this shell and start a new one (with Vagrant, `vagrant ssh`).'
echo -en "$ENDC"
fi
exit 0