例子: 安装apache脚本
#!/bin/bash
#install apache
#v1.0 by zhengjx
ping -c2 www.baidu.com &>/dev/null
if [ $? -eq 0 ];then
read -p "确定安装Apache[y]: " action_install_apache
if [ "$action_install_apache" = "y" ];then
yum install -y httpd
systemctl start httpd
systemctl enable httpd
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
sed -ri '/^SELINUX=/cSELINUX=disabled/' /etc/selinux/config
setenforce 0
curl http://127.0.0.1 &>/dev/null
if [ $? -eq 0 ];then
echo "Apache 安装成功!"
fi
else
echo "输入错误,确认输入y"
exit
fi
elif
ping -c2 127.0.0.1;then
echo "check network cards!"
elif
grep "nameserver" /etc/reslov.conf; then
echo "please check DNS"
fi