Skip to content

Instantly share code, notes, and snippets.

@hrchu
Last active September 19, 2022 19:57
Show Gist options
  • Save hrchu/3eb1c0aa9994df0328037fff04cd889d to your computer and use it in GitHub Desktop.
Save hrchu/3eb1c0aa9994df0328037fff04cd889d to your computer and use it in GitHub Desktop.
mhVTL install script for Ubuntu 16.04 (tested on the kernel version that less or equal 4.15.0)
#!/bin/sh
# Script to download, compile and install mhvtl
# Tested on ubuntu 16.04
# Origin: http://mhvtl-a-linux-virtual-tape-library.966029.n3.nabble.com/Easy-Install-for-Debian-Ubuntu-td4025413.html
# 03/04/13
# Added libconfig-general-perl (ensures tgt-admin can run)
# 04/04/13
# Added line to append www-data to sudoers automatically
# Added check for sudo/root
# Added copy for tgt-admin in sbin (fixes persistant config in tgt mhvtl-gui)
# Added logging (log output to /tmp/log-mhvtl-install)
# 02/27/18
# Fetch Makefile fixed forked repos
# Remove GUI install part since it is not work anymore
# Last Updated 02/27/2018
# config script vars
NONE='\033[00m'
RED='\033[01;31m'
GREEN='\033[01;32m'
BOLD='\033[1m'
LOGFILE='/tmp/log-mhvtl-install'
# function logs text string to screen and file
logText()
{
TEXT=$1
TLEN=${#TEXT}
a=0
TOUT=""
while [ $a -lt $TLEN ]; do
TOUT="$TOUT#"
a=$((a+1))
done
if [ $2!="simple" ]; then
echo "########$TOUT\n### $TEXT ###\n$TOUT########" >> $LOGFILE
else
echo "$TEXT" >> $LOGFILE
fi
echo "${GREEN}${BOLD}$TEXT${NONE}"
tput sgr0
}
echo "" > $LOGFILE
logText "Script Begin"
# check our script has been started with root auth
if [ "$(id -u)" != "0" ]; then
echo "${RED}${BOLD}This script must be run with root privileges. Please run again as either root or using sudo.${NONE}"
tput sgr0
exit 1
fi
# install required packages
logText "Downloading and Installing Packages"
sudo apt-get update >> $LOGFILE && 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 >> $LOGFILE; cd $HOME
# make a src directory if it doesnt already exist
logText "Check $HOME/src exists"
if [ ! -d $HOME/src ]; then
logText "Creating directory $HOME/src" simple
mkdir $HOME/src
fi
# create user, group and folders
logText "Create Users, Groups and Folders"
sudo groupadd -r vtl >> $LOGFILE
sudo useradd -r -c "Virtual Tape Library" -d /opt/mhvtl -g vtl vtl -s /bin/bash >> $LOGFILE
sudo mkdir -p /opt/mhvtl >> $LOGFILE
sudo mkdir -p /etc/mhvtl >> $LOGFILE
sudo chown -Rf vtl:vtl /opt/mhvtl >> $LOGFILE
sudo chown -Rf vtl:vtl /etc/mhvtl >> $LOGFILE
# download, compile and install mhvtl
logText "Download, Compile and Install mhvtl"
cd $HOME/src/ >> $LOGFILE
git clone https://github.com/markh794/mhvtl.git
cd mhvtl >> $LOGFILE
make distclean >> $LOGFILE
cd kernel/
make >> $LOGFILE && sudo make install >> $LOGFILE
cd ..
make >> $LOGFILE && sudo make install >> $LOGFILE
# fix some errors
logText "Fix some errors"
sudo mkdir /etc/tgt >> $LOGFILE
sudo ln -s /usr/lib64/libvtlscsi.so /usr/lib/ >> $LOGFILE
sudo /etc/init.d/mhvtl start >> $LOGFILE
sleep 3
logText "Show your tape libraries now!"
lsscsi
@xaminmo
Copy link

xaminmo commented May 4, 2018

in src/mhvtl/usr/Makefile, BINGROUP does not get defined, and must be fixed manually.

Also, mkvtl.service does not get created. You can run /etc/init.d/mhvtl start

Prior to start, you need to create, or after start, you need to edit these:
/etc/mhvtl/library_contents.10
/etc/mhvtl/library_contents.30

@hrchu
Copy link
Author

hrchu commented Jun 21, 2018

@xaminmo fixed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment