编写脚本自动部署反向代理、web、nfs
生活随笔
收集整理的這篇文章主要介紹了
编写脚本自动部署反向代理、web、nfs
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
服務器端
#!/bin/bashfunction nginx_install(){if [[ -f /usr/sbin/nginx ]]; thenecho 'Nginx has been installed.'exitelseflag1=3while [[ $flag1 -gt 0 ]]; doyum install epel-release -y && yum install nginx -yif [[ $? -ne 0 ]]; then((flag1--))elseecho 'Nginx has been installed.'exitfidoneecho 'Nginx install failed.'fisystemctl start nginx }function nginx_balancer(){msg1='upstream myapp1 { server 192.168.60.129; server 192.168.60.130; server 192.168.60.131; }'msg2='proxy_pass http://myapp1;'sed -ri "/^http/a $msg1" /etc/nginx/nginx.confsed -ri "/^ *location \/ \{$/a $msg2" /etc/nginx/nginx.confsystemctl reload nginx }function nfs_install(){rpm -qa |grep rpcbind >> /dev/nullif [[ $? -eq 0 ]]; thenecho 'RPCbind has been installed'elseflag2=3while [[ $flag2 -gt 0 ]]; doyum install rpcbind -yif [[ $? -ne 0 ]]; then((flag2--))elseecho 'RPCbind has been installed.'exitfidoneecho 'RPCbind install failed.'firpm -qa |grep nfs-utils >> /dev/nullif [[ $? -eq 0 ]]; thenecho 'nfs-utils has been installed'elseflag3=3while [[ $flag3 -gt 0 ]]; doyum install nfs-utils -yif [[ $? -ne 0 ]]; then((flag3--))elseecho 'nfs-utils has been installed.'exitfidoneecho 'nfs-utils install failed.'fi }function nfs_server(){mkdir /sharetouch /share/index.htmlecho '---NFS---Hello---' > /share/index.htmlchmod -R o+w /shareecho '/share 192.168.60.0/24(rw,sync,fsid=0)' >> /etc/exportssystemctl start rpcbind.service && systemctl start nfs-server.serviceif [[ $? -eq 0 ]]; thenecho 'NFS server running.'fisystemctl enable rpcbind.service && systemctl enable nfs-server.service }nginx_install nginx_balancer nfs_install nfs_server
客戶端
#!/bin/bashfunction nginx_install(){if [[ -f /usr/sbin/nginx ]]; thenecho 'Nginx has been installed.'exitelseflag1=3while [[ $flag1 -gt 0 ]]; doyum install epel-release -y && yum install nginx -yif [[ $? -ne 0 ]]; then((flag1--))elseecho 'Nginx has been installed.'exitfidoneecho 'Nginx install failed.'fisystemctl start nginx }function nfs_install(){rpm -qa |grep rpcbind >> /dev/nullif [[ $? -eq 0 ]]; thenecho 'RPCbind has been installed'elseflag2=3while [[ $flag2 -gt 0 ]]; doyum install rpcbind -yif [[ $? -ne 0 ]]; then((flag2--))elseecho 'RPCbind has been installed.'exitfidoneecho 'RPCbind install failed.'firpm -qa |grep nfs-utils >> /dev/nullif [[ $? -eq 0 ]]; thenecho 'nfs-utils has been installed'elseflag3=3while [[ $flag3 -gt 0 ]]; doyum install nfs-utils -yif [[ $? -ne 0 ]]; then((flag3--))elseecho 'nfs-utils has been installed.'exitfidoneecho 'nfs-utils install failed.'fi }function nfs_client(){systemctl start rpcbind.service && systemctl start nfs-server.servicesystemctl enable rpcbind.service && systemctl enable nfs-server.servicemount -t nfs 192.168.60.128:/share /usr/share/nginx/html/df |grep 192.168.60.128 >> /dev/nullif [[ $? -eq 0 ]]; thenecho 'NFS client running.'fi }nginx_install nfs_install nfs_client
轉載于:https://www.cnblogs.com/freelandun/p/6754802.html
總結
以上是生活随笔為你收集整理的编写脚本自动部署反向代理、web、nfs的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 服务器上安装搭建node环境
- 下一篇: WARNING: Max 1024 op