-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerateArtifactsUpdated.sh
More file actions
executable file
·76 lines (63 loc) · 2.37 KB
/
generateArtifactsUpdated.sh
File metadata and controls
executable file
·76 lines (63 loc) · 2.37 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
#!/bin/bash -e
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
#set -x
CHANNEL_NAME=$1
TOTAL_CHANNELS=$2
: ${CHANNEL_NAME:="mychannel"}
: ${TOTAL_CHANNELS:="1"}
echo "Using CHANNEL_NAME prefix as $CHANNEL_NAME"
ROOT_DIR=$PWD
export FABRIC_CFG_PATH=$ROOT_DIR/artifacts/channel
ARCH=$(uname -s)
function generateCerts() {
CRYPTOGEN=$ROOT_DIR/artifacts/bin/cryptogen
echo
echo "##########################################################"
echo "##### Generate certificates using cryptogen tool #########"
echo "##########################################################"
$CRYPTOGEN generate --config=$FABRIC_CFG_PATH/cryptogen.yaml --output="channel/crypto-config"
echo
}
## docker-compose template to replace private key file names with constants
function replacePrivateKey() {
OPTS="-i"
if [ "$ARCH" = "Darwin" ]; then
OPTS="-it"
fi
cp docker-compose-template.yaml docker-compose.yaml
cd channel/crypto-config/peerOrganizations/org1.example.com/ca/
PRIV_KEY=$(ls *_sk)
cd $ROOT_DIR/artifacts
sed $OPTS "s/CA1_PRIVATE_KEY/${PRIV_KEY}/g" docker-compose.yaml
cd channel/crypto-config/peerOrganizations/org2.example.com/ca/
PRIV_KEY=$(ls *_sk)
cd $ROOT_DIR/artifacts
sed $OPTS "s/CA2_PRIVATE_KEY/${PRIV_KEY}/g" docker-compose.yaml
}
## Generate orderer genesis block , channel configuration transaction and anchor peer update transactions
function generateChannelArtifacts() {
CONFIGTXGEN=$ROOT_DIR/artifacts/bin/configtxgen
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!
$CONFIGTXGEN -profile TwoOrgsOrdererGenesis -outputBlock ./channel/genesis.block
# for ((i = 1; i <= $TOTAL_CHANNELS; i = $i + 1)); do
echo
echo "#################################################################"
echo "### Generating channel configuration transaction '$CHANNEL_NAME.tx' ###"
echo "#################################################################"
$CONFIGTXGEN -profile TwoOrgsChannel -channelID $CHANNEL_NAME -outputCreateChannelTx ./channel/$CHANNEL_NAME.tx
echo
# done
}
cd artifacts
generateCerts
replacePrivateKey
generateChannelArtifacts
cd $ROOT_DIR