This simple script will do basic things such as set a hostname, the ZCS license, the hosts file, and download extract and start the zimbra installer on CentOS.
Hosts file should be in same directory as hosts.conf
License should be in same directory as license.xml
Code:
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;31mThis script must be run as root or it will fail\e[0m" 1>&2
exit 1
fi
echo "Zimbra Auto Server Preperation Script 1.0"
echo " "
echo "---"
echo "This script will prepare this server for Zimbra 6.0.2, and will start the installation. Please read the documentation!"
echo ""
echo -e "\e[1;32mYes will be assumed to answers, and will be defaulted. 'n' or 'no' will result in a No answer, anything else will be a yes.\e[0m"
echo ""
echo -e "\e[1;31mThis script MUST be run as root or it will fail\e[0m"
echo "---"
echo "Start Installation? (Y/n)"
read start
if [ $start == "n" ] || [ $start == "no" ]; then
echo "Exiting..."
exit 1
fi
# Check if the OS matches Red hat or CentOS
OS=`cat /etc/redhat-release | awk {'print $1}'`
if [ "$OS" != "CentOS" ]
then
echo -e "\e[1;31mSystem runs on something other than CentOS. This may not work!\e[0m";
echo -e "\e[1;31mContinue Anyway? (y/n)\e[0m"
read cont
if [ $cont == "n" ] || [ $cont == "no"]; then
echo "Exiting..."
exit 1
fi
fi
echo -e "\e[1;32mOkay. Vee one. Do not go back now.\e[0m"
echo -e "\e[1;33m-----------------------!!!-----------------------\e[0m"
echo "Updating System..."
yum update * -y > yum_update.log
echo "Installing Prerequisites..."
yum install wget gmp compat-libstdc++-33 sysstat libidn sudo -y > yum_prerequisite.log
echo -e "\e[1;31mWhat should the hostname be of this machine?\e[0m"
read host
hostname $host
echo "Hostname set. Continuing..."
echo "Downloading Zimbra..."
cd /tmp
echo -e "\e[1;31mVersion of Zimbra? [Network Edition (Needs license) or Free open source software (Foss)] (N/F)\e[0m"
read version
if [ $version == "F" ]; then
echo "FOSS Version selected"
wget http://h.yimg.com/lo/downloads/6.0.4_GA/zcs-6.0.4_GA_2038.RHEL5.20091214191028.tgz > wget_zcs.log
fi
if [ $version == "N" ]; then
echo "Network version selected"
wget http://h.yimg.com/lo/downloads/6.0.4_GA/zcs-NETWORK-6.0.4_GA_2038.RHEL5.20091214172206.tgz > wget_zcs.log
fi
echo "Extracting & Cleaning up..."
tar xfz zcs* > tar_zcs.log
rm -rf zcs*tgz > rm_zcs.log
echo "Cleaned up. If you select to continue at this point, you will be handed over to the Zimbra installation wizard, and this wizard will exit."
echo "---"
echo -e "\e[1;31mContinue? (Y/n)\e[0m"
read conti
if [ $conti == "n" ] || [ $conti == "no" ]; then
echo "Exiting..."
exit 1
fi
echo "Setting hosts and license."
cp hosts.conf /etc/hosts
cp license.xml /etc/ZCSLicense.xml
cd zcs*
echo "Copied. Rotation. Here comes Zimbra."
sh install.sh --platform-override -l /etc/ZCSLicense.xml