Skip to content

Commit

Permalink
Merge pull request #59 from hyperledger-labs/refactor/search-binaries
Browse files Browse the repository at this point in the history
Check for binaries on system
  • Loading branch information
samuelvenzi authored Feb 1, 2024
2 parents cbf76e2 + 44edf10 commit 489725d
Showing 1 changed file with 35 additions and 12 deletions.
47 changes: 35 additions & 12 deletions fabric/startDev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,45 @@ download_binaries(){
rm install-fabric.sh
}

FILE=bin
if [ ! -d "$FILE" ]; then
echo "Directory $FILE not found"
download_binaries
# Check PATH
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Binaries to check
fabric_binaries=("fabric-ca-client" "fabric-ca-server" "osnadmin" "configtxgen" "configtxlator" "cryptogen" "discover" "orderer" "peer")

all_binaries_exist() {
for binary in "${fabric_binaries[@]}"; do
if ! command_exists "$binary"; then
return 1
fi
done
return 0
}

if all_binaries_exist; then
echo "All Fabric binaries are available in the system path."
else
cd bin;
numFiles="$(ls -1 | wc -l)"
if [ "$numFiles" -ne 10 ];
then
cd ..
echo "Missing some fabric binaries"
echo "Some or all Fabric binaries are missing from the system path."

FILE=bin
if [ ! -d "$FILE" ]; then
echo "Directory $FILE not found"
download_binaries
else
cd ..
echo "Bin directory already exists"
cd bin
numFiles="$(ls -1 | wc -l)"
if [ "$numFiles" -ne 10 ]; then
cd ..
echo "Missing some fabric binaries in bin directory"
download_binaries
else
cd ..
fi
fi
fi
fi

docker network create cc-tools-demo-net
./network.sh up createChannel -n $ORG_QNTY
Expand Down

0 comments on commit 489725d

Please sign in to comment.