From 8c884cd71ec164ecdf3391bc1a3d0ee0f7864222 Mon Sep 17 00:00:00 2001 From: haniffm Date: Tue, 16 Apr 2019 11:52:51 +0200 Subject: [PATCH 1/5] Add Vagrantfile to spin up Ubuntu, Centos and SLES. Also added install script to install latest mhvtl from source. The install script currently works on Ubuntu and Centos. --- .gitignore | 4 +++ Vagrantfile | 29 +++++++++++++++++++ install_mhVTL.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 Vagrantfile create mode 100755 install_mhVTL.sh diff --git a/.gitignore b/.gitignore index 37e32beb9..219779e46 100755 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,7 @@ tools.db # Coverage default folders .coverage htmlcov/ + +# Vagrant files +.vagrant/ +/*.log diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 000000000..272742e10 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,29 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| +# config.vm.box = "ubuntu/xenial64" + 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 = "centos7" + end + + config.vm.define "sles" do |instance| + instance.vm.box = "wandisco/sles-12.4-64" + end + + config.vm.provider "virtualbox" do |vb| + vb.memory = "2048" + #config.vm.provision :shell, path: "install.sh" + end + + config.vm.provision "shell", inline: <<-SHELL + cd /vagrant + sudo ./install_mhVTL.sh + SHELL +end diff --git a/install_mhVTL.sh b/install_mhVTL.sh new file mode 100755 index 000000000..c43f0723b --- /dev/null +++ b/install_mhVTL.sh @@ -0,0 +1,72 @@ +#!/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 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 zlib-devel sg3_utils lsscsi mt-st mtx lzo lzo-devel perl-Config-General +} +install_sles_pre_req(){ + echo "SLES IS NOT YET SUPPORTED!" + exit 1 +} + +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' ]]; 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 From ed906b6f3b55452501a8235d50968985c20be361 Mon Sep 17 00:00:00 2001 From: haniffm Date: Tue, 16 Apr 2019 16:50:17 +0200 Subject: [PATCH 2/5] Moved vagrant specific files into a 'vagrant' folder. Also added experimental opensuse. And made sure the install script fails when 'make' fails --- .gitignore | 2 +- Vagrantfile => vagrant/Vagrantfile | 10 +++++----- install_mhVTL.sh => vagrant/install_mhVTL.sh | 21 +++++++++++++++----- 3 files changed, 22 insertions(+), 11 deletions(-) rename Vagrantfile => vagrant/Vagrantfile (70%) rename install_mhVTL.sh => vagrant/install_mhVTL.sh (67%) diff --git a/.gitignore b/.gitignore index 219779e46..83e624e09 100755 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ htmlcov/ # Vagrant files .vagrant/ -/*.log +/vagrant/*.log diff --git a/Vagrantfile b/vagrant/Vagrantfile similarity index 70% rename from Vagrantfile rename to vagrant/Vagrantfile index 272742e10..4b83161ea 100644 --- a/Vagrantfile +++ b/vagrant/Vagrantfile @@ -2,7 +2,6 @@ # vi: set ft=ruby : Vagrant.configure("2") do |config| -# config.vm.box = "ubuntu/xenial64" config.vm.box_check_update = false config.vm.define "ubuntu" do |instance| @@ -13,17 +12,18 @@ Vagrant.configure("2") do |config| instance.vm.box = "centos7" end - config.vm.define "sles" do |instance| - instance.vm.box = "wandisco/sles-12.4-64" + config.vm.define "opensuse" do |instance| + instance.vm.box = "toni03/opensuse-leap15" end config.vm.provider "virtualbox" do |vb| vb.memory = "2048" - #config.vm.provision :shell, path: "install.sh" end + config.vm.synced_folder "../", "/vagrant_data" + config.vm.provision "shell", inline: <<-SHELL - cd /vagrant + cd /vagrant_data/vagrant sudo ./install_mhVTL.sh SHELL end diff --git a/install_mhVTL.sh b/vagrant/install_mhVTL.sh similarity index 67% rename from install_mhVTL.sh rename to vagrant/install_mhVTL.sh index c43f0723b..4824ed344 100755 --- a/install_mhVTL.sh +++ b/vagrant/install_mhVTL.sh @@ -6,6 +6,8 @@ get_os_name(){ 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 @@ -34,8 +36,15 @@ install_centos_pre_req(){ sudo yum update -y && sudo yum install -y git mc ntp gcc gcc-c++ make kernel-devel zlib-devel sg3_utils lsscsi mt-st mtx lzo lzo-devel perl-Config-General } install_sles_pre_req(){ - echo "SLES IS NOT YET SUPPORTED!" - exit 1 + 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(){ @@ -43,7 +52,7 @@ install_pre_req(){ install_ubuntu_pre_req elif [[ ${OS_NAME} == 'centos' ]]; then install_centos_pre_req - elif [[ ${OS_NAME} == 'sles' ]]; then + elif [[ ${OS_NAME} == 'sles' ]] || [[ ${OS_NAME} == 'opensuse' ]]; then install_sles_pre_req fi } @@ -57,9 +66,11 @@ git clone https://github.com/markh794/mhvtl.git /src/mhvtl cd /src/mhvtl/ make distclean cd kernel/ -make && sudo make install +make +sudo make install cd .. -make && sudo make install +make +sudo make install sudo rm -rf mhvtl # Load it From 939a6647d6f0860ed37c09cf68eea381bff46fca Mon Sep 17 00:00:00 2001 From: haniffm Date: Wed, 17 Apr 2019 13:23:52 +0200 Subject: [PATCH 3/5] Fix vagrant box for centos --- vagrant/Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index 4b83161ea..147a78073 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -9,7 +9,7 @@ Vagrant.configure("2") do |config| end config.vm.define "centos" do |instance| - instance.vm.box = "centos7" + instance.vm.box = "geerlingguy/centos7" end config.vm.define "opensuse" do |instance| From 81dcc214b6b25768cea00322f6ab82c13aec3d1f Mon Sep 17 00:00:00 2001 From: Oskar Persson Date: Thu, 2 May 2019 11:40:37 +0200 Subject: [PATCH 4/5] Apply suggestions from code review Co-Authored-By: haniffm --- vagrant/install_mhVTL.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vagrant/install_mhVTL.sh b/vagrant/install_mhVTL.sh index 4824ed344..605adc2f1 100755 --- a/vagrant/install_mhVTL.sh +++ b/vagrant/install_mhVTL.sh @@ -7,7 +7,7 @@ get_os_name(){ elif [[ "$(hostnamectl | grep -i sles | wc -l)" != "0" ]]; then OS_NAME='sles' elif [[ "$(hostnamectl | grep -i opensuse | wc -l)" != "0" ]]; then - OS_NAME='opensuse' + OS_NAME='opensuse' elif [[ "$(hostnamectl | grep -i centos | wc -l)" != "0" ]]; then OS_NAME='centos' else From 5b6126ac154b93d35cbf05da9af9025c3bb56085 Mon Sep 17 00:00:00 2001 From: haniffm Date: Sat, 4 May 2019 21:10:21 +0200 Subject: [PATCH 5/5] Fix centos kernel-header installation in vagrant --- vagrant/install_mhVTL.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/vagrant/install_mhVTL.sh b/vagrant/install_mhVTL.sh index 605adc2f1..6f0f5af0a 100755 --- a/vagrant/install_mhVTL.sh +++ b/vagrant/install_mhVTL.sh @@ -33,7 +33,7 @@ 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 zlib-devel sg3_utils lsscsi mt-st mtx lzo lzo-devel perl-Config-General + 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!" @@ -80,4 +80,13 @@ sudo systemctl start mhvtl.target sleep 3 echo "Show your tape libraries now!" -lsscsi +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