#!/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