Script to prepare necessary package for install zimbra 8.6

Script to prepare necessary package for install zimbra 8.6
#!/bin/bash
#Author: Phan Van Huu
#Blog: huuphan.com
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' #No color
############## Prepair for install Zimbra(OS: Centos 6).#################
ifconfig | grep "inet addr" && route | grep default
#echo -e "$BLUE ############## Prepair for Zimbra(OS: Centos 6).################# $NC"
#echo -e ""
echo -e "$BLUE 1.Input IP address for server. $NC"
read IP1
#echo -e ""
#echo -e "$BLUE 2.Input netmask for server. $NC"
#read NETMASK1
#echo -e ""
#echo -e "$BLUE 3.Input gateway for server. $NC"
#read GATEWAY1
#echo -e "$BLUE Input interface (Ex: eth0) : $NC"
#read INTERFACES1
#echo ""
#echo -e "$BLUE 4.Input DNS2 (Ex: 8.8.4.4). $NC"
#read DNS2
#echo -e ""

echo -e ""
echo -e "$BLUE 2.Input DNS1 (Ex: 8.8.8.8). $NC"
read DNS1
echo -e ""
echo -e "$BLUE 3.Input HOSTNAME1(Ex: ldap). $NC"
read HOSTNAME1
echo -e ""
echo -e "$BLUE 4.Input domain(Ex: huuphan.com). $NC"
read DOMAIN1
echo -e ""
echo -e "$BLUE NTP Server. Example 0.asia.pool.ntp.org : $NC"
read NTPSERVER
echo ""
# config hosts,resolv.conf,network,ifcfg-eth* file.
echo -e "$BLUE ############ config /etc/hosts file ############ $NC"
if [ -f /etc/hosts.bak ]; then
        echo -e "$RED hosts.bak file Existing $NC"
else
        cp /etc/hosts /etc/hosts.bak
        cat <<EOF >/etc/hosts
127.0.0.1       localhost.localdomain localhost
$IP1 $HOSTNAME1.$DOMAIN1 $HOSTNAME1
EOF
fi
echo -e "$BLUE ############ config /etc/resolv.conf file ############ $NC"
if [ -f /etc/resolv.conf.bak ]; then
        echo -e "$RED resolv.bak file Existing $NC"
else
        cp /etc/resolv.conf /etc/resolv.conf.bak
        cat <<EOF >/etc/resolv.conf
search $DOMAIN1
nameserver $DNS1
#nameserver 8.8.8.8
#nameserver 8.8.4.4
EOF
fi
echo -e "$BLUE ############ config /etc/sysconfig/network file ############ $NC"
PATH3=/etc/sysconfig
if [ -f $PATH3/network.bak ]; then
        echo -e "$RED $PATH3/network.bak file Exsting $NC"
else
        cp $PATH3/network /etc/network.bak
        cat <<EOF >$PATH3/network
NETWORKING=yes
HOSTNAME=$HOSTNAME1
EOF
fi
echo -e "$BLUE ############ config /etc/sysconfig/iptables file ############ $NC"
if [ -f /etc/sysconfig/iptables.bak ]; then
        echo -e "$RED /etc/sysconfig/iptables.bak file Exsting $NC"
else
        cp /etc/sysconfig/iptables /etc/sysconfig/iptables.bak
        cat <<EOF >/etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 389 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 636 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 514 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
EOF
fi
# Restart service Network
service network restart
chkconfig network on
# Disable service sendmail, postfix or SELINUX
sed -i.bak "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
setenforce 0
service iptables start
chkconfig iptables on
service sendmail stop
service postfix stop
chkconfig sendmail off
chkconfig postfix off
# Update repo and install package needed by Zimbra
echo ""
echo -e "[INFO] : Update repos and install packages required by Zimbra"
echo ""
yum -y update
yum -y install nc sudo libidn gmp libaio libstdc++ unzip perl-core perl sysstat sqlite vim rsync ntp
# Connecting to NTP Server
echo ""
echo -e "[INFO] : Configuring NTP Server"
echo ""
ntpdate $NTPSERVER
###Review file configure ###
echo "$BLUE File iptalbles conf $NC"
cat /etc/sysconfig/iptables
echo "$BLUE File hosts conf $NC"
cat /etc/hosts
echo "$BLUE File resolv conf $NC"
cat /etc/resolv.conf
echo "$BLUE File network conf $NC"
cat /etc/sysconfig/network
echo ""
echo "Configuring Firewall, network, /etc/hosts and DNS server has been finished. please install Zimbra now"
Script to prepare necessary package for install zimbra 8.6


Comments

Popular posts from this blog

zimbra some services are not running [Solve problem]

How to install php7 on centos 6

Bash script list all IP addresses connected to Server