postfix一键部署

#!/bin/bash
#author:dcc
#date:2018/05/26
#version:v1
#description:install postfix
if [ ! -d "$HOME/mylog" ];then
	mkdir $HOME/mylog
fi
config_file="/etc/postfix/main.cf"
log_path="$HOME/mylog/install.log"

#check postfix whether install
rpm -q postfix >/dev/null
if [ ! $? -eq 0 ];then
#test yum whether can use?

	test01=`yum repolist | grep 'repolist: '|sed -n 's/repolist: //p'`
	if [ "$test01" == "0" ];then
		echo "error_code:1;the yum.repo can't be used" >> $log_path
		echo "Error:yum can not be used"
		exit 1
	fi
	yum -y install postfix > /dev/null && echo "`date`:install postfix success" >> $log_path || echo "`date`:install postfix failed" && exit 1
fi

#config postfix
sed -in '/^mydestination =/s/=.*/=/' $config_file
sed -rin '/^#myori.*hostname$/c\
myorigin = dcc.cn' $config_file

#restart and enable postfix
systemctl restart postfix && echo "`date`:restart postfix success" >> $log_path || echo "`date`:restart postfix failed,you can use journalctl -xe to check" >> $log_path && exit 2

systemctl enable postfix && echo "`date`:enable postfix success" >> $log_path || echo "`date`:enable postfix failed" >> $log_path && exit 3

  不接受任何邮件,只用于发报警邮件

转载于:https://www.cnblogs.com/dccrussell/p/9095827.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值