-
Notifications
You must be signed in to change notification settings - Fork 0
/
startNetwork.sh
74 lines (67 loc) · 2.14 KB
/
startNetwork.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
72
73
74
MODE="$1"
ORGS="$2"
CHANNEL_NAME="$3"
PROFILE_NAME="$4"
CHANNEL="$5"
IMAGETAG="latest"
function generateChannelArtifacts() {
which configtxgen
if [ "$?" -ne 0 ]; then
echo "configtxgen tool not found. exiting"
exit 1
fi
echo "#####################################################################"
echo "### Generating channel configuration transaction $CHANNEL_NAME.tx ###"
echo "#####################################################################"
set -x
configtxgen -profile $PROFILE_NAME -outputCreateChannelTx ./channel-artifacts/$CHANNEL_NAME.tx -channelID $CHANNEL_NAME
res=$?
set +x
if [ $res -ne 0 ]; then
echo "Failed to generate channel configuration transaction..."
exit 1
fi
for ((org = 0; org < $ORGS; org++)); do
ORG_NAME=$(jq ".Channels[$CHANNEL].Organizations[$org].name" UserInput.json | tr -d '"')
echo
echo "#################################################################"
echo "####### Generating anchor peer update for ${ORG_NAME}MSP ##########"
echo "#################################################################"
set -x
configtxgen -profile $PROFILE_NAME -outputAnchorPeersUpdate ./channel-artifacts/${ORG_NAME}MSPanchors_${CHANNEL_NAME}.tx -channelID $CHANNEL_NAME -asOrg ${ORG_NAME}MSP
res=$?
set +x
if [ $res -ne 0 ]; then
echo "Failed to generate anchor peer update for ${ORG_NAME}MSP..."
exit 1
fi
done
echo
echo "#################################################################################"
echo "######## Crypto material generation completed for channel : $CHANNEL_NAME #######"
echo "#################################################################################"
}
# The function will bring up all the docker containers
function dockerComposeUp() {
docker-compose -f docker-compose-cli.yaml up -d
# now run the end to end script
docker exec cli scripts/script.sh $CHANNEL_NAME $ORGS $CHANNEL
if [ $? -ne 0 ]; then
echo "ERROR !!!! Test failed"
exit 1
fi
}
case $MODE in
up)
dockerComposeUp
exit 0
;;
generate)
generateChannelArtifacts
exit 0
;;
restart)
dockerComposeUp
exit 0
;;
esac