github.com/tenywen/fabric@v1.0.0-beta.0.20170620030522-a5b1ed380643/examples/configtxupdate/bootstrap_batchsize/script.sh (about)

     1  #!/bin/bash
     2  
     3  CDIR=$(dirname $(basename "$0"))
     4  
     5  : ${OUTDIR:="example_output"}
     6  mkdir -p ${OUTDIR} || die "could not create output dir ${OUTDIR}"
     7  
     8  GENESIS_BLOCK_PB="${OUTDIR}/genesis_block.pb"
     9  GENESIS_BLOCK_JSON="${OUTDIR}/genesis_block.json"
    10  UPDATED_GENESIS_BLOCK_JSON="${OUTDIR}/updated_genesis_block.json"
    11  UPDATED_GENESIS_BLOCK_PB="${OUTDIR}/updated_genesis_block.pb"
    12  
    13  . ${CDIR}/../common_scripts/common.sh
    14  
    15  findConfigtxgen || die "no configtxgen present"
    16  
    17  bigMsg "Creating bootstrap block"
    18  
    19  echo -e "Executing:\n\tconfigtxgen -outputBlock '${GENESIS_BLOCK_PB}' -profile SampleSingleMSPSolo"
    20  $CONFIGTXGEN -outputBlock "${GENESIS_BLOCK_PB}" -profile SampleSingleMSPSolo 2>/dev/null || die "Error generating genesis block"
    21  
    22  pauseIfInteractive
    23  
    24  bigMsg "Decoding genesis block"
    25  decode common.Block "${GENESIS_BLOCK_PB}" "${GENESIS_BLOCK_JSON}"
    26  
    27  bigMsg "Updating the genesis config"
    28  ORIGINAL_BATCHSIZE=$(jq ".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count" genesis_block.json)
    29  NEW_BATCHSIZE=$(( ${ORIGINAL_BATCHSIZE} + 1 ))
    30  echo "Updating batch size from ${ORIGINAL_BATCHSIZE} to ${NEW_BATCHSIZE}."
    31  echo -e "Executing\n\tjq '.data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count = ${NEW_BATCHSIZE}' '${GENESIS_BLOCK_JSON}' > '${UPDATED_GENESIS_BLOCK_JSON}'"
    32  jq ".data.data[0].payload.data.config.channel_group.groups.Orderer.values.BatchSize.value.max_message_count = ${NEW_BATCHSIZE}" "${GENESIS_BLOCK_JSON}" > "${UPDATED_GENESIS_BLOCK_JSON}"
    33  
    34  pauseIfInteractive
    35  
    36  bigMsg "Re-encoding the updated genesis block"
    37  
    38  encode common.Block "${UPDATED_GENESIS_BLOCK_JSON}" "${UPDATED_GENESIS_BLOCK_PB}"
    39  
    40  bigMsg "Bootstrapping edit complete"