chore(project): 添加项目配置文件和忽略规则
- 添加 Babel 配置文件支持 ES6+ 语法转换 - 添加 ESLint 忽略规则和配置文件 - 添加 Git 忽略规则文件 - 添加 Travis CI 配置文件 - 添加 1.4.2 版本变更日志文件 - 添加 Helm 图表辅助模板文件 - 添加 Helm 忽略规则文件
This commit is contained in:
75
script/config-center/consul/consul-config.sh
Normal file
75
script/config-center/consul/consul-config.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 1999-2019 Seata.io Group.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at、
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
while getopts ":h:p:" opt
|
||||
do
|
||||
case $opt in
|
||||
h)
|
||||
host=$OPTARG
|
||||
;;
|
||||
p)
|
||||
port=$OPTARG
|
||||
;;
|
||||
?)
|
||||
echo " USAGE OPTION: $0 [-h host] [-p port] "
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z ${host} ]]; then
|
||||
host=localhost
|
||||
fi
|
||||
if [[ -z ${port} ]]; then
|
||||
port=8500
|
||||
fi
|
||||
|
||||
consulAddr=$host:$port
|
||||
contentType="content-type:application/json;charset=UTF-8"
|
||||
echo "Set consulAddr=$consulAddr"
|
||||
|
||||
failCount=0
|
||||
tempLog=$(mktemp -u)
|
||||
function addConfig() {
|
||||
curl -X PUT -H "${1}" -d "${2}" "http://$3/v1/kv/$4" >"${tempLog}" 2>/dev/null
|
||||
if [[ -z $(cat "${tempLog}") ]]; then
|
||||
echo " Please check the cluster status. "
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(cat "${tempLog}") =~ "true" ]]; then
|
||||
echo "Set $4=$2 successfully "
|
||||
else
|
||||
echo "Set $4=$2 failure "
|
||||
(( failCount++ ))
|
||||
fi
|
||||
}
|
||||
|
||||
count=0
|
||||
for line in $(cat $(dirname "$PWD")/config.txt | sed s/[[:space:]]//g); do
|
||||
(( count++ ))
|
||||
key=${line%%=*}
|
||||
value=${line#*=}
|
||||
addConfig "${contentType}" "${value}" "${consulAddr}" "${key}"
|
||||
done
|
||||
|
||||
echo "========================================================================="
|
||||
echo " Complete initialization parameters, total-count:$count , failure-count:$failCount "
|
||||
echo "========================================================================="
|
||||
|
||||
if [[ ${failCount} -eq 0 ]]; then
|
||||
echo " Init consul config finished, please start seata-server. "
|
||||
else
|
||||
echo " Init consul config fail. "
|
||||
fi
|
||||
Reference in New Issue
Block a user