diff --git a/test-network/addOrg3/addOrg3.sh b/test-network/addOrg3/addOrg3.sh index 0fc69d06..b56b92d1 100755 --- a/test-network/addOrg3/addOrg3.sh +++ b/test-network/addOrg3/addOrg3.sh @@ -15,6 +15,8 @@ export PATH=${PWD}/../../bin:${PWD}:$PATH export FABRIC_CFG_PATH=${PWD} export VERBOSE=false +. ../scripts/utils.sh + # Print the usage message function printHelp () { echo "Usage: " @@ -56,33 +58,24 @@ function generateOrg3() { if [ "$CRYPTO" == "cryptogen" ]; then which cryptogen if [ "$?" -ne 0 ]; then - echo "cryptogen tool not found. exiting" - exit 1 + fatalln "cryptogen tool not found. exiting" fi - echo - echo "##########################################################" - echo "##### Generate certificates using cryptogen tool #########" - echo "##########################################################" - echo + infoln "Generating certificates using cryptogen tool" - echo "##########################################################" - echo "############ Create Org3 Identities ######################" - echo "##########################################################" + infoln "Creating Org3 Identities" set -x cryptogen generate --config=org3-crypto.yaml --output="../organizations" res=$? { set +x; } 2>/dev/null if [ $res -ne 0 ]; then - echo "Failed to generate certificates..." - exit 1 + fatalln "Failed to generate certificates..." fi fi - # Create crypto material using Fabric CAs + # Create crypto material using Fabric CA if [ "$CRYPTO" == "Certificate Authorities" ]; then - fabric-ca-client version > /dev/null 2>&1 if [[ $? -ne 0 ]]; then echo "ERROR! fabric-ca-client binary not found.." @@ -92,10 +85,7 @@ function generateOrg3() { exit 1 fi - echo - echo "##########################################################" - echo "##### Generate certificates using Fabric CA ############" - echo "##########################################################" + infoln "Generating certificates using Fabric CA" IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1 @@ -103,16 +93,12 @@ function generateOrg3() { sleep 10 - echo "##########################################################" - echo "############ Create Org3 Identities ######################" - echo "##########################################################" - + infoln "Creating Org3 Identities" createOrg3 fi - echo - echo "Generate CCP files for Org3" + infoln "Generating CCP files for Org3" ./ccp-generate.sh } @@ -120,22 +106,17 @@ function generateOrg3() { function generateOrg3Definition() { which configtxgen if [ "$?" -ne 0 ]; then - echo "configtxgen tool not found. exiting" - exit 1 + fatalln "configtxgen tool not found. exiting" + fi + infoln "Generating Org3 organization definition" + export FABRIC_CFG_PATH=$PWD + set -x + configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json + res=$? + { set +x; } 2>/dev/null + if [ $res -ne 0 ]; then + fatalln "Failed to generate Org3 organization definition..." fi - echo "##########################################################" - echo "####### Generating Org3 organization definition #########" - echo "##########################################################" - export FABRIC_CFG_PATH=$PWD - set -x - configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json - res=$? - { set +x; } 2>/dev/null - if [ $res -ne 0 ]; then - echo "Failed to generate Org3 config material..." - exit 1 - fi - echo } function Org3Up () { @@ -146,8 +127,7 @@ function Org3Up () { IMAGE_TAG=$IMAGETAG docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1 fi if [ $? -ne 0 ]; then - echo "ERROR !!!! Unable to start Org3 network" - exit 1 + fatalln "ERROR !!!! Unable to start Org3 network" fi } @@ -155,10 +135,7 @@ function Org3Up () { function addOrg3 () { # If the test network is not up, abort if [ ! -d ../organizations/ordererOrganizations ]; then - echo - echo "ERROR: Please, run ./network.sh up createChannel first." - echo - exit 1 + fatalln "ERROR: Please, run ./network.sh up createChannel first." fi # generate artifacts if they don't exist @@ -167,29 +144,21 @@ function addOrg3 () { generateOrg3Definition fi - echo "Bringing up Org3 peer" + infoln "Bringing up Org3 peer" Org3Up # Use the CLI container to create the configuration transaction needed to add # Org3 to the network - echo - echo "###############################################################" - echo "####### Generate and submit config tx to add Org3 #############" - echo "###############################################################" + infoln "Generating and submitting config tx to add Org3" docker exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE if [ $? -ne 0 ]; then - echo "ERROR !!!! Unable to create config tx" - exit 1 + fatalln "ERROR !!!! Unable to create config tx" fi - echo - echo "###############################################################" - echo "############### Join Org3 peers to network ##################" - echo "###############################################################" + infoln "Joining Org3 peers to network" docker exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE if [ $? -ne 0 ]; then - echo "ERROR !!!! Unable to join Org3 peers to network" - exit 1 + fatalln "ERROR !!!! Unable to join Org3 peers to network" fi } @@ -279,9 +248,7 @@ while [[ $# -ge 1 ]] ; do shift ;; * ) - echo - echo "Unknown flag: $key" - echo + errorln "Unknown flag: $key" printHelp exit 1 ;; @@ -292,7 +259,7 @@ done # Determine whether starting, stopping, restarting or generating for announce if [ "$MODE" == "up" ]; then - echo "Add Org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'" + infoln "Adding org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'" echo elif [ "$MODE" == "down" ]; then EXPMODE="Stopping network" diff --git a/test-network/addOrg3/fabric-ca/registerEnroll.sh b/test-network/addOrg3/fabric-ca/registerEnroll.sh index a0dc729e..65b4122c 100644 --- a/test-network/addOrg3/fabric-ca/registerEnroll.sh +++ b/test-network/addOrg3/fabric-ca/registerEnroll.sh @@ -1,10 +1,14 @@ +#!/bin/bash +# +# Copyright IBM Corp All Rights Reserved +# +# SPDX-License-Identifier: Apache-2.0 +# +. ../../scripts/utils.sh function createOrg3 { - - echo - echo "Enroll the CA admin" - echo + infoln "Enrolling the CA admin" mkdir -p ../organizations/peerOrganizations/org3.example.com/ export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org3.example.com/ @@ -30,23 +34,17 @@ function createOrg3 { Certificate: cacerts/localhost-11054-ca-org3.pem OrganizationalUnitIdentifier: orderer' > ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml - echo - echo "Register peer0" - echo + infoln "Registering peer0" set -x fabric-ca-client register --caname ca-org3 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem { set +x; } 2>/dev/null - echo - echo "Register user" - echo + infoln "Registering user" set -x fabric-ca-client register --caname ca-org3 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem { set +x; } 2>/dev/null - echo - echo "Register the org admin" - echo + infoln "Registering the org admin" set -x fabric-ca-client register --caname ca-org3 --id.name org3admin --id.secret org3adminpw --id.type admin --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem { set +x; } 2>/dev/null @@ -54,18 +52,14 @@ function createOrg3 { mkdir -p ../organizations/peerOrganizations/org3.example.com/peers mkdir -p ../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com - echo - echo "## Generate the peer0 msp" - echo + infoln "Generating the peer0 msp" set -x fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp --csr.hosts peer0.org3.example.com --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem { set +x; } 2>/dev/null cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/msp/config.yaml - echo - echo "## Generate the peer0-tls certificates" - echo + infoln "Generating the peer0-tls certificates" set -x fabric-ca-client enroll -u https://peer0:peer0pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls --enrollment.profile tls --csr.hosts peer0.org3.example.com --csr.hosts localhost --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem { set +x; } 2>/dev/null @@ -87,9 +81,7 @@ function createOrg3 { mkdir -p ../organizations/peerOrganizations/org3.example.com/users mkdir -p ../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com - echo - echo "## Generate the user msp" - echo + infoln "Generating the user msp" set -x fabric-ca-client enroll -u https://user1:user1pw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/User1@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem { set +x; } 2>/dev/null @@ -98,13 +90,10 @@ function createOrg3 { mkdir -p ../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com - echo - echo "## Generate the org admin msp" - echo + infoln "Generating the org admin msp" set -x fabric-ca-client enroll -u https://org3admin:org3adminpw@localhost:11054 --caname ca-org3 -M ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp --tls.certfiles ${PWD}/fabric-ca/org3/tls-cert.pem { set +x; } 2>/dev/null cp ${PWD}/../organizations/peerOrganizations/org3.example.com/msp/config.yaml ${PWD}/../organizations/peerOrganizations/org3.example.com/users/Admin@org3.example.com/msp/config.yaml - } diff --git a/test-network/network.sh b/test-network/network.sh index 328fd1ab..0768cd66 100755 --- a/test-network/network.sh +++ b/test-network/network.sh @@ -141,9 +141,9 @@ function createOrgs() { if [ "$?" -ne 0 ]; then fatalln "cryptogen tool not found. exiting" fi - infoln "Generate certificates using cryptogen tool" + infoln "Generating certificates using cryptogen tool" - infoln "Create Org1 Identities" + infoln "Creating Org1 Identities" set -x cryptogen generate --config=./organizations/cryptogen/crypto-config-org1.yaml --output="organizations" @@ -153,7 +153,7 @@ function createOrgs() { fatalln "Failed to generate certificates..." fi - infoln "Create Org2 Identities" + infoln "Creating Org2 Identities" set -x cryptogen generate --config=./organizations/cryptogen/crypto-config-org2.yaml --output="organizations" @@ -163,7 +163,7 @@ function createOrgs() { fatalln "Failed to generate certificates..." fi - infoln "Create Orderer Org Identities" + infoln "Creating Orderer Org Identities" set -x cryptogen generate --config=./organizations/cryptogen/crypto-config-orderer.yaml --output="organizations" @@ -177,7 +177,7 @@ function createOrgs() { # Create crypto material using Fabric CA if [ "$CRYPTO" == "Certificate Authorities" ]; then - infoln "Generate certificates using Fabric CA" + infoln "Generating certificates using Fabric CA" IMAGE_TAG=${CA_IMAGETAG} docker-compose -f $COMPOSE_FILE_CA up -d 2>&1 @@ -192,21 +192,21 @@ function createOrgs() { fi done - infoln "Create Org1 Identities" + infoln "Creating Org1 Identities" createOrg1 - infoln "Create Org2 Identities" + infoln "Creating Org2 Identities" createOrg2 - infoln "Create Orderer Org Identities" + infoln "Creating Orderer Org Identities" createOrderer fi - infoln "Generate CCP files for Org1 and Org2" + infoln "Generating CCP files for Org1 and Org2" ./organizations/ccp-generate.sh } @@ -300,9 +300,6 @@ function createChannel() { # configtx.yaml is mounted in the cli container, which allows us to use it to # create the channel artifacts scripts/createChannel.sh $CHANNEL_NAME $CLI_DELAY $MAX_RETRY $VERBOSE - if [ $? -ne 0 ]; then - fatalln "Create channel failed" - fi } @@ -337,7 +334,6 @@ function networkDown() { docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf addOrg3/fabric-ca/org3/msp addOrg3/fabric-ca/org3/tls-cert.pem addOrg3/fabric-ca/org3/ca-cert.pem addOrg3/fabric-ca/org3/IssuerPublicKey addOrg3/fabric-ca/org3/IssuerRevocationPublicKey addOrg3/fabric-ca/org3/fabric-ca-server.db' # remove channel and script artifacts docker run --rm -v $(pwd):/data busybox sh -c 'cd /data && rm -rf channel-artifacts log.txt *.tar.gz' - fi } diff --git a/test-network/organizations/fabric-ca/registerEnroll.sh b/test-network/organizations/fabric-ca/registerEnroll.sh index bf790f3a..c064d024 100755 --- a/test-network/organizations/fabric-ca/registerEnroll.sh +++ b/test-network/organizations/fabric-ca/registerEnroll.sh @@ -3,8 +3,7 @@ source scripts/utils.sh function createOrg1() { - - infoln "Enroll the CA admin" + infoln "Enrolling the CA admin" mkdir -p organizations/peerOrganizations/org1.example.com/ export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org1.example.com/ @@ -30,17 +29,17 @@ function createOrg1() { Certificate: cacerts/localhost-7054-ca-org1.pem OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml - infoln "Register peer0" + infoln "Registering peer0" set -x fabric-ca-client register --caname ca-org1 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem { set +x; } 2>/dev/null - infoln "Register user" + infoln "Registering user" set -x fabric-ca-client register --caname ca-org1 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem { set +x; } 2>/dev/null - infoln "Register the org admin" + infoln "Registering the org admin" set -x fabric-ca-client register --caname ca-org1 --id.name org1admin --id.secret org1adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem { set +x; } 2>/dev/null @@ -48,14 +47,14 @@ function createOrg1() { mkdir -p organizations/peerOrganizations/org1.example.com/peers mkdir -p organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com - infoln "Generate the peer0 msp" + infoln "Generating the peer0 msp" set -x fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp --csr.hosts peer0.org1.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem { set +x; } 2>/dev/null cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp/config.yaml - infoln "Generate the peer0-tls certificates" + infoln "Generating the peer0-tls certificates" set -x fabric-ca-client enroll -u https://peer0:peer0pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls --enrollment.profile tls --csr.hosts peer0.org1.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem { set +x; } 2>/dev/null @@ -76,7 +75,7 @@ function createOrg1() { mkdir -p organizations/peerOrganizations/org1.example.com/users mkdir -p organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com - infoln "Generate the user msp" + infoln "Generating the user msp" set -x fabric-ca-client enroll -u https://user1:user1pw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem { set +x; } 2>/dev/null @@ -85,18 +84,16 @@ function createOrg1() { mkdir -p organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com - infoln "Generate the org admin msp" + infoln "Generating the org admin msp" set -x fabric-ca-client enroll -u https://org1admin:org1adminpw@localhost:7054 --caname ca-org1 -M ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org1/tls-cert.pem { set +x; } 2>/dev/null cp ${PWD}/organizations/peerOrganizations/org1.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/config.yaml - } function createOrg2() { - - infoln "Enroll the CA admin" + infoln "Enrolling the CA admin" mkdir -p organizations/peerOrganizations/org2.example.com/ export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/peerOrganizations/org2.example.com/ @@ -122,17 +119,17 @@ function createOrg2() { Certificate: cacerts/localhost-8054-ca-org2.pem OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml - infoln "Register peer0" + infoln "Registering peer0" set -x fabric-ca-client register --caname ca-org2 --id.name peer0 --id.secret peer0pw --id.type peer --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem { set +x; } 2>/dev/null - infoln "Register user" + infoln "Registering user" set -x fabric-ca-client register --caname ca-org2 --id.name user1 --id.secret user1pw --id.type client --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem { set +x; } 2>/dev/null - infoln "Register the org admin" + infoln "Registering the org admin" set -x fabric-ca-client register --caname ca-org2 --id.name org2admin --id.secret org2adminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem { set +x; } 2>/dev/null @@ -140,14 +137,14 @@ function createOrg2() { mkdir -p organizations/peerOrganizations/org2.example.com/peers mkdir -p organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com - infoln "Generate the peer0 msp" + infoln "Generating the peer0 msp" set -x fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp --csr.hosts peer0.org2.example.com --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem { set +x; } 2>/dev/null cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/msp/config.yaml - infoln "Generate the peer0-tls certificates" + infoln "Generating the peer0-tls certificates" set -x fabric-ca-client enroll -u https://peer0:peer0pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls --enrollment.profile tls --csr.hosts peer0.org2.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem { set +x; } 2>/dev/null @@ -168,7 +165,7 @@ function createOrg2() { mkdir -p organizations/peerOrganizations/org2.example.com/users mkdir -p organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com - infoln "Generate the user msp" + infoln "Generating the user msp" set -x fabric-ca-client enroll -u https://user1:user1pw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/User1@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem { set +x; } 2>/dev/null @@ -177,18 +174,16 @@ function createOrg2() { mkdir -p organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com - infoln "Generate the org admin msp" + infoln "Generating the org admin msp" set -x fabric-ca-client enroll -u https://org2admin:org2adminpw@localhost:8054 --caname ca-org2 -M ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/org2/tls-cert.pem { set +x; } 2>/dev/null cp ${PWD}/organizations/peerOrganizations/org2.example.com/msp/config.yaml ${PWD}/organizations/peerOrganizations/org2.example.com/users/Admin@org2.example.com/msp/config.yaml - } function createOrderer() { - - infoln "Enroll the CA admin" + infoln "Enrolling the CA admin" mkdir -p organizations/ordererOrganizations/example.com export FABRIC_CA_CLIENT_HOME=${PWD}/organizations/ordererOrganizations/example.com @@ -214,12 +209,12 @@ function createOrderer() { Certificate: cacerts/localhost-9054-ca-orderer.pem OrganizationalUnitIdentifier: orderer' >${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml - infoln "Register orderer" + infoln "Registering orderer" set -x fabric-ca-client register --caname ca-orderer --id.name orderer --id.secret ordererpw --id.type orderer --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem { set +x; } 2>/dev/null - infoln "Register the orderer admin" + infoln "Registering the orderer admin" set -x fabric-ca-client register --caname ca-orderer --id.name ordererAdmin --id.secret ordererAdminpw --id.type admin --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem { set +x; } 2>/dev/null @@ -229,14 +224,14 @@ function createOrderer() { mkdir -p organizations/ordererOrganizations/example.com/orderers/orderer.example.com - infoln "Generate the orderer msp" + infoln "Generating the orderer msp" set -x fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem { set +x; } 2>/dev/null cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/config.yaml - infoln "Generate the orderer-tls certificates" + infoln "Generating the orderer-tls certificates" set -x fabric-ca-client enroll -u https://orderer:ordererpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/tls --enrollment.profile tls --csr.hosts orderer.example.com --csr.hosts localhost --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem { set +x; } 2>/dev/null @@ -254,11 +249,10 @@ function createOrderer() { mkdir -p organizations/ordererOrganizations/example.com/users mkdir -p organizations/ordererOrganizations/example.com/users/Admin@example.com - infoln "Generate the admin msp" + infoln "Generating the admin msp" set -x fabric-ca-client enroll -u https://ordererAdmin:ordererAdminpw@localhost:9054 --caname ca-orderer -M ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp --tls.certfiles ${PWD}/organizations/fabric-ca/ordererOrg/tls-cert.pem { set +x; } 2>/dev/null cp ${PWD}/organizations/ordererOrganizations/example.com/msp/config.yaml ${PWD}/organizations/ordererOrganizations/example.com/users/Admin@example.com/msp/config.yaml - } diff --git a/test-network/scripts/createChannel.sh b/test-network/scripts/createChannel.sh index de46ad35..567155cb 100755 --- a/test-network/scripts/createChannel.sh +++ b/test-network/scripts/createChannel.sh @@ -41,7 +41,6 @@ createChannel() { done cat log.txt verifyResult $res "Channel creation failed" - successln "Channel '$CHANNEL_NAME' created" } # joinChannel ORG @@ -82,11 +81,12 @@ BLOCKFILE="./channel-artifacts/${CHANNEL_NAME}.block" ## Create channel infoln "Creating channel ${CHANNEL_NAME}" createChannel +successln "Channel '$CHANNEL_NAME' created" ## Join all the peers to the channel -infoln "Join Org1 peers to the channel..." +infoln "Joining org1 peer to the channel..." joinChannel 1 -infoln "Join Org2 peers to the channel..." +infoln "Joining org2 peer to the channel..." joinChannel 2 ## Set the anchor peers for each org in the channel @@ -95,6 +95,4 @@ setAnchorPeer 1 infoln "Setting anchor peer for org2..." setAnchorPeer 2 -successln "Channel successfully joined" - -exit 0 +successln "Channel '$CHANNEL_NAME' joined" diff --git a/test-network/scripts/org3-scripts/joinChannel.sh b/test-network/scripts/org3-scripts/joinChannel.sh index fb58ae5c..97153ccb 100755 --- a/test-network/scripts/org3-scripts/joinChannel.sh +++ b/test-network/scripts/org3-scripts/joinChannel.sh @@ -11,9 +11,6 @@ # chaincode as version 2.0 on peer0.org3. # -echo -echo "========= Getting Org3 on to your test network ========= " -echo CHANNEL_NAME="$1" DELAY="$2" TIMEOUT="$3" @@ -61,16 +58,13 @@ peer channel fetch 0 $BLOCKFILE -o orderer.example.com:7050 --ordererTLSHostname res=$? { set +x; } 2>/dev/null cat log.txt -verifyResult $res "Fetching config block from orderer has Failed" +verifyResult $res "Fetching config block from orderer has failed" +infoln "Joining org3 peer to the channel..." joinChannel 3 -echo "Setting anchor peer for org3..." +infoln "Setting anchor peer for org3..." setAnchorPeer 3 -echo "===================== peer0.org3 joined channel '$CHANNEL_NAME' ===================== " -echo -echo "========= Finished adding Org3 to your test network! ========= " -echo - -exit 0 +successln "Channel '$CHANNEL_NAME' joined" +successln "Org3 peer successfully added to network" diff --git a/test-network/scripts/org3-scripts/updateChannelConfig.sh b/test-network/scripts/org3-scripts/updateChannelConfig.sh index 5bf8bc7c..eabbf71e 100755 --- a/test-network/scripts/org3-scripts/updateChannelConfig.sh +++ b/test-network/scripts/org3-scripts/updateChannelConfig.sh @@ -25,10 +25,9 @@ MAX_RETRY=5 # imports . scripts/envVar.sh . scripts/configUpdate.sh +. scripts/utils.sh -echo -echo "Creating config transaction to add org3 to network" -echo +infoln "Creating config transaction to add org3 to network" # Fetch the config for the channel, writing it to config.json fetchChannelConfig 1 ${CHANNEL_NAME} config.json @@ -41,24 +40,13 @@ jq -s '.[0] * {"channel_group":{"groups":{"Application":{"groups": {"Org3MSP":.[ # Compute a config update, based on the differences between config.json and modified_config.json, write it as a transaction to org3_update_in_envelope.pb createConfigUpdate ${CHANNEL_NAME} config.json modified_config.json org3_update_in_envelope.pb -echo -echo "========= Config transaction to add org3 to network created ===== " -echo - -echo "Signing config transaction" -echo +infoln "Signing config transaction" signConfigtxAsPeerOrg 1 org3_update_in_envelope.pb -echo -echo "========= Submitting transaction from a different peer (peer0.org2) which also signs it ========= " -echo +infoln "Submitting transaction from a different peer (peer0.org2) which also signs it" setGlobals 2 set -x peer channel update -f org3_update_in_envelope.pb -c ${CHANNEL_NAME} -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${ORDERER_CA} { set +x; } 2>/dev/null -echo -echo "========= Config transaction to add org3 to network submitted! =========== " -echo - -exit 0 +successln "Config transaction to add org3 to network submitted"