diff --git a/first-network/byfn.sh b/first-network/byfn.sh index 172f96d587..a6118e874b 100755 --- a/first-network/byfn.sh +++ b/first-network/byfn.sh @@ -105,8 +105,46 @@ function removeUnwantedImages() { fi } +# Versions of fabric known not to work with this release of first-network +BLACKLISTED_VERSIONS="^1\.0\. ^1\.1\.0-preview ^1\.1\.0-alpha" + +# Do some basic sanity checking to make sure that the appropriate versions of fabric +# binaries/images are available. In the future, additional checking for the presence +# of go or other items could be added. +function checkPrereqs() { + # Note, we check configtxlator externally because it does not require a config file, and peer in the + # docker image because of FAB-8551 that makes configtxlator return 'development version' in docker + LOCAL_VERSION=$(configtxlator version | sed -ne 's/ Version: //p') + DOCKER_IMAGE_VERSION=$(docker run --rm hyperledger/fabric-tools:$IMAGETAG peer version | sed -ne 's/ Version: //p'|head -1) + + echo "LOCAL_VERSION=$LOCAL_VERSION" + echo "DOCKER_IMAGE_VERSION=$DOCKER_IMAGE_VERSION" + + if [ "$LOCAL_VERSION" != "$DOCKER_IMAGE_VERSION" ] ; then + echo "=================== WARNING ===================" + echo " Local fabric binaries and docker images are " + echo " out of sync. This may cause problems. " + echo "===============================================" + fi + + for UNSUPPORTED_VERSION in $BLACKLISTED_VERSIONS ; do + echo "$LOCAL_VERSION" | grep -q $UNSUPPORTED_VERSION + if [ $? -eq 0 ] ; then + echo "ERROR! Local Fabric binary version of $LOCAL_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples." + exit 1 + fi + + echo "$DOCKER_IMAGE_VERSION" | grep -q $UNSUPPORTED_VERSION + if [ $? -eq 0 ] ; then + echo "ERROR! Fabric Docker image version of $DOCKER_IMAGE_VERSION does not match this newer version of BYFN and is unsupported. Either move to a later version of Fabric or checkout an earlier version of fabric-samples." + exit 1 + fi + done +} + # Generate the needed certificates, the genesis block and start the network. function networkUp () { + checkPrereqs # generate artifacts if they don't exist if [ ! -d "crypto-config" ]; then generateCerts