Shell scripts automatically deploy NIGNX reverse proxies and Web servers, shared storage

Source: Internet
Author: User

#!/bin/bash

Systemctl Status Nginxvar=$?if[$var-eq4 ] Then Yum InstallEpel-release-yif[$?-ne0 ] Then Echo "Epel Library installation failed, no nginx source available" Else Yum InstallNginx-yif[$?-eq0 ] Thensystemctl start Nginxif[$?-eq0 ] Then Echo "nginx start OK" Else Echo "nginx Start fail" fi Else Echo "nginx Install fail" fi fielif[$var-eq3 ] Thensystemctl start Nginxif[$?-eq0 ] Then Echo "nginx start OK" Else Echo "nginx Start fail" fielif[$var-eq0 ] Then Echo "Nginx is OK"Else Echo "Nginx can ' t be installed"fiEcho "Modifying a configuration file"grep 'Upstream'/etc/nginx/nginx.confif(($? !=0)) Then sed-ri'/^http/a upstream Pythonweb {'/etc/nginx/nginx.confsed-ri'/^upst/a server 192.168.211.136 weight=3\;'/etc/nginx/nginx.confsed-ri'/^server 192.168.211.136/a server 192.168.211.137\;'/etc/nginx/nginx.confsed-ri'/^server 192.168.211.137/a server 192.168.211.138\;'/etc/nginx/nginx.confsed-ri'/^server 192.168.211.138/a \}'/etc/nginx/nginx.confsed-ri'/^ (\ +) (location) (\) (\)//Proxy_pass http:\/\/pythonweb\;'/etc/nginx/nginx.conffiEcho "configuration file modified successfully"Echo "Reload Nginx"Systemctl Reload Nginxif(($?==0)) Then Echo "HTTP Load balancer is ok!"Else Echo "sorry!!"fiSystemctl Status NFS-servervar1=$?if(($var 1==4)) Then Yum InstallRpcbind Nfs-utils-yif(($?==0)) Thensystemctl start Rpcbind NFS-Serverif(($?==0)) Then Echo "congratulations!! NFS Start ok!!" Else Echo "Sorry is Fail!!!" fi Else Echo"Sorry install is FAIL!!!" fielif(($var 1==3)) Then Echo "Nfs-server not executed"systemctl start Rpcbind NFS-Serverif(($?==0)) Then Echo "congratulations!! NFS Start OK!!!" Else Echo "sorry!!" fielif(($var 1==0)) Then Echo "Okokok!!!"Else Echo "I am SO sorry"fiEcho "Modifying a configuration file"Test-D/Shareif[ $? !=0 ] Then mkdir/Sharechmod-R777/SharefiEcho "/share 192.168.16.0/24 (rw,sync,fsid=0)">/etc/exportsEcho "configuration file modified successfully"Echo "Reload Nfs-server"Systemctl Reload NFS-Serverif(($?==0)) Then Echo "NFS service is ok!"Else Echo "sorry!!"fi

Shell scripts automatically deploy NIGNX reverse proxies and Web servers, shared storage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.