From b50611575b4acbe9efac768b4ff44426a5809375 Mon Sep 17 00:00:00 2001 From: Matthew B White Date: Tue, 8 Feb 2022 11:08:59 +0000 Subject: [PATCH] Make network.sh more tolerant (#634) The network.sh is dependent onbeing executed from the test-network directory This PR makes it a little more tolerant, and will add a bin directgory based on the location of the script - not just the PWD Signed-off-by: Matthew B White --- test-network/network.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test-network/network.sh b/test-network/network.sh index c6c3fdef..cb28ae23 100755 --- a/test-network/network.sh +++ b/test-network/network.sh @@ -12,10 +12,20 @@ # # prepending $PWD/../bin to PATH to ensure we are picking up the correct binaries # this may be commented out to resolve installed version of tools if desired -export PATH=${PWD}/../bin:$PATH +# +# However using PWD in the path has the side effect that location that +# this script is run from is critical. To ease this, get the directory +# this script is actually in and infer location from there. (putting first) + +ROOTDIR=$(cd "$(dirname "$0")" && pwd) +export PATH=${ROOTDIR}/../bin:${PWD}/../bin:$PATH export FABRIC_CFG_PATH=${PWD}/configtx export VERBOSE=false +# push to the required directory & set a trap to go back if needed +pushd ${ROOTDIR} > /dev/null +trap "popd > /dev/null" EXIT + . scripts/utils.sh # Obtain CONTAINER_IDS and remove them @@ -483,4 +493,3 @@ else printHelp exit 1 fi -