标签:start str 文件 部署 pytho nfs sed 自动部署 配置文件
#!/bin/bash
systemctl status nginx var=$? if [ $var -eq 4 ] then yum install epel-release -y if [$? -ne 0 ] then echo "epel库安装失败,无可用nginx源" else yum install nginx -y if [ $? -eq 0 ] then systemctl start nginx if [ $? -eq 0 ] then echo "nginx start ok" else echo "nginx start fail" fi else echo "nginx install fail" fi fi elif [ $var -eq 3 ] then systemctl start nginx if [ $? -eq 0 ] then echo "nginx start ok" else echo "nginx start fail" fi elif [ $var -eq 0 ] then echo "nginx is OK" else echo "nginx can‘t be installed" fi echo "修改配置文件" grep ‘upstream‘ /etc/nginx/nginx.conf if(($? != 0)) then sed -ri ‘/^http/a upstream pythonweb {‘ /etc/nginx/nginx.conf sed -ri ‘/^upst/a server 192.168.211.136 weight=3\;‘ /etc/nginx/nginx.conf sed -ri ‘/^server 192.168.211.136/a server 192.168.211.137\;‘ /etc/nginx/nginx.conf sed -ri ‘/^server 192.168.211.137/a server 192.168.211.138\;‘ /etc/nginx/nginx.conf sed -ri ‘/^server 192.168.211.138/a \}‘ /etc/nginx/nginx.conf sed -ri ‘/^(\ +)(location)(\ )(\/)/a proxy_pass http:\/\/pythonweb\;‘ /etc/nginx/nginx.conf fi echo "配置文件修改成功" echo "重新加载nginx" systemctl reload nginx if(($?==0)) then echo "HTTP load balancer is OK!" else echo "Sorry!!" fi systemctl status nfs-server var1=$? if(($var1==4)) then yum install rpcbind nfs-utils -y if(($?==0)) then systemctl start rpcbind nfs-server if(($?==0)) then echo "Congratulations!! nfs start OK!!" else echo "Sorry is Fail!!!" fi else echo"sorry install is Fail!!!" fi elif(($var1==3)) then echo "nfs-server未执行" systemctl start rpcbind nfs-server if(($?==0)) then echo "Congratulations!! nfs start OK!!!" else echo "sorry!!" fi elif(($var1==0)) then echo "OKOKOK!!!" else echo "I am so sorry" fi echo "修改配置文件" test -d /share if [ $? != 0 ] then mkdir /share chmod -R 777 /share fi echo "/share 192.168.16.0/24(rw,sync,fsid=0)" > /etc/exports echo "配置文件修改成功" echo "重新加载nfs-server" systemctl reload nfs-server if(($?==0)) then echo "NFS service is OK!" else echo "Sorry!!" fi
shell脚本自动部署nignx反向代理及web服务器,共享存储
标签:start str 文件 部署 pytho nfs sed 自动部署 配置文件
原文地址:http://www.cnblogs.com/stin/p/7846189.html