mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-26 11:35:10 +00:00
I tried to handle most (if not all) of the variables evaluations in the project that depends on $PWD by wrapping them in double-quotations to avoid values that contains white spaces.
Some lines I was not sure if they are Okay or not but I left them as they are. Samples (not all lines) as follows:
- commercial-paper/network-clean.sh:15:DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
- commercial-paper/network-starter.sh:15:DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
- asset-transfer-basic/chaincode-javascript/node_modules/fabric-shim/coverage/fabric-shim/lib/chaincode.js.html:997: optsCpy.pem = fs.readFileSync(process.env.CORE_PEER_TLS_ROOTCERT_FILE).toString();
- commercial-paper/organization/digibank/digibank.sh:29:export PEER_PARMS="${PEER_CONN_PARMS##*( )}"
The next sample I was not really sure, but still edited it:
- test-network/addOrg3/fabric-ca/registerEnroll.sh:68: cp ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/tlscacerts/* ${PWD}/../organizations/peerOrganizations/org3.example.com/peers/peer0.org3.example.com/tls/ca.crt
I deliberately ignored some lines because I think they are not problem. These lines include:
- `export` sentences
- assignment sentences like: test-network/scripts/createChannel.sh:48: FABRIC_CFG_PATH=$PWD/../config/
- gradlew files: the line SAVED="`pwd`"
- gradlew files: the line APP_HOME="`pwd -P`"
- gradlew files: the line CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
Signed-off-by: Waleed Mortaja <waleedmortaja@protonmail.com>
58 lines
1.9 KiB
Bash
Executable file
58 lines
1.9 KiB
Bash
Executable file
#!/bin/bash
|
|
#
|
|
# Copyright IBM Corp. All Rights Reserved.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
# import utils
|
|
. scripts/envVar.sh
|
|
. scripts/configUpdate.sh
|
|
|
|
|
|
# NOTE: this must be run in a CLI container since it requires jq and configtxlator
|
|
createAnchorPeerUpdate() {
|
|
infoln "Fetching channel config for channel $CHANNEL_NAME"
|
|
fetchChannelConfig $ORG $CHANNEL_NAME ${CORE_PEER_LOCALMSPID}config.json
|
|
|
|
infoln "Generating anchor peer update transaction for Org${ORG} on channel $CHANNEL_NAME"
|
|
|
|
if [ $ORG -eq 1 ]; then
|
|
HOST="peer0.org1.example.com"
|
|
PORT=7051
|
|
elif [ $ORG -eq 2 ]; then
|
|
HOST="peer0.org2.example.com"
|
|
PORT=9051
|
|
elif [ $ORG -eq 3 ]; then
|
|
HOST="peer0.org3.example.com"
|
|
PORT=11051
|
|
else
|
|
errorln "Org${ORG} unknown"
|
|
fi
|
|
|
|
set -x
|
|
# Modify the configuration to append the anchor peer
|
|
jq '.channel_group.groups.Application.groups.'${CORE_PEER_LOCALMSPID}'.values += {"AnchorPeers":{"mod_policy": "Admins","value":{"anchor_peers": [{"host": "'$HOST'","port": '$PORT'}]},"version": "0"}}' ${CORE_PEER_LOCALMSPID}config.json > ${CORE_PEER_LOCALMSPID}modified_config.json
|
|
{ set +x; } 2>/dev/null
|
|
|
|
# Compute a config update, based on the differences between
|
|
# {orgmsp}config.json and {orgmsp}modified_config.json, write
|
|
# it as a transaction to {orgmsp}anchors.tx
|
|
createConfigUpdate ${CHANNEL_NAME} ${CORE_PEER_LOCALMSPID}config.json ${CORE_PEER_LOCALMSPID}modified_config.json ${CORE_PEER_LOCALMSPID}anchors.tx
|
|
}
|
|
|
|
updateAnchorPeer() {
|
|
peer channel update -o orderer.example.com:7050 --ordererTLSHostnameOverride orderer.example.com -c $CHANNEL_NAME -f ${CORE_PEER_LOCALMSPID}anchors.tx --tls --cafile "$ORDERER_CA" >&log.txt
|
|
res=$?
|
|
cat log.txt
|
|
verifyResult $res "Anchor peer update failed"
|
|
successln "Anchor peer set for org '$CORE_PEER_LOCALMSPID' on channel '$CHANNEL_NAME'"
|
|
}
|
|
|
|
ORG=$1
|
|
CHANNEL_NAME=$2
|
|
setGlobalsCLI $ORG
|
|
|
|
createAnchorPeerUpdate
|
|
|
|
updateAnchorPeer
|