Skip to content

Add Vagrantfile to spin up Ubuntu, Centos and SLES for mhvtl #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ tools.db
# Coverage default folders
.coverage
htmlcov/

# Vagrant files
.vagrant/
/vagrant/*.log
29 changes: 29 additions & 0 deletions vagrant/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box_check_update = false

config.vm.define "ubuntu" do |instance|
instance.vm.box = "ubuntu/xenial64"
end

config.vm.define "centos" do |instance|
instance.vm.box = "geerlingguy/centos7"
end

config.vm.define "opensuse" do |instance|
instance.vm.box = "toni03/opensuse-leap15"
end

config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end

config.vm.synced_folder "../", "/vagrant_data"

config.vm.provision "shell", inline: <<-SHELL
cd /vagrant_data/vagrant
sudo ./install_mhVTL.sh
SHELL
end
92 changes: 92 additions & 0 deletions vagrant/install_mhVTL.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash
echo "Script Begin"

get_os_name(){
if [[ "$(hostnamectl | grep -i ubuntu | wc -l)" != "0" ]]; then
OS_NAME='ubuntu'
elif [[ "$(hostnamectl | grep -i sles | wc -l)" != "0" ]]; then
OS_NAME='sles'
elif [[ "$(hostnamectl | grep -i opensuse | wc -l)" != "0" ]]; then
OS_NAME='opensuse'
elif [[ "$(hostnamectl | grep -i centos | wc -l)" != "0" ]]; then
OS_NAME='centos'
else
echo 'This os is not supported!'
exit 1
fi
echo "OS_NAME is $OS_NAME"
}

# check our script has been started with root auth
if [[ "$(id -u)" != "0" ]]; then
echo "This script must be run with root privileges. Please run again as either root or using sudo."
tput sgr0
exit 1
fi

get_os_name

# Lets break the script if there are any errors
set -e

install_ubuntu_pre_req(){
sudo apt-get update && sudo apt-get install sysstat lzop liblzo2-dev liblzo2-2 mtx mt-st sg3-utils zlib1g-dev git lsscsi build-essential gawk alien fakeroot linux-headers-$(uname -r) -y
}
install_centos_pre_req(){
sudo yum update -y && sudo yum install -y git mc ntp gcc gcc-c++ make kernel-devel-$(uname -r) zlib-devel sg3_utils lsscsi mt-st mtx lzo lzo-devel perl-Config-General
}
install_sles_pre_req(){
echo "SLES/OpenSuse IS NOT YET SUPPORTED! Use it at your own risk!"

# Workaround so that we install the same kernel-devel and kernel-syms version as the running kernel.
UNAME_R=$(echo $(uname -r) | cut -d "-" -f-2)
PATCHED_KERNEL_VERSION=$(sudo zypper se -s kernel-devel | grep ${UNAME_R} | cut -d "|" -f4 | tr -d " ")
sudo zypper install -y --oldpackage kernel-devel-${PATCHED_KERNEL_VERSION}
sudo zypper install -y --oldpackage kernel-syms-${PATCHED_KERNEL_VERSION}

sudo zypper install -y git mc ntp gcc gcc-c++ make zlib-devel sg3_utils lsscsi mtx lzo lzo-devel perl-Config-General
}

install_pre_req(){
if [[ ${OS_NAME} == 'ubuntu' ]]; then
install_ubuntu_pre_req
elif [[ ${OS_NAME} == 'centos' ]]; then
install_centos_pre_req
elif [[ ${OS_NAME} == 'sles' ]] || [[ ${OS_NAME} == 'opensuse' ]]; then
install_sles_pre_req
fi
}

# Install required packages
install_pre_req

# Clone the mhVTL project
sudo mkdir -p /src/
git clone https://github.com/markh794/mhvtl.git /src/mhvtl
cd /src/mhvtl/
make distclean
cd kernel/
make
sudo make install
cd ..
make
sudo make install
sudo rm -rf mhvtl

# Load it
sudo systemctl daemon-reload
sudo systemctl enable mhvtl.target
sudo systemctl start mhvtl.target

sleep 3
echo "Show your tape libraries now!"
lsscsi -g

echo ""
if [[ "$(lsscsi -g | wc -l)" -gt 8 ]]
then
echo "Found some virtual tapes, success!"
else
echo "Could not find the virtual tapes, the installation failed!"
exit 1
fi