#!/bin/bash
# This is a email server configure script
POSTFIX=/etc/postfix/mian.cf 定义了邮件配置文件位置
DOVECOT=/etc/dovecot/dovecot.conf 定义了邮件pop3配置文件位置
POSTFIXMBER=26 检查语法错误时返回来的值
PROT=$(lsof -i :25 | awk ‘NR==2{print $1}‘) 定义了占用25端口的进程
netstat -nl| grep :25 &> /dev/null 检查25端口是否开启
if [$?-eq 0 ];then
pkill -9 $PROT 25端口被占用就把占用进程杀死
else
echo "25 prot already release"
fi
forWRAP in {postfix,dovecot} 安装邮件服务器的包
do
rpm -q $WRAP &> /dev/null 检查这两个包是否存在
if [ $? != 0 ];then
yum -y install $WRAP
else
echo "$WRAPalready install"
fi
done
echo "myhostname=mail.baidu.com" >>$POSTFIX 邮件服务器的主机名
echo "mydomain=baidu.com" >> $POSTFIX 邮件服务器所在的
echo" myorigin=$mydomain" >> $POSTFIX 发件人的后缀
echo" inet_interfaces = all " >> $POSTFIX 监听端口
echo " mydistation=$mydmain" >>$POSTFIX 发件人DNS后缀
echo "mynetworks = 0.0.0.0/24" >>$POSTFIX 设置允许哪些网段需要转发到外部区域的邮件交给postfix
echo " mail_spool_directory =/var/spool/mail" >> $POSTFIX 设置收到邮件存放的目录
postfixcheck 检查语法
if [$? -eq 0 ];then
service postfix restart 开启邮件服务
chkconfig postfix on
else
echo "postfix configure fileappear failed"
exit $POSTMBER 检查配置文件失败后返回i邮件存放的努力的值
fi
echo" protocols = pop3" >> $DOVECOT
echo" listen = *" >> $DOVECOT
service dovecot restart
chkconfig dovecot on