#!/usr/bin/env  bash

#该脚本的作用是：更改从web17推送过来的nginx 配置文件IP，并reload nginx

#获取云服务器私网IP
IP=$(ip a |awk '/scope global eth0/{print $2}'|awk -F '/' '{print $1}')

#获取NGINX 主机定义的IP
NGINX=$(awk -F ':' '/listen/{print $1}' /etc/nginx/conf.d/zuan.conf |awk '{print $2}')

#替换IP地址
#sed -i "s/$NGINX/$IP/" /etc/nginx/conf.d/zuan.conf
sed -i "s/$NGINX/$IP/g" `grep "$NGINX" -rl /etc/nginx/conf.d/`


#重新加载nginx
service nginx restart
