docker-compose-files/hyperledger_fabric/latest/scripts/gen_channelArtifacts.sh

82 lines
2.4 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Use ${FABRIC_CFG_PATH}/configtx.yaml to generate following materials,
# and put under /tmp/$CHANNEL_ARTIFACTS:
# system channel genesis block
# new app channel tx
# update anchor peer tx
# Define those global variables
if [ -f ./variables.sh ]; then
source ./variables.sh
2018-10-11 22:29:09 +08:00
elif [ -f /scripts/variables.sh ]; then
source /scripts/variables.sh
else
echo "Cannot find the variables.sh files, pls check"
exit 1
fi
2018-10-11 22:29:09 +08:00
cd /tmp/${CHANNEL_ARTIFACTS} # all generated materials will be put under /tmp/$CHANNEL_ARTIFACTS
2019-05-02 17:30:13 +08:00
echo "Generate genesis block of system channel using configtx.yaml"
[ ! -f ${ORDERER0_GENESIS_BLOCK} ] && \
configtxgen \
2018-10-11 22:29:09 +08:00
-configPath /tmp \
-channelID ${SYS_CHANNEL} \
-profile ${ORDERER_GENESIS_PROFILE} \
2019-05-02 17:30:13 +08:00
-outputBlock ${ORDERER0_GENESIS_BLOCK}
[ ! -f ${ORDERER0_GENESIS_BLOCK} ] && echo "Fail to generate genesis block ${ORDERER0_GENESIS_BLOCK}" && exit -1
cp ${ORDERER0_GENESIS_BLOCK} ${ORDERER1_GENESIS_BLOCK}
cp ${ORDERER0_GENESIS_BLOCK} ${ORDERER2_GENESIS_BLOCK}
2019-02-28 11:21:41 +08:00
2019-04-01 16:21:22 +08:00
#for (( i=1; i<150; i++ ));
#do
#APP_CHANNEL="channel"$i
#APP_CHANNEL_TX=${APP_CHANNEL}".tx"
2019-03-21 14:59:52 +08:00
echo "Create the new app channel ${APP_CHANNEL} tx using configtx.yaml"
2019-04-01 16:21:22 +08:00
[ ! -f ${APP_CHANNEL_TX} ] && \
configtxgen \
2018-10-11 22:29:09 +08:00
-configPath /tmp \
-profile ${APP_CHANNEL_PROFILE} \
-channelID ${APP_CHANNEL} \
2018-10-09 14:02:33 +08:00
-outputCreateChannelTx ${APP_CHANNEL_TX}
2019-02-28 11:21:41 +08:00
[ ! -f ${APP_CHANNEL_TX} ] && echo "Fail to generate app channel tx file" && exit -1
2019-04-01 16:21:22 +08:00
#done
2019-02-28 11:21:41 +08:00
2019-04-01 16:21:22 +08:00
[ ! -f ${APP_CHANNEL_TX}.json ] && \
configtxgen \
-inspectChannelCreateTx ${APP_CHANNEL_TX} > ${APP_CHANNEL_TX}.json
echo "Create the anchor peer configuration tx for org1 and org2"
2019-04-01 16:21:22 +08:00
[ ! -f ${UPDATE_ANCHOR_ORG1_TX} ] && \
configtxgen \
2018-10-11 22:29:09 +08:00
-configPath /tmp \
-profile ${APP_CHANNEL_PROFILE} \
-channelID ${APP_CHANNEL} \
-asOrg ${ORG1MSP} \
-outputAnchorPeersUpdate ${UPDATE_ANCHOR_ORG1_TX}
2018-10-11 22:29:09 +08:00
2019-02-28 11:21:41 +08:00
[ ! -f ${UPDATE_ANCHOR_ORG1_TX} ] && echo "Fail to generate the anchor update tx for org1" && exit -1
2019-04-01 16:21:22 +08:00
[ ! -f ${UPDATE_ANCHOR_ORG2_TX} ] && \
configtxgen \
2018-10-11 22:29:09 +08:00
-configPath /tmp \
-profile ${APP_CHANNEL_PROFILE} \
-channelID ${APP_CHANNEL} \
-asOrg ${ORG2MSP} \
-outputAnchorPeersUpdate ${UPDATE_ANCHOR_ORG2_TX}
2019-02-28 11:21:41 +08:00
[ ! -f ${UPDATE_ANCHOR_ORG2_TX} ] && echo "Fail to generate the anchor update tx for org1" && exit -1
echo "Output the json for org1, org2 and org3"
2019-05-02 17:30:13 +08:00
declare -a msps=("${ORG1MSP}"
"${ORG2MSP}"
"${ORG3MSP}")
for msp in "${msps[@]}"
do
[ ! -f ${msp}.json ] && \
configtxgen \
2018-10-11 22:29:09 +08:00
-configPath /tmp \
2019-05-02 17:30:13 +08:00
-printOrg ${msp} >${msp}.json
done