1. 程式人生 > >shell腳本自動部署nignx反向代理及web服務器,共享存儲

shell腳本自動部署nignx反向代理及web服務器,共享存儲

echo pytho 修改 ^h pro lan nfs bash style

#!/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服務器,共享存儲