shell:修改变更值[通俗易懂]

shell:修改变更值[通俗易懂]#catconfd-general-config.confETCD_SERVER_HOSTIP=192.168.3.103ETCD_SERVER_PORT=2379innernetworksegement=192.168.3pgconn=10.47.245.110:13306,10.47.245.110:23306kafkaconn=10.47.223.223:9090,10…

大家好,又见面了,我是你们的朋友全栈君。

目录

一、基本文件展示

1.confd-general-config.conf文件展示

2.相关数据展示

二、相关修改变更值代码展示


一、基本文件展示

1.confd-general-config.conf文件展示

# cat confd-general-config.conf
ETCD_SERVER_HOSTIP=192.168.3.103
ETCD_SERVER_PORT=2379
innernetworksegement=192.168.3
pgconn=10.47.245.110:13306,10.47.245.110:23306
kafkaconn=10.47.223.223:9090,10.47.223.223:9091,10.47.223.223:9092
zkconn=10.47.223.223:2181,10.47.223.223:2182,10.47.223.223:2183
redisconn=10.47.223.223:8000,10.47.223.223:8001,10.47.223.223:8002
k8sapiserverurl=10.47.225.97:8080
k8snfshost=10.47.225.92
lianchuang_url=61.160.190.227:8298

2.相关数据展示

# Kafka stream
spring.cloud.stream.kafka.binder.zk-nodes=10.47.223.223:2181,10.47.223.223:2182,10.47.223.223:2183
spring.cloud.stream.kafka.binder.brokers=10.47.223.223:9090,10.47.223.223:9091,10.47.223.223:9092
spring.cloud.stream.kafka.binder.configuration.security.protocol=SASL_PLAINTEXT
spring.cloud.stream.kafka.binder.configuration.sasl.mechanism=PLAIN

二、相关修改变更值代码展示

function getConfigValue
{
    [ $# -ne 2 ] && echo  "function getConfigValue arguments error"
    local fileName=$1
    local key=$2
    echo `cat ${fileName}| grep "${key}"| grep "=" | awk -F= '{print $2}' | tr -d " "`	
}

function writeConfigValue()
{
    K8SCONFIGDIR=/home/zyf/confdconfig
    K8SCONFIGFILE=${K8SCONFIGDIR}/confd-general-config.conf
    
    DBMASTURL=`getConfigValue ${K8SCONFIGFILE} pgconn | awk -F ',' '{print $1}'`
    DBSLAVEURL=`getConfigValue ${K8SCONFIGFILE} pgconn | awk -F ',' '{print $2}'`
    
    REDISURL=`getConfigValue ${K8SCONFIGFILE} redisconn`
    KAFKAURL=`getConfigValue ${K8SCONFIGFILE} kafkaconn`
    ZOOKEEPURL=`getConfigValue ${K8SCONFIGFILE} zkconn`
    IPSEGEMENT=`getConfigValue ${K8SCONFIGFILE} innernetworksegement`
	LIANCHUANGURL=`getConfigValue ${K8SCONFIGFILE} lianchuang_url`
    
    if [ -f ${CONFIGDIR}/application.properties ]
    then
      if [ -n ${IPSEGEMENT} ]
      then
        sed -i -e "/^genid/s/\/[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]./\/${IPSEGEMENT}./g" ${CONFIGDIR}/application.properties
      fi
          
      if [ -n ${ZOOKEEPURL} ]
      then
        sed -i -e "/^spring.cloud.stream.kafka.binder.zk-nodes/s/spring.cloud.stream.kafka.binder.zk-nodes=.*/spring.cloud.stream.kafka.binder.zk-nodes=${ZOOKEEPURL}/" ${CONFIGDIR}/application.properties
      fi
      
      if [ -n ${KAFKAURL} ]
      then
        sed -i -e "/^kafka.binder.brokers/s/kafka.binder.brokers=.*/kafka.binder.brokers=${KAFKAURL}/" ${CONFIGDIR}/application.properties
        sed -i -e "/^spring.cloud.stream.kafka.binder.brokers/s/spring.cloud.stream.kafka.binder.brokers=.*/spring.cloud.stream.kafka.binder.brokers=${KAFKAURL}/" ${CONFIGDIR}/application.properties
      fi
	  
	  if [ -n ${LIANCHUANGURL} ]
      then
		BRFOREVALUE=`getConfigValue ${CONFIGDIR}/application.properties lianchuang.url`
		BRFORE=${BRFOREVALUE#*//}
		sed -i "s/${BRFORE}/${LIANCHUANGURL}/g" ${CONFIGDIR}/application.properties
      fi
    fi
    
    if [ -f ${CONFIGDIR}/bootstrap.properties ]
    then
      if [ -n ${IPSEGEMENT} ]
      then
        sed -i -e "/^eureka.client.serviceUrl.defaultZone/s/\/[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]./\/${IPSEGEMENT}./g" ${CONFIGDIR}/bootstrap.properties
      fi
    fi
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/157204.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号