待重新整理
脚本命令
# 安装前校验
release=`uname -r | grep -E "el5|.el6.|.el7.|default"`
#release=`cat /etc/*release 2>/dev/null | uniq | sed 's#(.*##g' | grep -E "release 6.|release 7."`
if [ "$release"x = ""x ]; then
echo [ERROR] "Installer only support Redhat/CentOS 5.X/6.x/7.x serial platforms. Aborting..."
exit 1
fi
# 获取版本
release_version=`uname -r | grep -Eo "el5|el6|el7|default"`
# 关闭防火墙
iptables_set()
{
case $release_version in
"el5")
service iptables stop
chkconfig iptables off
echo "el5 config firewalld success"
;;
"el6")
service iptables stop
chkconfig iptables off
echo "el6 config firewalld success"
;;
"el7")
systemctl stop firewalld
systemctl disable firewalld
echo "el7 config firewalld success"
;;
"default")
SLES_VERSION=$(sed -n '/^VERSION/ p ' /etc/*release | awk -F= '{print $2}')
echo "SLES version is $SLES_VERSION"
# sles11
if [[ $SLES_VERSION =~ 11 ]]
then
# 取消开机启动防火墙
chkconfig SuSEfirewall2_init off
chkconfig SuSEfirewall2_setup off
# 关闭操作为:
service SuSEfirewall2_setup stop
service SuSEfirewall2_init stop
echo "suse11 system config firewalld success"
fi
# sles12
if [[ $SLES_VERSION =~ 12 ]]
then
# 取消开机启动防火墙
systemctl disable SuSEfirewall2.service
# 关闭操作为:
systemctl stop SuSEfirewall2.service
echo "suse12 system config firewalld success"
fi
;;
*)
echo [ERROR] "iptables_set unsupport release version $release_version."
exit 1
;;
esac
echo "iptables_set success"
echo -e "============================================================================================================================\n"
}