码迷,mamicode.com
首页 > 其他好文 > 详细

postfix一键部署

时间:2018-05-27 14:52:24      阅读:380      评论:0      收藏:0      [点我收藏+]

标签:rest   emctl   conf   一键   main.cf   /etc/   dir   ror   repo   

#!/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$/cmyorigin = 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

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

postfix一键部署

标签:rest   emctl   conf   一键   main.cf   /etc/   dir   ror   repo   

原文地址:https://www.cnblogs.com/dccrussell/p/9095827.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!