Blob Blame History Raw
#!/usr/bin/env bash
#
# This is a wrapper to properly execute Vagrant within the embedded
# Vagrant installation directory. This sets up proper environment variables
# so that everything loads and compiles to proper directories.

# Load defaults, especially VAGRANT_PREFERRED_PROVIDERS
if [ -r /etc/default/vagrant ]; then
  source /etc/default/vagrant
fi

# Export gem paths so that we use the isolated gems.
# TODO: Should be replaced from .spec file.
# ruby -e "print Gem.path.join(':')"
export GEM_PATH="/usr/share/gems:/usr/share/vagrant/gems"

# Export GEM_HOME based on VAGRANT_HOME
#
# This needs to be set because Bundler includes gem paths
# from RubyGems' Gem.paths.
if [ -z $VAGRANT_HOME ]; then
  VAGRANT_HOME=$(eval echo "~/.vagrant.d")
fi
export GEM_HOME="$VAGRANT_HOME/gems"


# SSL certs
export SSL_CERT_FILE="${SSL_CERT_FILE:-/etc/pki/tls/cert.pem}"

# Export an enviroment variable to say we're in a Vagrant
# installer created environment.
export VAGRANT_INSTALLER_ENV=1
# This is currently used only in Vagrant::Plugin::Manager.system_plugins_file
# to locate plugins configuration file.
export VAGRANT_INSTALLER_EMBEDDED_DIR="@vagrant_embedded_dir@"
export VAGRANT_INSTALLER_VERSION="2"

# Determine the OS that we're on, which is used in some later checks.
# It is very important we do this _before_ setting the PATH below
# because uname dependencies can conflict on some platforms.
OS=$(uname -s 2>/dev/null)

# Export the OS as an environment variable that Vagrant can access
# so that it can behave better.
export VAGRANT_DETECTED_OS="${OS}"

# Export the VAGRANT_EXECUTABLE so that pre-rubygems can optimize a bit
export VAGRANT_EXECUTABLE="${VAGRANT_INSTALLER_EMBEDDED_DIR}/gems/bin/vagrant"

# Set providers' preferred order(priority)
if [ -z $VAGRANT_PREFERRED_PROVIDERS ]; then
  VAGRANT_PREFERRED_PROVIDERS=libvirt,docker
fi
export VAGRANT_PREFERRED_PROVIDERS

# Call the actual Vagrant bin with our arguments
exec ruby "${VAGRANT_EXECUTABLE}" "$@"