-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate.sh
More file actions
executable file
·124 lines (105 loc) · 3.66 KB
/
generate.sh
File metadata and controls
executable file
·124 lines (105 loc) · 3.66 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
export PATH=${PWD}/bin:${PWD}:$PATH
export FABRIC_CFG_PATH=$PWD
export VERBOSE=false
# channel name defaults to "mychannel"
export CHANNEL_NAME="mychannel"
# Generates Org certs using cryptogen tool
function generateCerts() {
which cryptogen
if [ "$?" -ne 0 ]; then
echo "cryptogen tool not found. exiting"
exit 1
fi
echo
echo "##########################################################"
echo "##### Generate certificates using cryptogen tool #########"
echo "##########################################################"
if [ -d "crypto-config" ]; then
rm -Rf crypto-config
fi
set -x
./bin/cryptogen generate --config=./crypto-config.yaml
res=$?
set +x
if [ $res -ne 0 ]; then
echo "Failed to generate certificates..."
exit 1
fi
echo
}
function generateChannelArtifacts() {
which configtxgen
if [ "$?" -ne 0 ]; then
echo "configtxgen tool not found. exiting"
exit 1
fi
echo "##########################################################"
echo "######### Generating Orderer Genesis block ##############"
echo "##########################################################"
# Note: For some unknown reason (at least for now) the block file can't be
# named orderer.genesis.block or the orderer will fail to launch!
set -x
./bin/configtxgen -profile energy_chain -channelID byfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
res=$?
set +x
if [ $res -ne 0 ]; then
echo "Failed to generate orderer(enertgy_chain) genesis block..."
exit 1
fi
echo
echo "#################################################################"
echo "### Generating channel configuration transaction 'channel.tx' ###"
echo "#################################################################"
set -x
./bin/configtxgen -profile commonchannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
res=$?
set +x
if [ $res -ne 0 ]; then
echo "Failed to generate channel configuration transaction..."
exit 1
fi
echo
echo "#################################################################"
echo "####### Generating anchor peer update for prosumerMSP ##########"
echo "#################################################################"
set -x
./bin/configtxgen -profile commonchannel -outputAnchorPeersUpdate ./channel-artifacts/prosumerMSPanchors.tx -channelID $CHANNEL_NAME -asOrg prosumerMSP
res=$?
set +x
if [ $res -ne 0 ]; then
echo "Failed to generate anchor peer update for peosumerMSP..."
exit 1
fi
echo
echo "#################################################################"
echo "####### Generating anchor peer update for consumerMSP ##########"
echo "#################################################################"
set -x
./bin/configtxgen -profile commonchannel -outputAnchorPeersUpdate \
./channel-artifacts/consumerMSPanchors.tx -channelID $CHANNEL_NAME -asOrg consumerMSP
res=$?
set +x
if [ $res -ne 0 ]; then
echo "Failed to generate anchor peer update for consumerMSP..."
exit 1
fi
echo
echo "#################################################################"
echo "####### Generating anchor peer update for exchangeMSP ##########"
echo "#################################################################"
set -x
./bin/configtxgen -profile commonchannel -outputAnchorPeersUpdate \
./channel-artifacts/exchangeMSPanchors.tx -channelID $CHANNEL_NAME -asOrg exchangeMSP
res=$?
set +x
if [ $res -ne 0 ]; then
echo "Failed to generate anchor peer update for exchangeMSP..."
exit 1
fi
echo
}
# default consensus type
CONSENSUS_TYPE="kafka"
generateCerts
generateChannelArtifacts