provision: Refuse to run outside an existing Vagrant environment.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-10-19 17:58:33 -07:00 committed by Tim Abbott
parent 0485aece4e
commit 2c27a87bcd
1 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,13 @@ if [ "$EUID" -eq 0 ]; then
exit 1 exit 1
fi fi
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
os="$(. /etc/os-release && echo "$ID $VERSION_ID")" os="$(. /etc/os-release && echo "$ID $VERSION_ID")"
case "$os" in case "$os" in
'ubuntu 14.04' | 'ubuntu 16.04') 'ubuntu 14.04' | 'ubuntu 16.04')