github.com/myafeier/fabric@v1.0.1-0.20170722181825-3a4b1f2bce86/test/envsetup/generateCfgTrx.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright IBM Corp. All Rights Reserved.
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  set -e
     9  
    10  CHANNEL_NAME=$1
    11  CHANNEL_COUNT=$2
    12  
    13  : ${CHANNEL_NAME:="mychannel"}
    14  : ${CHANNEL_COUNT:="1"}
    15  
    16  export FABRIC_ROOT=$GOPATH/src/github.com/hyperledger/fabric
    17  export E2E_CLI_PATH=$FABRIC_ROOT/examples/e2e_cli/
    18  cp $E2E_CLI_PATH/configtx.yaml $PWD
    19  cp $E2E_CLI_PATH/crypto-config.yaml ./crypto-config.yaml
    20  cp -r $E2E_CLI_PATH/base $PWD/
    21  sed -i 's/e2ecli/envsetup/g' base/peer-base.yaml
    22  export FABRIC_CFG_PATH=$PWD
    23  
    24  ARTIFACTS=./channel-artifacts
    25  OS_ARCH=$(echo "$(uname -s)-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}')
    26  
    27  echo "Channel name - "$CHANNEL_NAME
    28  echo "Total channels - "$CHANNEL_COUNT
    29  echo
    30  
    31  CONFIGTXGEN=$(which configtxgen || /bin/true)
    32  
    33  ## Generates Org certs using cryptogen tool
    34  function generateCerts() {
    35  	CRYPTOGEN=$FABRIC_ROOT/release/$OS_ARCH/bin/cryptogen
    36  
    37  	if [ -f "$CRYPTOGEN" ]; then
    38  		echo "Using cryptogen -> $CRYPTOGEN"
    39  	else
    40  		echo "Building cryptogen"
    41  		make -C $FABRIC_ROOT release-all
    42  	fi
    43  
    44  	echo
    45  	echo "**** Generate certificates using cryptogen tool ****"
    46  	$CRYPTOGEN generate --config=./crypto-config.yaml
    47  	echo
    48  }
    49  
    50  ## Generate orderer genesis block , channel configuration transaction and anchor peer update transactions
    51  function generateChannelArtifacts() {
    52  
    53  	CONFIGTXGEN=$FABRIC_ROOT/release/$OS_ARCH/bin/configtxgen
    54  	if [ -f "$CONFIGTXGEN" ]; then
    55  		echo "Using configtxgen -> $CONFIGTXGEN"
    56  	else
    57  		echo "Building configtxgen"
    58  		make -C $FABRIC_ROOT release-all
    59  	fi
    60  
    61  	echo "Generating genesis block"
    62  	$CONFIGTXGEN -profile TwoOrgsOrdererGenesis -outputBlock $ARTIFACTS/genesis.block
    63  
    64  	for ((i = 0; $i < $CHANNEL_COUNT; i++)); do
    65  		echo "Generating channel configuration transaction for channel '$CHANNEL_NAME$i'"
    66  		$CONFIGTXGEN -profile TwoOrgsChannel -outputCreateChannelTx $ARTIFACTS/channel$i.tx -channelID $CHANNEL_NAME$i
    67  
    68  		echo "Generating anchor peer update for Org1MSP"
    69  		$CONFIGTXGEN -profile TwoOrgsChannel -outputAnchorPeersUpdate $ARTIFACTS/Org1MSPanchors$i.tx -channelID $CHANNEL_NAME$i -asOrg Org1MSP
    70  
    71  		echo "Generating anchor peer update for Org2MSP"
    72  		$CONFIGTXGEN -profile TwoOrgsChannel -outputAnchorPeersUpdate $ARTIFACTS/Org2MSPanchors$i.tx -channelID $CHANNEL_NAME$i -asOrg Org2MSP
    73  	done
    74  }
    75  
    76  generateCerts
    77  generateChannelArtifacts
    78  
    79  echo "######################### DONE ######################"