diff options
author | Victor Morales <victor.morales@intel.com> | 2018-02-17 03:52:57 -0500 |
---|---|---|
committer | Victor Morales <victor.morales@intel.com> | 2018-02-17 03:52:57 -0500 |
commit | 5be79b4a0bd1b1face1ef915b1f1539162fdd2b8 (patch) | |
tree | b522c161bdc090ae64ad42b6260609b6a4701327 /bootstrap/vagrant-onap | |
parent | 139e934f1d744834b3a71ae1294f8fbe1cb8fd67 (diff) |
Improve setup_libvirt.sh script
The scope of the setup_libvirt.sh script was limited to cover only
the installation of libvirt dependencies, this change pretends to
cover the installation of vagrant and virtualbox and/or libvirt for
different distros.
Change-Id: I1ffd4478046cb64ad164f88d9bab078f246f0677
Signed-off-by: Victor Morales <victor.morales@intel.com>
Issue-ID: INT-370
Diffstat (limited to 'bootstrap/vagrant-onap')
-rwxr-xr-x | bootstrap/vagrant-onap/tools/setup.sh | 133 | ||||
-rwxr-xr-x | bootstrap/vagrant-onap/tools/setup_libvirt.sh | 21 |
2 files changed, 133 insertions, 21 deletions
diff --git a/bootstrap/vagrant-onap/tools/setup.sh b/bootstrap/vagrant-onap/tools/setup.sh new file mode 100755 index 000000000..fe3a3fc28 --- /dev/null +++ b/bootstrap/vagrant-onap/tools/setup.sh @@ -0,0 +1,133 @@ +#!/bin/bash +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2017-2018 +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +vagrant_version=2.0.2 + +function usage { + cat <<EOF +usage: setup.sh -p <PROVIDER> +Argument: + -p Vagrant provider +EOF +} + +while getopts ":p:" OPTION; do + case $OPTION in + p) + provider=$OPTARG + ;; + \?) + usage + exit 1 + ;; + esac +done + +case $provider in + "virtualbox" | "libvirt" ) + export VAGRANT_DEFAULT_PROVIDER=${provider} + ;; + * ) + usage + exit 1 +esac +source /etc/os-release || source /usr/lib/os-release + +packages=() +case ${ID,,} in + *suse) + INSTALLER_CMD="sudo -H -E zypper -q install -y --no-recommends" + + # Vagrant installation + vagrant_pgp="pgp_keys.asc" + wget -q https://keybase.io/hashicorp/$vagrant_pgp + wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.rpm + gpg --quiet --with-fingerprint $vagrant_pgp + sudo rpm --import $vagrant_pgp + sudo rpm --checksig vagrant_${vagrant_version}_x86_64.rpm + sudo rpm --install vagrant_${vagrant_version}_x86_64.rpm + rm vagrant_${vagrant_version}_x86_64.rpm + rm $vagrant_pgp + + case $VAGRANT_DEFAULT_PROVIDER in + virtualbox) + wget -q http://download.virtualbox.org/virtualbox/rpm/opensuse/$VERSION/virtualbox.repo -P /etc/zypp/repos.d/ + $INSTALLER_CMD --enablerepo=epel dkms + wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import - + packages+=(VirtualBox-5.1) + ;; + libvirt) + # vagrant-libvirt dependencies + packages+=(qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm zlib-devel libxml2-devel libxslt-devel make) + # NFS + packages+=(nfs-kernel-server) + ;; + esac + sudo zypper -n ref + ;; + + ubuntu|debian) + INSTALLER_CMD="sudo -H -E apt-get -y -q=3 install" + + # Vagrant installation + wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.deb + sudo dpkg -i vagrant_${vagrant_version}_x86_64.deb + rm vagrant_${vagrant_version}_x86_64.deb + + case $VAGRANT_DEFAULT_PROVIDER in + virtualbox) + echo "deb http://download.virtualbox.org/virtualbox/debian trusty contrib" >> /etc/apt/sources.list + wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - + wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add - + packages+=(virtualbox-5.1 dkms) + ;; + libvirt) + # vagrant-libvirt dependencies + packages+=(qemu libvirt-bin ebtables dnsmasq libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev) + # NFS + packages+=(nfs-kernel-server) + ;; + esac + sudo apt-get update + ;; + + rhel|centos|fedora) + PKG_MANAGER=$(which dnf || which yum) + sudo $PKG_MANAGER updateinfo + INSTALLER_CMD="sudo -H -E ${PKG_MANAGER} -q -y install" + + # Vagrant installation + wget -q https://releases.hashicorp.com/vagrant/$vagrant_version/vagrant_${vagrant_version}_x86_64.rpm + $INSTALLER_CMD vagrant_${vagrant_version}_x86_64.rpm + rm vagrant_${vagrant_version}_x86_64.rpm + + case $VAGRANT_DEFAULT_PROVIDER in + virtualbox) + wget -q http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo -P /etc/yum.repos.d + $INSTALLER_CMD --enablerepo=epel dkms + wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | rpm --import - + packages+=(VirtualBox-5.1) + ;; + libvirt) + # vagrant-libvirt dependencies + packages+=(qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm) + # NFS + packages+=(nfs-utils nfs-utils-lib) + ;; + esac + ;; + +esac + +${INSTALLER_CMD} ${packages[@]} +if [ $VAGRANT_DEFAULT_PROVIDER == libvirt ]; then + vagrant plugin install vagrant-libvirt + sudo usermod -a -G libvirt $USER +fi diff --git a/bootstrap/vagrant-onap/tools/setup_libvirt.sh b/bootstrap/vagrant-onap/tools/setup_libvirt.sh deleted file mode 100755 index 54003d691..000000000 --- a/bootstrap/vagrant-onap/tools/setup_libvirt.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -export VAGRANT_DEFAULT_PROVIDER=libvirt - -source /etc/os-release || source /usr/lib/os-release -case ${ID,,} in - *suse) - ;; - ubuntu|debian) - # vagrant-libvirt dependencies - sudo apt-get install -y qemu libvirt-bin ebtables dnsmasq libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev - - # NFS - sudo apt-get install -y nfs-kernel-server - ;; - rhel|centos|fedora) - PKG_MANAGER=$(which dnf || which yum) - sudo $PKG_MANAGER install -y qemu libvirt libvirt-devel ruby-devel gcc qemu-kvm - ;; -esac -vagrant plugin install vagrant-libvirt |