Skip to content

Commit

Permalink
update setup to touch all required files
Browse files Browse the repository at this point in the history
Signed-off-by: munapower <mmunaro@hotmail.com>
  • Loading branch information
munapower committed Jul 19, 2024
1 parent 818db30 commit 7ead437
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion samples/deployment/test-network/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ backup() {
echo "Prepare fabric samples test-network for FPC"

FABRIC_SAMPLES=${FPC_PATH}/samples/deployment/test-network/fabric-samples
CORE_PATH=${FABRIC_SAMPLES}/config/core.yaml
CORE_PATH=${FABRIC_SAMPLES}/test-network/compose/docker/peercfg/core.yaml
DOCKER_PATH=${FABRIC_SAMPLES}/test-network/compose/docker
DOCKER_COMPOSE_TEST_NET=${DOCKER_PATH}/docker-compose-test-net.yaml
DOCKER_COMPOSE_CA=${DOCKER_PATH}/docker-compose-ca.yaml
COMPOSE_PATH=${FABRIC_SAMPLES}/test-network/compose
COMPOSE_TEST_NET=${COMPOSE_PATH}/compose-test-net.yaml
COMPOSE_CA=${COMPOSE_PATH}/compose-ca.yaml

if [ ! -d "${FABRIC_SAMPLES}/bin" ]; then
echo "Error: no fabric binaries found, see README.md"
Expand Down Expand Up @@ -60,18 +63,23 @@ yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' -i ${CORE_PATH} co
if [ ! -z ${DOCKERD_FPC_PATH+x} ]; then
echo "Oo we are in docker mode! we need to use the host fpc path"
FPC_PATH_HOST=${DOCKERD_FPC_PATH}
COMPOSE_PATH_HOST=${DOCKERD_FPC_PATH}
else
FPC_PATH_HOST=${FPC_PATH}
COMPOSE_PATH_HOST=${FPC_PATH}
fi
echo "set FPC_PATH_HOST = ${FPC_PATH_HOST}"
echo "set COMPOSE_PATH_HOST = ${COMPOSE_PATH_HOST}"

FABRIC_SAMPLES_HOST=${FPC_PATH_HOST}/samples/deployment/test-network/fabric-samples
COMPOSE_HOST=${COMPOSE_PATH_HOST}/samples/deployment/test-network/fabric-samples/test-network/compose

echo "Resolving relative docker volume paths in ..."

echo "${DOCKER_COMPOSE_TEST_NET}"
backup ${DOCKER_COMPOSE_TEST_NET}
sed -i "s+\.\./+${FABRIC_SAMPLES_HOST}/test-network/+g" "${DOCKER_COMPOSE_TEST_NET}"
sed -i "s+\./+${COMPOSE_HOST}/test-network/+g" "${DOCKER_COMPOSE_TEST_NET}"

echo "${DOCKER_COMPOSE_CA}"
backup ${DOCKER_COMPOSE_CA}
Expand All @@ -84,6 +92,23 @@ for p in "${peers[@]}"; do
yq ".services.\"$p\".volumes += [\"${FABRIC_SAMPLES_HOST}/config/core.yaml:/etc/hyperledger/fabric/core.yaml\"]" -i "${DOCKER_COMPOSE_TEST_NET}"
done

echo "Now modifying the files in ..."

echo "${COMPOSE_TEST_NET}"
backup ${COMPOSE_TEST_NET}
sed -i "s+\.\./+${FABRIC_SAMPLES_HOST}/test-network/+g" "${COMPOSE_TEST_NET}"

echo "${COMPOSE_CA}"
backup ${COMPOSE_CA}
sed -i "s+\.\./+${FABRIC_SAMPLES_HOST}/test-network/+g" "${COMPOSE_CA}"

echo "${COMPOSE_TEST_NET}"
peers=("peer0.org1.example.com" "peer0.org2.example.com")
for p in "${peers[@]}"; do
yq ".services.\"$p\".volumes += [\"${FPC_PATH_HOST}:/opt/gopath/src/github.com/hyperledger/fabric-private-chaincode\"]" -i "${COMPOSE_TEST_NET}"
yq ".services.\"$p\".volumes += [\"${FABRIC_SAMPLES_HOST}/config/core.yaml:/etc/hyperledger/fabric/core.yaml\"]" -i "${COMPOSE_TEST_NET}"
done

###############################################
# setup blockchain explorer
###############################################
Expand Down

0 comments on commit 7ead437

Please sign in to comment.