linux脚本修改nginx配置,Shell脚本修改Nginx upstream配置文件

#!/bin/bash###################################################### Name: change_nginx_upstream_conf.sh# Version: V1.# Author: 运维菜鸟# Description: 更改nginx upstream...
摘要由CSDN通过智能技术生成

#!/bin/bash

#####################################################

# Name: change_nginx_upstream_conf.sh

# Version: V1.

# Author: 运维菜鸟

# Description: 更改nginx upstream配置文件

# Create Date: --

# Email:

#####################################################

#function name

function_name=$

#pool name

pool_name=$

#pool corresponding ip list

pool_ip_lists=$

#pool corresponding tomcat port

pool_tomcat_port=$

#upstream file location

ngx_upstream_file=$

#检测pool在nginx upstream配置文件中是否存在

function check_pool_in_ngx_upstream() {

grep -E "${pool_name}[^-]" ${ngx_upstream_file} >> /dev/null

if [ $? -eq ];then

echo -e "\033[36m the ${pool_name} in ${ngx_upstream_file}. \033[0m"

else

echo -e "\033[31m the ${pool_name} not in ${ngx_upstream_file}. \033[0m"

exit

fi

}

#显示pool在nginx upstream配置文件中对应内容

function show_pool_in_ngx_upstream() {

pool_name_first_line=`egrep -n "${pool_name}[^-]" ${ngx_upstream_file} | cut -d ":" -f1`

line_list=`grep -n "^}" ${ngx_upstream_file} | cut -d ":" -f1`

pool_name_end_line=${pool_name_first_line}

for line in ${line_list[*]};do

if [ $line -gt ${pool_name_first_l

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值