-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate.sh
executable file
·71 lines (64 loc) · 2.86 KB
/
generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#
# Exit on first error, print all commands
echo "===================================================================================================================="
echo ""
export PATH=$GOPATH/src/github.com/hyperledger/fabric/build/bin:${PWD}/../bin:${PWD}:$PATH
export FABRIC_CFG_PATH=${PWD}/artifacts
export CHANNEL_NAME=supplychainchannel
# remove previous crypto material and config transactions
rm -fr ../artifacts/network
echo ""
echo "===================================== Generating crypto material ==================================================="
echo ""
# generate crypto material
cryptogen generate --config=./artifacts/crypto-config.yaml --output=./artifacts/network/crypto-config
if [ "$?" -ne 0 ]; then
echo "Failed to generate crypto material!"
exit 1
fi
echo ""
echo "======================================= Creating genesis block ====================================================="
echo ""
# generate genesis block for orderer
configtxgen -profile TraceOrdererGenesis -outputBlock ./artifacts/network/genesis.block
if [ "$?" -ne 0 ]; then
echo "Failed to generate orderer genesis block!"
exit 1
fi
echo ""
echo "============================= Generating channel configuration transaction ========================================="
echo ""
# generate channel configuration transaction
configtxgen -profile TraceOrgsChannel -outputCreateChannelTx ./artifacts/network/channel.tx -channelID $CHANNEL_NAME
if [ "$?" -ne 0 ]; then
echo "Failed to generate channel configuration transaction!"
exit 1
fi
echo ""
echo "============================= Generating anchor peer update for ManufacturerMSP ===================================="
echo ""
# generate anchor peer transaction
configtxgen -profile TraceOrgsChannel -outputAnchorPeersUpdate ./artifacts/network/ManufacturerMSPanchors.tx -channelID $CHANNEL_NAME -asOrg ManufacturerMSP
if [ "$?" -ne 0 ]; then
echo "Failed to generate anchor peer update for ManufacturerMSP!"
exit 1
fi
echo ""
echo "============================= Generating anchor peer update for MiddleMenMSP ======================================"
echo ""
configtxgen -profile TraceOrgsChannel -outputAnchorPeersUpdate ./artifacts/network/MiddleMenMSPanchors.tx -channelID $CHANNEL_NAME -asOrg MiddleMenMSP
if [ "$?" -ne 0 ]; then
echo "Failed to generate anchor peer update for MiddleMenMSP!"
exit 1
fi
echo ""
echo "============================= Generating anchor peer update for ConsumerMSP ========================================"
echo ""
configtxgen -profile TraceOrgsChannel -outputAnchorPeersUpdate ./artifacts/network/ConsumerMSPanchors.tx -channelID $CHANNEL_NAME -asOrg ConsumerMSP
if [ "$?" -ne 0 ]; then
echo "Failed to generate anchor peer update for ConsumerMSP!"
exit 1
fi
echo ""
echo "===================================== Ready to up the network ======================================================"