fabric-samples/distributed-deploy/bcp-install-main/resources/generateInstallPackage/masterPackage/template/create-update-pb.sh
zeoio fa0b04aaeb distributed-depoly: add copyright to codes, configs file
Signed-off-by: zeoio <kinsleer@outlook.com>
2020-04-29 10:01:42 +08:00

30 lines
1.4 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#
# Copyright CGB Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
# 这个脚本需要在/var/run/目录下执行因为cli获取通道配置文件后会复制到容器的/host/var/run/下,也就是宿主机的/var/run/
CHANNEL_NAME="$1"
which jq
if [ "$?" -ne 0 ]; then
yum -y install jq
fi
cp -r /host/var/run/config_${CHANNEL_NAME}.json ./
cp -r /host/var/run/config_${CHANNEL_NAME}_modified.json ./
configtxlator proto_encode --input config_${CHANNEL_NAME}.json --type common.Config --output config_${CHANNEL_NAME}.pb
configtxlator proto_encode --input config_${CHANNEL_NAME}_modified.json --type common.Config --output config_${CHANNEL_NAME}_modified.pb
configtxlator compute_update --channel_id $CHANNEL_NAME --original config_${CHANNEL_NAME}.pb --updated config_${CHANNEL_NAME}_modified.pb --output config_update_${CHANNEL_NAME}.pb
configtxlator proto_decode --input config_update_${CHANNEL_NAME}.pb --type common.ConfigUpdate | jq '.' > config_update_${CHANNEL_NAME}.json
echo '{"payload":{"header":{"channel_header":{"channel_id":"'${CHANNEL_NAME}'","type":2}},"data":{"config_update":'$(cat config_update_${CHANNEL_NAME}.json)'}}}' | jq '.' > config_update_${CHANNEL_NAME}_in_envelope.json
configtxlator proto_encode --input config_update_${CHANNEL_NAME}_in_envelope.json --type common.Envelope --output config_update_${CHANNEL_NAME}_in_envelope.pb