#!/bin/bash
domain='aaaaa.com'
check_env() {
local timeout=1
local target=www.baidu.com
local ret_code=`curl -I -s --connect-timeout ${timeout} ${target} -w %{http_code} | tail -n1`
if [ $ret_code = 200 ]; then
return 1
else
return 0
fi
#return 0
}
installmail() {
check_env
if [ $? -eq 0 ];then
echo 'The servers network is faild!'
exit -1
else
yum -y install epel* wget yum-utils
hostnamectl set-hostname mail.${domain}
echo '127.0.0.1 mail.'${domain}'' >>/etc/hosts
yum -y install postfix.x86_64 dovecot.x86_64 cyrus-sasl
local Mail_data=/data/Maildir
if [ ! -d ${Mail_data} ];then
mkdir -p ${Mail_data}
yum -y install postfix.x86_64 dovecot.x86_64 cyrus-sasl
systemctl restart saslauthd.service
systemctl restart postfix.service
systemctl restart dovecot.service
fi
fi
}
main() {
installmail
}
main "$@"



