2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
15 if ! $(vagrant version &>/dev/null); then
16 enable_vagrant_install=true
18 if [[ "$vagrant_version" != "$(vagrant version | awk 'NR==1{print $3}')" ]]; then
19 enable_vagrant_install=true
25 usage: $0 -p <PROVIDER>
26 Installation of vagrant and its dependencies in Linux OS
33 while getopts ":p:" OPTION; do
44 if [[ -z "${provider+x}" ]]; then
50 "virtualbox" | "libvirt" )
51 export VAGRANT_DEFAULT_PROVIDER=${provider}
57 source /etc/os-release || source /usr/lib/os-release
59 libvirt_group="libvirt"
63 INSTALLER_CMD="sudo -H -E zypper -q install -y --no-recommends"
64 packages+=(python-devel)
66 # Vagrant installation
67 if [[ "${enable_vagrant_install+x}" ]]; then
68 vagrant_pgp="pgp_keys.asc"
69 wget -q https://keybase.io/hashicorp/$vagrant_pgp
70 wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.rpm
71 gpg --quiet --with-fingerprint $vagrant_pgp
72 sudo rpm --import $vagrant_pgp
73 sudo rpm --checksig vagrant_${vagrant_version}_x86_64.rpm
74 sudo rpm --install vagrant_${vagrant_version}_x86_64.rpm
75 rm vagrant_${vagrant_version}_x86_64.rpm
79 case $VAGRANT_DEFAULT_PROVIDER in
81 wget -q http://download.virtualbox.org/virtualbox/rpm/opensuse/$VERSION/virtualbox.repo -P /etc/zypp/repos.d/
82 $INSTALLER_CMD --enablerepo=epel dkms
83 wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -
84 packages+=(VirtualBox-5.1)
87 # vagrant-libvirt dependencies
88 packages+=(qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm zlib-devel libxml2-devel libxslt-devel make)
90 packages+=(nfs-kernel-server)
97 libvirt_group="libvirtd"
98 INSTALLER_CMD="sudo -H -E apt-get -y -q=3 install"
99 packages+=(python-dev)
101 # Vagrant installation
102 if [[ "${enable_vagrant_install+x}" ]]; then
103 wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.deb
104 sudo dpkg -i vagrant_${vagrant_version}_x86_64.deb
105 rm vagrant_${vagrant_version}_x86_64.deb
108 case $VAGRANT_DEFAULT_PROVIDER in
110 echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" >> /etc/apt/sources.list
111 wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
112 wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
113 packages+=(virtualbox-5.1 dkms)
116 # vagrant-libvirt dependencies
117 packages+=(qemu libvirt-bin ebtables dnsmasq libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev)
119 packages+=(nfs-kernel-server)
126 PKG_MANAGER=$(which dnf || which yum)
127 sudo $PKG_MANAGER updateinfo
128 INSTALLER_CMD="sudo -H -E ${PKG_MANAGER} -q -y install"
129 packages+=(python-devel)
131 # Vagrant installation
132 if [[ "${enable_vagrant_install+x}" ]]; then
133 wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.rpm
134 $INSTALLER_CMD vagrant_${vagrant_version}_x86_64.rpm
135 rm vagrant_${vagrant_version}_x86_64.rpm
138 case $VAGRANT_DEFAULT_PROVIDER in
140 wget -q http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo -P /etc/yum.repos.d
141 $INSTALLER_CMD --enablerepo=epel dkms
142 wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import -
143 packages+=(VirtualBox-5.1)
146 # vagrant-libvirt dependencies
147 packages+=(qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm)
149 packages+=(nfs-utils nfs-utils-lib)
156 ${INSTALLER_CMD} ${packages[@]}
158 curl -sL https://bootstrap.pypa.io/get-pip.py | sudo python
160 sudo -H pip install --upgrade pip
161 sudo -H pip install tox
162 if [[ ${http_proxy+x} ]]; then
163 vagrant plugin install vagrant-proxyconf
165 if [ $VAGRANT_DEFAULT_PROVIDER == libvirt ]; then
166 vagrant plugin install vagrant-libvirt
167 sudo usermod -a -G $libvirt_group $USER # This might require to reload user's group assigments
168 sudo systemctl restart libvirtd