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