shell脚本自动部署nignx反向代理及web服务器,共享存储

Posted Claire_xu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell脚本自动部署nignx反向代理及web服务器,共享存储相关的知识,希望对你有一定的参考价值。

#!/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服务器,共享存储的主要内容,如果未能解决你的问题,请参考以下文章

shell基本语法2

linux开发脚本自动部署及监控

开发脚本自动部署及监控

linux开发脚本自动部署及监控

Day11.开发脚本自动部署及监控

开发脚本自动部署及监控作业