#!/usr/bin/env bash
server_host=$1
# server_host=172.16.10.1
# module_name=xyqb
module_name=$2
public_host=139.198.2.239
basic_host=172.16.10.2
mysql_host=172.16.10.5

cd /home/quant_group/jenkins/workspace/update_test-config-manager/
rm -rf ${module_name}.${server_host}
cp -rf ${module_name} ${module_name}.${server_host}
cd ${module_name}.${server_host}
# 替换mysql数据库账户
sed -i "s/192.168.192.191/${mysql_host}/g" *.properties
sed -i "s/spring.datasource.username=root/spring.datasource.username=quantgroup/g" *.properties
sed -i "s/spring.datasource.password=qatest/spring.datasource.password=quaNtGroup2011/g" *.properties
# 替换redis数据库账户
sed -i "s/redis.master.host=192.168.192.206/redis.master.host=${basic_host}/g" *.properties
sed -i "s/redis.master.port=6370/redis.master.port=6371/g" *.properties
# 替换rabbitmq账户
sed -i "s/rabbitmq.connection.host=192.168.192.243/rabbitmq.connection.host=${basic_host}/g" *.properties
sed -i "s/rabbitmq.connection.port=5672/rabbitmq.connection.port=5671/g" *.properties
sed -i "s/rabbitmq.connection.user=rabbit_admin/rabbitmq.connection.user=qa/g" *.properties
sed -i "s/rabbitmq.connection.password=abc1234/rabbitmq.connection.password=qatest/g" *.properties

sed -i "s/192.168.192.190/${server_host}/g" *.properties
sed -i "s/61.50.125.14/${public_host}/g" *.properties

cd ..
rm -rf ${module_name}.${server_host}.tgz
tar zcf ${module_name}.${server_host}.tgz ${module_name}.${server_host}