Skip to content
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
155 changes: 126 additions & 29 deletions scripts/centos_prepare_ovpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,152 @@
# Script to setup a fresh installation of CentOS to run OVPL
# Installs: Dependencies: python-devel, git, pip; mongodb; openvz.

# read proxy settings from config file
if [[ -f "config.sh" ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Reading config.sh file for proxy settings" 2>&1 | tee -a $LOGFILE
source ./config.sh
if [[ -n $http_proxy ]]; then

export http_proxy=$http_proxy
echo "[[$DATE:: $0 :: Line $LINENO::]] export http_proxy = $http_proxy" 2>&1 | tee -a $LOGFILE
fi
if [[ -n $https_proxy ]]; then
export https_proxy=$https_proxy
echo "[[$DATE:: $0 :: Line $LINENO::]] export https_proxy = $https_proxy" 2>&1 | tee -a $LOGFILE
fi
else
echo "[[$DATE:: $0 :: Line $LINENO::]] config.sh file not exist" 2>&1 | tee -a $LOGFILE
exit 1
fi

if [[ -f $LOGFILE ]];then
echo "================================================="
echo "logfilepath = setup-ovpl-centos/scripts/$LOGFILE"
echo "================================================="
else
touch $LOGFILE
echo "================================================="
echo "logfilepath = setup-ovpl-centos/scripts/$LOGFILE"
echo "================================================="
fi

# check if script is run as root
if [[ $UID -ne 0 ]]; then
echo ""
echo "$0 must be run as root!"
echo "Exiting.."
echo "[[$DATE:: $0 :: Line $LINENO::]] $0 must be run as root...." 2>&1 | tee -a $LOGFILE
echo "check log file exiting...."
exit 1

else
echo "[[$DATE:: $0 :: Line $LINENO::]] Started Invoking centos_prepare_ovpl.sh...." 2>&1 | tee -a $LOGFILE

fi

# check if meta directory exists
if [[ ! -d "../meta" ]]; then
echo ""
echo "You don't have the necessary files."
echo "Please contact the author of the script."
echo "[[$DATE:: $0 :: Line $LINENO::]] You don't have the necessary files please contact the author of the script...." 2>&1 | tee -a $LOGFILE
echo "Check log file exiting...."
exit 1
fi

# read proxy settings from config file
source ./config.sh
fi

if [[ -n $http_proxy ]]; then
echo $http_proxy
export http_proxy=$http_proxy
#updating system
echo ""
echo "========================== UPDATING SYSTEM ================================"
echo "[[$DATE:: $0 :: Line $LINENO::]] Updating System...." 2>&1 | tee -a $LOGFILE
yum update -y
if [[ $? -ne 0 ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Error in updating system " 2>&1 | tee -a $LOGFILE
exit 1
else
echo ""
echo "[[$DATE:: $0 :: Line $LINENO::]] System updation complete.." 2>&1 | tee -a $LOGFILE
echo ""
fi
if [[ -n $https_proxy ]]; then
export https_proxy=$https_proxy


if [[ -f "install_dependencies.sh" ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Invoking install_dependencies.sh" 2>&1 | tee -a $LOGFILE
./install_dependencies.sh
if [ $? -ne 0 ]; then
echo ""
echo "[[$DATE:: $0 :: Line $LINENO::]] Error installing dependencies. Quitting!" 2>&1 | tee -a $LOGFILE
echo "======================"
echo "See logs at $LOGFILE"
echo "====================="
exit 1
else
echo "[[$DATE:: $0 :: Line $LINENO::]] successfully installed dependencies..." 2>&1 | tee -a $LOGFILE

fi
else
echo "[[$DATE:: $0 :: Line $LINENO::]] install_dependencies.sh file not exist" 2>&1 | tee -a $LOGFILE
exit 1
fi

echo "Invoking install_dependencies.sh"
./install_dependencies.sh
if [ $? -ne 0 ]; then
echo ""
echo "Error installing dependencies. Quitting!"
exit 1
if [[ -f "install_openvz.sh" ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Invoking install_openvz.sh" 2>&1 | tee -a $LOGFILE
./install_openvz.sh
if [ $? -ne 0 ]; then
echo ""
echo "[[$DATE:: $0 :: Line $LINENO::]] Error installing openvz. Quitting!" 2>&1 | tee -a $LOGFILE
echo "======================"
echo "See logs at $LOGFILE"
echo "====================="
exit 1
else
echo "[[$DATE:: $0 :: Line $LINENO::]] successfully installed openvz..." 2>&1 | tee -a $LOGFILE


fi
else
echo "[[$DATE:: $0:: Line $LINENO::]] install_openvz.sh file not exist" 2>&1 | tee -a $LOGFILE
exit 1
fi

echo "Invoking install_openvz.sh"
./install_openvz.sh
if [ $? -ne 0 ]; then
echo ""
echo "Error installing OpenVZ. Quitting!"
exit 1
if [[ -f "install_mongodb.sh" ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Invoking install_mongodb.sh" 2>&1 | tee -a $LOGFILE
./install_mongodb.sh
if [ $? -ne 0 ]; then
echo ""
echo "[[$DATE:: $0 :: Line $LINENO::]] Error installing mongodb. Quitting! " 2>&1 | tee -a $LOGFILE
echo "======================"
echo "See logs at $LOGFILE"
echo "====================="
exit 1

else
echo "[[$DATE:: $0 :: Line $LINENO::]] successfully installed mongodb..." 2>&1 | tee -a $LOGFILE

fi
else
echo "[[$DATE:: $0 :: Line $LINENO::]] install_mongodb.sh file not exist" 2>&1 | tee -a $LOGFILE
exit 1
fi

echo "Invoking install_mongodb.sh"
./install_mongodb.sh
if [ $? -ne 0 ]; then
echo ""
echo "Error installing MongoDB. Quitting!"
exit 1
if [[ -f "install_ovpl.sh" ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Invoking install_ovpl.sh" 2>&1 | tee -a $LOGFILE
./install_ovpl.sh
if [ $? -ne 0 ]; then
echo ""
echo "[[$DATE:: $0 :: Line $LINENO::]] Error installing ovpl. Quitting! " 2>&1 | tee -a $LOGFILE
echo "======================"
echo "See logs at $LOGFILE"
echo "====================="
exit 1
else

echo "=========================================================================================================="
echo "[[$DATE:: $0 :: Line $LINENO::]] Congrats! You have setup OVPL successfully!!! :-)" 2>&1 | tee -a $LOGFILE
echo "Now run 'make' from inside the src directory"
echo " of OVPL to start the services."
echo "=========================================================================================================="
fi
else
echo "[[$DATE:: $0 :: Line $LINENO::]] install_ovpl.sh file not exist" 2>&1 | tee -a $LOGFILE
exit 1
fi

exit 0
4 changes: 4 additions & 0 deletions scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ export http_proxy=""

#set your https proxy. Similar to the above.
export https_proxy=""

#Loggfile name
export LOGFILE="setup-ovpl.log"
export DATE=$(date)
16 changes: 10 additions & 6 deletions scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

meta_dir="../meta"

echo ""
echo "Setting up EPEL repo.."
#wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
echo "[[$DATE:: $0 :: Line $LINENO::]] Setting up EPEL repo.." 2>&1 | tee -a $LOGFILE
rpm -ivh $meta_dir/epel-release-6-8.noarch.rpm
#rm epel-release-6.8.noarch.rpm

echo ""
echo "Installing dependencies.. yum -y install gcc python-devel.x86_64 python-pip ssh git"
yum -y install gcc python-devel.x86_64 python-pip ssh git
echo "[[$DATE:: $0 :: Line $LINENO::]] Installing dependencies.. " 2>&1 | tee -a $LOGFILE
echo "[[$DATE:: $0 :: Line $LINENO::]] Running yum -y install gcc python-devel.x86_64 python-pip openssh-clients openssh-server git" 2>&1 | tee -a $LOGFILE
yum -y install gcc python-devel.x86_64 python-pip openssh-clients openssh-server git
if [[ $? -ne 0 ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Error in installing dependencies.." 2>&1 | tee -a $LOGFILE
exit 1
else
echo "[[$DATE:: $0 :: Line $LINENO::]] Completed installation of gcc python-devel.x86_64 python-pip openssh-clients openssh-server git" 2>&1 | tee -a $LOGFILE
fi

exit 0
28 changes: 20 additions & 8 deletions scripts/install_mongodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@
# Script to setup repo and install MongoDB

meta_dir="../meta"
DATE=$(date)
LOGGFILE="setup-ovpl.log"

echo ""
echo "Setting up MongoDB repo.."
echo "[[$DATE:: $0 :: Line $LINENO::]] Setting up MongoDB repo...." 2>&1 | tee -a $LOGFILE
cp $meta_dir/mongodb.repo /etc/yum.repos.d/mongodb.repo


echo ""
echo "Installing MongoDB.."
echo "[[$DATE:: $0 :: Line $LINENO::]] Installing MongoDB......" 2>&1 | tee -a $LOGFILE
yum -y install mongodb-org
if [[ $? -ne 0 ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Error in installing mongodb.." 2>&1 | tee -a $LOGFILE
exit 1
fi

echo ""
echo "Starting mongod service.."
echo "[[$DATE:: $0 :: Line $LINENO::]] Starting mongod service.." 2>&1 | tee -a $LOGFILE
service mongod start

if [ $? -eq 0 ];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Mongodb service started.." 2>&1 | tee -a $LOGFILE
elif [ $? -eq 1 ];then
sed 's/.*deamon.*/new/g' /etc/init.d/mongod
service mongod restart

else
echo "[[$DATE:: $0 :: Line $LINENO::]] Error in starting Mongodb service.." 2>&1 | tee -a $LOGFILE
exit 1

fi
exit 0
63 changes: 40 additions & 23 deletions scripts/install_openvz.sh
Original file line number Diff line number Diff line change
@@ -1,59 +1,76 @@
#!/bin/bash
# Script to setup OpenVZ repo, install and configure OpenVZ
# Script to setup OpenVZ repo, install and configure

meta_dir="../meta"
vz_template_file="ubuntu-12.04-custom-x86_64.tar.gz"


cd $meta_dir
echo "[[$DATE:: $0 :: Line $LINENO::]] Downloading $vz_template_file file to $meta_dir directory" 2>&1 | tee -a $LOGFILE
echo ""
echo "Setting up OpenVZ repo.."
wget http://community.virtual-labs.ac.in/downloads/ubuntu-12.04-custom-x86_64.tar.gz
if [[ $? -ne 0 ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Error in Downloading $vz_template_file file to $meta_dir directory.." 2>&1 | tee -a $LOGFILE
fi

#wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
echo "[$DATE:: $0 :: Line $LINENO::]] copying openvz.repo into /etc/yum/repos.d/" 2>&1 | tee -a $LOGFILE
cp $meta_dir/openvz.repo /etc/yum.repos.d/openvz.repo

echo "[$DATE:: $0 :: Line $LINENO::]] Importing RPM-GPG-Key for openvz.." 2>&1 | tee -a $LOGFILE
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ

echo ""
echo "Installing the OpenVZ kernel.."
echo "[[$DATE:: $0 :: Line $LINENO::]] Installing the OpenVZ kernel.." 2>&1 | tee -a $LOGFILE
yum -y install vzkernel
if [[ $? -ne 0 ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Error in Installing the OpenVZ kernel...." 2>&1 | tee -a $LOGFILE
exit 1
fi

echo ""
echo "Configuring OpenVZ.."
echo "[[$DATE:: $0 :: Line $LINENO::]] Configuring OpenVZ.." 2>&1 | tee -a $LOGFILE
cat $meta_dir/updated_sysctl.conf >> /etc/sysctl.conf
echo "SELINUX=disabled" > /etc/sysconfig/selinux
echo "[[$DATE:: $0 :: Line $LINENO::]] Disabled SELINUX.." 2>&1 | tee -a $LOGFILE

echo ""
echo "Installing OpenVZ tools.."
echo "[[$DATE:: $0 :: Line $LINENO::]] Installing OpenVZ tools.." 2>&1 | tee -a $LOGFILE
yum -y install vzctl vzquota ploop vzstats
if [[ $? -ne 0 ]];then
echo "[[$DATE:: $0 :: Line $LINENO::]] Error in Installing the OpenVZ tools...." 2>&1 | tee -a $LOGFILE
exit 1
fi

if [[ ! -f $meta_dir/$vz_template_file ]]; then
echo ""
echo "VZ OS template file not found!"
echo "[[$DATE:: $0 :: Line $LINENO::]] VZ OS template file not found!" 2>&1 | tee -a $LOGFILE
echo "Please obtain an VZ OS template image and manually"
echo "copy that into /vz/template/cache folder."
echo "Failing the above step will result in OVPL not working."
echo "Please contact VLEAD for further clarifications."
else
echo ""
echo "Copying the default OS template for containers.."

echo "[[$DATE:: $0 :: Line $LINENO::]] Copying the default OS template for containers....." 2>&1 | tee -a $LOGFILE
cp $meta_dir/$vz_template_file /vz/template/cache
fi

# Not needed!? Not sure.
#echo "Allowing multiple subnets to reside on the same network interface.."
#sed -i 's/#NEIGHBOUR_DEVS=all/NEIGHBOUR_DEVS=all/g' /etc/vz/vz.conf
#sed -i 's/NEIGHBOUR_DEVS=detect/NEIGHBOUR_DEVS=all/g' /etc/vz/vz.conf
#
#echo "Setting container layout to default to ploop (VM in a file).."
#sed -i 's/#VE_LAYOUT=ploop/VE_LAYOUT=ploop/g' /etc/vz/vz.conf
#
#echo "Setting Ubuntu 12.04 64bit to be the default template.."
#sed -i 's/centos-6-x86/ubuntu-12.04-x86_64/g' /etc/vz/vz.conf
echo "[[$DATE:: $0 :: Line $LINENO::]] Allowing multiple subnets to reside on the same network interface.." 2>&1 | tee -a $LOGFILE
sed -i 's/#NEIGHBOUR_DEVS=all/NEIGHBOUR_DEVS=all/g' /etc/vz/vz.conf
sed -i 's/#NEIGHBOUR_DEVS=detect/NEIGHBOUR_DEVS=all/g' /etc/vz/vz.conf

echo "[[$DATE:: $0 :: Line $LINENO::]] Setting container layout to default to ploop (VM in a file).." 2>&1 | tee -a $LOGFILE
sed -i 's/VE_LAYOUT=simfs/VE_LAYOUT=ploop/g' /etc/vz/vz.conf

echo "[[$DATE:: $0 :: Line $LINENO::]] Setting Ubuntu 12.04 64bit to be the default template.." 2>&1 | tee -a $LOGFILE
sed -i 's/centos-6-x86/ubuntu-12.04-x86_64/g' /etc/vz/vz.conf
#
#sysctl -p
#
#echo "Disabling iptables.."
#/etc/init.d/iptables stop && chkconfig iptables off

echo ""
echo "Finished installing OpenVZ"
echo "[[$DATE:: $0 :: Line $LINENO::]] Setting iptables" 2>&1 | tee -a $LOGFILE
iptables -F FORWARD
echo "[[$DATE:: $0 :: Line $LINENO::]] Saving iptables" 2>&1 | tee -a $LOGFILE
service iptables save
echo "[[$DATE:: $0 :: Line $LINENO::]] Finished installing OpenVZ" 2>&1 | tee -a $LOGFILE

exit 0
Loading