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