#!/bin/bash CENTER_CODE=$1 #容器编号 chmod 777 /3rd/env.env . /3rd/env.env #MYSQL_HOST="10.100.0.5" MYSQL_PORT="3306" MACHINE_HOST="10.100.0.5" #宿主机地址 MACHINE_HOST_DOMAIN="101.42.52.13" #宿主机外网地址 LOCAL_HOST="127.0.0.1" #本地地址 DEV_BASE_PATH=/data/mmogrun/publish TOOLS_PATH=${DEV_BASE_PATH}/tools CFG_PATH=${DEV_BASE_PATH}/cfg MODEL='standalone' #运行模式 STANDALONE_PATH=${CFG_PATH}/${MODEL} #******************************sed mysql config start **************************** cd ${STANDALONE_PATH}/PlayerOp/ sed -i "s#anhei_oss#anhei_oss_${CENTER_CODE}#g" PlayerOpServerConfig.json sed -i "s#${LOCAL_HOST}#${MYSQL_HOST}#g" PlayerOpServerConfig.json cd ${STANDALONE_PATH}/GameDB sed -i "s#anhei_game#anhei_game_${CENTER_CODE}#g" GameDBServerConfig.json sed -i "s#${LOCAL_HOST}#${MYSQL_HOST}#g" GameDBServerConfig.json cd ${STANDALONE_PATH}/Mail sed -i "s#anhei_game#anhei_game_${CENTER_CODE}#g" MailServerConfig.json sed -i "s#${LOCAL_HOST}#${MYSQL_HOST}#g" MailServerConfig.json cd ${STANDALONE_PATH}/DB sed -i "s#anhei_account#anhei_account_${CENTER_CODE}#g" DBServerConfig_1.json sed -i "s#${LOCAL_HOST}#${MYSQL_HOST}#g" DBServerConfig_1.json sed -i "s#anhei_account#anhei_account_${CENTER_CODE}#g" DBServerConfig_2.json sed -i "s#${LOCAL_HOST}#${MYSQL_HOST}#g" DBServerConfig_2.json cd ${STANDALONE_PATH}/Name sed -i "s#${LOCAL_HOST}#${MYSQL_HOST}#g" NameServerConfig.json cd ${STANDALONE_PATH}/Operation sed -i "s#anhei_oss#anhei_oss_${CENTER_CODE}#g" OperationServerConfig.json sed -i "s#${LOCAL_HOST}#${MYSQL_HOST}#g" OperationServerConfig.json cd ${STANDALONE_PATH}/Game/ sed -i "s#\"currency\": 2#\"currency\":\"\$currency$\"#g" GameServerConfig.json #"currency":"$currency$" #******************************sed mysql config end **************************** #****************************** bussiness info replace docker************ cd ${STANDALONE_PATH} LOCAL_HOST=$(hostname -I | sed 's/ //g') #source /3rd/env.env #用这个作为模板进行替换 sed -i "s#docker#docker_${CENTER_CODE}#g" cluster.json sed -i "s#${MACHINE_HOST_DOMAIN}:9721#${MACHINE_HOST_DOMAIN}:${REALM_GATE_PORT_1}#g" cluster.json #realmgate 1 sed -i "s#${MACHINE_HOST_DOMAIN}:9722#${MACHINE_HOST_DOMAIN}:${REALM_GATE_PORT_2}#g" cluster.json #realmgete 2 sed -i "s#${MACHINE_HOST_DOMAIN}:9820#${MACHINE_HOST_DOMAIN}:${CHAT_GATE_PORT}#g" cluster.json sed -i "s#172.17.0.1#${LOCAL_HOST}#g" cluster.json #替换一些业务上的需求 CLUSTER_PARAMS='currency=4,randNameRow=0' #默认为国服参数 case ${CENTER_CODE} in 1) CLUSTER_PARAMS='currency=2,randNameRow=0' #默认为日本参数 ;; 2|3) CLUSTER_PARAMS='currency=1,randNameRow=1' ;; *) CLUSTER_PARAMS='currency=2,randNameRow=0' #默认为国服参数 echo "默认zh配置" ;; esac sed -i "s#dk_params#${CLUSTER_PARAMS}#g" cluster.json #替换启动参数 #****************************** bussiness info replace docker************ SQL_FILE_PATH=${TOOLS_PATH}/sql cd ${SQL_FILE_PATH} sed -i "s#anhei_account#anhei_account_${CENTER_CODE}#g" dbaccount.sql sed -i "s#anhei_oss#anhei_oss_${CENTER_CODE}#g" toss.sql sed -i "s#anhei_game#anhei_game_${CENTER_CODE}#g" dbgame.sql