172 lines
5.7 KiB
Plaintext
172 lines
5.7 KiB
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
# vcd15-install Install vCloud Director 1.5 for AutoLab v1.1
|
||
|
#
|
||
|
# vCloud Director Installation Script
|
||
|
# William Lam
|
||
|
# www.virtuallyghetto.com
|
||
|
#
|
||
|
# Damian Karlson
|
||
|
# www.damiankarlson.com
|
||
|
# www.labguides.com
|
||
|
# www.professionalvmware.com/brownbags
|
||
|
#
|
||
|
# chkconfig: 3 99 99
|
||
|
# description: Automated vCloud Director installation on AutoLab
|
||
|
|
||
|
####################
|
||
|
# FILE DEFINITIONS #
|
||
|
####################
|
||
|
# vCloud Director 1.5.x
|
||
|
VMWARE_VCD_BIN=`find /root/vmware-vcloud-director-1.5*.bin`
|
||
|
VCLOUD_VERSION=1.5.x
|
||
|
|
||
|
#####################
|
||
|
# SECOND IP ADDRESS #
|
||
|
#####################
|
||
|
IP_ADDRESS_2=192.168.199.39
|
||
|
IP_ADDRESS_2_NETMASK=255.255.255.0
|
||
|
|
||
|
#################
|
||
|
# KEYSTORE INFO #
|
||
|
#################
|
||
|
KEYSTORE_PASSWORD=vcloud
|
||
|
KEYSTORE_ORG_UNIT_NAME=AutoLab
|
||
|
KEYSTORE_ORG=AutoLab
|
||
|
KEYSTORE_CITY=AutoLab
|
||
|
KEYSTORE_STATE=AutoLab
|
||
|
KEYSTORE_COUNTRY=US
|
||
|
|
||
|
################################
|
||
|
# SQL 2008 R2 SP1 EXPRESS CONF #
|
||
|
################################
|
||
|
SQL_VCLOUD_USERNAME=vcloud15
|
||
|
SQL_VCLOUD_PASSWORD=VMware1!
|
||
|
SQL_VCLOUD_DATABASE=vCloud15
|
||
|
|
||
|
verify() {
|
||
|
if [ ${UID} -ne 0 ]; then
|
||
|
echo "Installer must run as root!" >> /root/vcd15-install.log
|
||
|
exit 1
|
||
|
fi
|
||
|
if [ ! -f ${VMWARE_VCD_BIN} ]; then
|
||
|
echo "Unable to find ${VMWARE_VCD_BIN}!" >> /root/vcd15-install.log
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
echo "Proceeding with the installation of VMware vCD ${VCLOUD_VERSION}" >> /root/vcd15-install.log
|
||
|
}
|
||
|
|
||
|
generateCertificates() {
|
||
|
HTTP_IP=$(grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0 | awk -F "=" '{print $2}' | sed 's/"//g')
|
||
|
CONSOLEPROXY_IP=$(grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth1 | awk -F "=" '{print $2}' | sed 's/"//g')
|
||
|
HTTP_HOSTNAME=$(host ${HTTP_IP} | awk '{print $5}' | sed 's/.$//g')
|
||
|
CONSOLEPROXY_HOSTNAME=$(host ${CONSOLEPROXY_IP} | awk '{print $5}' | sed 's/.$//g')
|
||
|
|
||
|
if [ ! -f /opt/keystore/certificates.ks ]; then
|
||
|
echo "Creating keystore certificate for http using ${HTTP_HOSTNAME}" >> /root/vcd15-install.log
|
||
|
keytool -keystore certificates.ks -storetype JCEKS -storepass ${KEYSTORE_PASSWORD} -keypass ${KEYSTORE_PASSWORD} -genkey -keyalg RSA -alias http -dname "CN=${HTTP_HOSTNAME}, OU=${KEYSTORE_ORG_UNIT_NAME}, O=${KEYSTORE_ORG}, L=${KEYSTORE_CITY},S=${KEYSTORE_STATE}, C=${KEYSTORE_COUNTRY}" 2>&1 >> /root/vcd15-install.log
|
||
|
keytool -keystore certificates.ks -storetype JCEKS -storepass ${KEYSTORE_PASSWORD} -keypass ${KEYSTORE_PASSWORD} -certreq -alias http -file http.csr 2>&1 >> /root/vcd15-install.log
|
||
|
|
||
|
echo "Creating keystore certificate for consoleproxy using ${CONSOLEPROXY_HOSTNAME}" >> /root/vcd15-install.log
|
||
|
keytool -keystore certificates.ks -storetype JCEKS -storepass ${KEYSTORE_PASSWORD} -keypass ${KEYSTORE_PASSWORD} -genkey -keyalg RSA -alias consoleproxy -dname "CN=${HTTP_HOSTNAME}, OU=${KEYSTORE_ORG_UNIT_NAME}, O=${KEYSTORE_ORG}, L=${KEYSTORE_CITY},S=${KEYSTORE_STATE}, C=${KEYSTORE_COUNTRY}" 2>&1 >> /root/vcd15-install.log
|
||
|
keytool -keystore certificates.ks -storetype JCEKS -storepass ${KEYSTORE_PASSWORD} -keypass ${KEYSTORE_PASSWORD} -certreq -alias consoleproxy -file consoleproxy.csr 2>&1 >> /root/vcd15-install.log
|
||
|
|
||
|
echo "Moving certificates.ks to /opt/keystore" >> /root/vcd15-install.log
|
||
|
if [ -f certificates.ks ]; then
|
||
|
mkdir -p /opt/keystore
|
||
|
mv certificates.ks /opt/keystore
|
||
|
else
|
||
|
echo "Error! Unable to locate certificates.ks in current working directory, certificates may not have been generated correctly!" >> /root/vcd15-install.log
|
||
|
fi
|
||
|
else
|
||
|
echo "Looks like /opt/keystore/certificates.ks exists already! Will not generate vCD keystores!" >> /root/vcd15-install.log
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
installvCD() {
|
||
|
VCD_INSTALL_RESPONSE_FILE=/tmp/vcd15-install-$$.response
|
||
|
|
||
|
rpm -qa | grep -i "vmware-vcloud-director" > /dev/null 2>&1
|
||
|
if [ $? -eq 1 ]; then
|
||
|
echo "Installing VMware vCloud Director ${VCLOUD_VERSION}" >> /root/vcd15-install.log
|
||
|
cat > ${VCD_INSTALL_RESPONSE_FILE} << __VCD_INSTALL__
|
||
|
y
|
||
|
n
|
||
|
__VCD_INSTALL__
|
||
|
|
||
|
chmod u+x ${VMWARE_VCD_BIN}
|
||
|
${VMWARE_VCD_BIN} < ${VCD_INSTALL_RESPONSE_FILE} 2>&1 >> /root/vcd15-install.log
|
||
|
|
||
|
rm -f ${VCD_INSTALL_RESPONSE_FILE}
|
||
|
else
|
||
|
echo "VMware vCloud Director ${VCLOUD_VERSION} is already installed!" >> /root/vcd15-install.log
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
configurevCD() {
|
||
|
VCD_CONFIG_RESPONSE_FILE=/tmp/vcd-configure-$$.response
|
||
|
VCD_PATH=/opt/vmware/vcloud-director
|
||
|
|
||
|
cat > ${VCD_CONFIG_RESPONSE_FILE} << __VCD_CONFIGURE__
|
||
|
1
|
||
|
1
|
||
|
/opt/keystore/certificates.ks
|
||
|
${KEYSTORE_PASSWORD}
|
||
|
|
||
|
2
|
||
|
192.168.199.4
|
||
|
1433
|
||
|
${SQL_VCLOUD_DATABASE}
|
||
|
|
||
|
${SQL_VCLOUD_USERNAME}
|
||
|
${SQL_VCLOUD_PASSWORD}
|
||
|
y
|
||
|
__VCD_CONFIGURE__
|
||
|
|
||
|
service vmware-vcd status > /dev/null 2>&1
|
||
|
if [ $? -eq 0 ]; then
|
||
|
service vmware-vcd stop
|
||
|
fi
|
||
|
echo "Configuring vCloud Director" >> /root/vcd15-install.log
|
||
|
${VCD_PATH}/bin/configure < ${VCD_CONFIG_RESPONSE_FILE}
|
||
|
|
||
|
rm -f ${VCD_CONFIG_RESPONSE_FILE}
|
||
|
|
||
|
echo "Completed installation of vCloud Director!" >> /root/vcd15-install.log
|
||
|
echo "Starting vCloud Director" >> /root/vcd15-install.log
|
||
|
${VCD_PATH}/bin/vmware-vcd start
|
||
|
echo "Waiting for vCloud Director to finish initialization" >> /root/vcd15-install.log
|
||
|
VCD_START_SUCCESS=0
|
||
|
VCD_START_COUNT=0
|
||
|
VCD_START_MAX_COUNT=24
|
||
|
while [ 1 ];
|
||
|
do
|
||
|
grep -i "Application Initialization: Complete" ${VCD_PATH}/logs/vcloud-container-info.log > /dev/null 2>&1
|
||
|
if [ $? -eq 0 ]; then
|
||
|
echo "vCloud Director is up and running! You can now go to https://${HTTP_HOSTNAME}" >> /root/vcd15-install.log
|
||
|
break
|
||
|
else
|
||
|
if [ ${VCD_START_COUNT} = ${VCD_START_MAX_COUNT} ]; then
|
||
|
echo "Unable to start vCloud Director, something went wrong! Please take a look at ${VCD_PATH}/logs/vcloud-container-info.log for more info" >> /root/vcd15-install.log
|
||
|
break
|
||
|
fi
|
||
|
VCD_START_COUNT=$((VCD_START_COUNT+1))
|
||
|
sleep 5
|
||
|
fi
|
||
|
done
|
||
|
}
|
||
|
|
||
|
case "$1" in
|
||
|
start)
|
||
|
verify
|
||
|
generateCertificates
|
||
|
installvCD
|
||
|
configurevCD
|
||
|
chkconfig vcd15-install off
|
||
|
;;
|
||
|
stop|status|restart|reload|force-reload)
|
||
|
# do nothing
|
||
|
;;
|
||
|
esac
|
||
|
exit
|