Easy Install for Debian/Ubuntu

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Easy Install for Debian/Ubuntu

james2k2
Hi All,

Below is a script I have been writing, which is modified from the original by bvincent (who I think modified theirs from somebody else) so thanks to everybody who's put in to this already! I am only so-so with Linux in general, so if I've made any stupid mistakes, please point them out. The script is successful on my Debian 6 install, and the original was successful in Ubuntu 12.xx, and bvincent said Ubuntu 11.10 worked for them too. With this script, I was able to successfully use the excellent GUI by NIA (I think) and create a valid target for my Windows Server 2008 R2 running DPM (Microsoft Data Protection Manager) 2010 and could backup successfully.

Have fun!

#!/bin/sh 
# Script to download, compile and install mhvtl/mhvtl-gui (webui) 
# Tested on Debian 6 (Original script was tested on Ubuntu 11.10 and 12.xx so should work still) 
# 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)
# Last Updated 04/04/2013

# 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 libconfig-general-perl apache2 php5 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/ 
git clone http://github.com/markh794/mhvtl.git >> $LOGFILE
cd mhvtl 
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 service mhvtl start >> $LOGFILE

# download and install mhvtl-gui 
logText "Download and Install mhvtl-gui"
logText "Create a backup of sudoers... /etc/sudoers.old" simple
sudo cp /etc/sudoers /etc/sudoers.old >> $LOGFILE
sudo sed -i '/Defaults    requiretty/s/^/#/' /etc/sudoers >> $LOGFILE 
sudo sed -i '$a www-data ALL=(ALL) NOPASSWD: ALL' /etc/sudoers >> $LOGFILE
cd /var/www/ 
sudo git clone http://github.com/niadev67/mhvtl-gui.git >> $LOGFILE
sudo chown -R www-data:www-data ./ >> $LOGFILE
sudo mv mhvtl-gui mhvtl >> $LOGFILE
sudo service apache2 restart >> $LOGFILE

# tidy up some data
logText "Tidy Up Data"
sudo cp /var/www/mhvtl/stgt.git/scripts/tgt-admin /usr/sbin/tgt-admin >> $LOGFILE

# finished message 
cat<<EOD>>$HOME/src/mhvtl-install-notes 
           Please complete the following steps to finsih the install. 
                1) Browse to http://your.host.name/mhvtl
                2) Login with password 'mhvtl' 
                3) Use the mhvtl webgui to configure the mhvtl library, map, driver and tapes 
                4) Login to the mhvtl webgui and use the "iscsi target" menu item to install tgtd (the iSCSI target software) 
                5) Login to the mhvtl webgui and use the "iscsi target" menu uitem to Create Automatic iSCSI Configuration, 
                   and set the tgtd service. 
EOD 
cat<<EOF 
           Please complete the following steps to finsih the install. 
                1) Browse to http://your.host.name/mhvtl
                2) Login with password 'mhvtl' 
                3) Use the mhvtl webgui to configure the mhvtl library, map, driver and tapes 
                4) Login to the mhvtl webgui and use the "iscsi target" menu item to install tgtd (the iSCSI target software) 
                5) Login to the mhvtl webgui and use the "iscsi target" menu item to Create Automatic iSCSI Configuration, 
                   and set the tgtd service. 

                          This message is saved to '$HOME/src/mhvtl-install-notes' 
                          To view the message, run 'cat $HOME/src/mhvtl-install-notes' 
EOF 
nia
Reply | Threaded
Open this post in threaded view
|

Re: Easy Install for Debian/Ubuntu

nia
Administrator
Cool ..

Thanks

-nia