diff --git a/first-network/byfn.sh b/first-network/byfn.sh index c9129e82ab..0e68afc46d 100755 --- a/first-network/byfn.sh +++ b/first-network/byfn.sh @@ -317,8 +317,9 @@ function generateCerts (){ fi set -x cryptogen generate --config=./crypto-config.yaml + res=$? set +x - if [ "$?" -ne 0 ]; then + if [ $res -ne 0 ]; then echo "Failed to generate certificates..." exit 1 fi @@ -377,8 +378,9 @@ function generateChannelArtifacts() { # named orderer.genesis.block or the orderer will fail to launch! set -x configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block + res=$? set +x - if [ "$?" -ne 0 ]; then + if [ $res -ne 0 ]; then echo "Failed to generate orderer genesis block..." exit 1 fi @@ -388,8 +390,9 @@ function generateChannelArtifacts() { echo "#################################################################" set -x configtxgen -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME + res=$? set +x - if [ "$?" -ne 0 ]; then + if [ $res -ne 0 ]; then echo "Failed to generate channel configuration transaction..." exit 1 fi @@ -400,8 +403,9 @@ function generateChannelArtifacts() { echo "#################################################################" set -x configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP + res=$? set +x - if [ "$?" -ne 0 ]; then + if [ $res -ne 0 ]; then echo "Failed to generate anchor peer update for Org1MSP..." exit 1 fi @@ -413,8 +417,9 @@ function generateChannelArtifacts() { set -x configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate \ ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP + res=$? set +x - if [ "$?" -ne 0 ]; then + if [ $res -ne 0 ]; then echo "Failed to generate anchor peer update for Org2MSP..." exit 1 fi diff --git a/first-network/eyfn.sh b/first-network/eyfn.sh index a811d56da3..b6783aacec 100755 --- a/first-network/eyfn.sh +++ b/first-network/eyfn.sh @@ -186,8 +186,9 @@ function generateCerts (){ (cd org3-artifacts set -x cryptogen generate --config=./org3-crypto.yaml + res=$? set +x - if [ "$?" -ne 0 ]; then + if [ $res -ne 0 ]; then echo "Failed to generate certificates..." exit 1 fi @@ -209,8 +210,9 @@ function generateChannelArtifacts() { export FABRIC_CFG_PATH=$PWD set -x configtxgen -printOrg Org3MSP > ../channel-artifacts/org3.json + res=$? set +x - if [ "$?" -ne 0 ]; then + if [ $res -ne 0 ]; then echo "Failed to generate Org3 config material..." exit 1 fi diff --git a/first-network/scripts/script.sh b/first-network/scripts/script.sh index 4e0b6ab446..5762cb253f 100755 --- a/first-network/scripts/script.sh +++ b/first-network/scripts/script.sh @@ -38,11 +38,14 @@ createChannel() { if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then set -x peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx >&log.txt + res=$? set +x else + set -x peer channel create -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt + res=$? + set +x fi - res=$? cat log.txt verifyResult $res "Channel creation failed" echo "===================== Channel \"$CHANNEL_NAME\" is created successfully ===================== " diff --git a/first-network/scripts/step2org3.sh b/first-network/scripts/step2org3.sh index 0ffaa01ddf..41268c4b40 100755 --- a/first-network/scripts/step2org3.sh +++ b/first-network/scripts/step2org3.sh @@ -38,8 +38,8 @@ fi echo "Fetching channel config block from orderer..." set -x peer channel fetch 0 $CHANNEL_NAME.block -o orderer.example.com:7050 -c $CHANNEL_NAME --tls --cafile $ORDERER_CA >&log.txt -set +x res=$? +set +x cat log.txt verifyResult $res "Fetching config block from orderer has Failed" diff --git a/first-network/scripts/upgrade_to_v11.sh b/first-network/scripts/upgrade_to_v11.sh index bb980db98a..69eb2fbda2 100755 --- a/first-network/scripts/upgrade_to_v11.sh +++ b/first-network/scripts/upgrade_to_v11.sh @@ -87,13 +87,14 @@ addCapabilityToChannel() { if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then set -x peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --cafile $ORDERER_CA + res=$? set +x else set -x peer channel update -f config_update_in_envelope.pb -c $CH_NAME -o orderer.example.com:7050 --tls true --cafile $ORDERER_CA + res=$? set +x fi - res=$? verifyResult $res "Config update for \"$GROUP\" on \"$CH_NAME\" failed" echo "===================== Config update for \"$GROUP\" on \"$CH_NAME\" is completed ===================== " diff --git a/first-network/scripts/utils.sh b/first-network/scripts/utils.sh index 305a810383..7509147e3b 100755 --- a/first-network/scripts/utils.sh +++ b/first-network/scripts/utils.sh @@ -71,13 +71,14 @@ updateAnchorPeers() { if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then set -x peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx >&log.txt + res=$? set +x else set -x peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/${CORE_PEER_LOCALMSPID}anchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA >&log.txt + res=$? set +x fi - res=$? cat log.txt verifyResult $res "Anchor peer update failed" echo "===================== Anchor peers for org \"$CORE_PEER_LOCALMSPID\" on \"$CHANNEL_NAME\" is updated successfully ===================== " @@ -93,8 +94,8 @@ joinChannelWithRetry () { set -x peer channel join -b $CHANNEL_NAME.block >&log.txt - set +x res=$? + set +x cat log.txt if [ $res -ne 0 -a $COUNTER -lt $MAX_RETRY ]; then COUNTER=` expr $COUNTER + 1` @@ -114,8 +115,8 @@ installChaincode () { VERSION=${3:-1.0} set -x peer chaincode install -n mycc -v ${VERSION} -l ${LANGUAGE} -p ${CC_SRC_PATH} >&log.txt - set +x res=$? + set +x cat log.txt verifyResult $res "Chaincode installation on peer${PEER}.org${ORG} has Failed" echo "===================== Chaincode is installed on peer${PEER}.org${ORG} ===================== " @@ -133,13 +134,14 @@ instantiateChaincode () { if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then set -x peer chaincode instantiate -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v ${VERSION} -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt + res=$? set +x else set -x peer chaincode instantiate -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -l ${LANGUAGE} -v 1.0 -c '{"Args":["init","a","100","b","200"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer')" >&log.txt + res=$? set +x fi - res=$? cat log.txt verifyResult $res "Chaincode instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' failed" echo "===================== Chaincode Instantiation on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== " @@ -153,8 +155,8 @@ upgradeChaincode () { set -x peer chaincode upgrade -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -v 2.0 -c '{"Args":["init","a","90","b","210"]}' -P "OR ('Org1MSP.peer','Org2MSP.peer','Org3MSP.peer')" - set +x res=$? + set +x cat log.txt verifyResult $res "Chaincode upgrade on org${ORG} peer${PEER} has Failed" echo "===================== Chaincode is upgraded on org${ORG} peer${PEER} ===================== " @@ -178,8 +180,9 @@ chaincodeQuery () { echo "Attempting to Query peer${PEER}.org${ORG} ...$(($(date +%s)-starttime)) secs" set -x peer chaincode query -C $CHANNEL_NAME -n mycc -c '{"Args":["query","a"]}' >&log.txt + res=$? set +x - test $? -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}') + test $res -eq 0 && VALUE=$(cat log.txt | awk '/Query Result/ {print $NF}') test "$VALUE" = "$EXPECTED_RESULT" && let rc=0 done echo @@ -257,13 +260,14 @@ chaincodeInvoke () { if [ -z "$CORE_PEER_TLS_ENABLED" -o "$CORE_PEER_TLS_ENABLED" = "false" ]; then set -x peer chaincode invoke -o orderer.example.com:7050 -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt + res=$? set +x else set -x peer chaincode invoke -o orderer.example.com:7050 --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -C $CHANNEL_NAME -n mycc -c '{"Args":["invoke","a","b","10"]}' >&log.txt + res=$? set +x fi - res=$? cat log.txt verifyResult $res "Invoke execution on peer${PEER}.org${ORG} failed " echo "===================== Invoke transaction on peer${PEER}.org${ORG} on channel '$CHANNEL_NAME' is successful ===================== "