Skip to content

Commit

Permalink
Merge "FAB-16812 Update bootstrap script"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Yellick authored and Gerrit Code Review committed Nov 22, 2019
2 parents 2869d92 + 8105eff commit ef4b79f
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,24 @@ printHelp() {
echo "would download docker images and binaries for version 1.4.4"
}

# dockerFabricPull() pulls docker images from fabric and chaincode repositories
# dockerPull() pulls docker images from fabric and chaincode repositories
# note, if a docker image doesn't exist for a requested release, it will simply
# be skipped, since this script doesn't terminate upon errors.
dockerFabricPull() {
local FABRIC_TAG=$1
for IMAGES in peer orderer ccenv tools baseos nodeenv javaenv; do
echo "==> FABRIC IMAGE: $IMAGES"
echo
docker pull "hyperledger/fabric-$IMAGES:$FABRIC_TAG"
docker tag "hyperledger/fabric-$IMAGES:$FABRIC_TAG" "hyperledger/fabric-$IMAGES"
done
}

dockerThirdPartyImagesPull() {
local THIRDPARTY_TAG=$1
for IMAGES in couchdb kafka zookeeper; do
echo "==> THIRDPARTY DOCKER IMAGE: $IMAGES"
echo
docker pull "hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG"
docker tag "hyperledger/fabric-$IMAGES:$THIRDPARTY_TAG" "hyperledger/fabric-$IMAGES"
dockerPull() {
image_tag=$1
shift
while [[ $# -gt 0 ]]
do
image_name="$1"
echo "====> hyperledger/fabric-$image_name:$image_tag"
docker pull "hyperledger/fabric-$image_name:$image_tag"
docker tag "hyperledger/fabric-$image_name:$image_tag" "hyperledger/fabric-$image_name"
shift
done
}

dockerCaPull() {
local CA_TAG=$1
echo "==> FABRIC CA IMAGE"
echo
docker pull "hyperledger/fabric-ca:$CA_TAG"
docker tag "hyperledger/fabric-ca:$CA_TAG" "hyperledger/fabric-ca"
}

samplesInstall() {
cloneSamplesRepo() {
# clone (if needed) hyperledger/fabric-samples and checkout corresponding
# version to the binaries and docker images to be downloaded
if [ -d first-network ]; then
Expand Down Expand Up @@ -90,7 +76,7 @@ download() {
fi
}

binariesInstall() {
pullBinaries() {
echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries"
download "${BINARY_FILE}" "https://github.com/hyperledger/fabric/releases/download/v${VERSION}/${BINARY_FILE}"
if [ $? -eq 22 ]; then
Expand All @@ -110,16 +96,30 @@ binariesInstall() {
fi
}

dockerInstall() {
pullDockerImages() {
command -v docker >& /dev/null
NODOCKER=$?
if [ "${NODOCKER}" == 0 ]; then
FABRIC_IMAGES=(peer orderer ccenv tools)
case "$VERSION" in
1.*)
FABRIC_IMAGES+=(javaenv)
shift
;;
2.*)
FABRIC_IMAGES+=(nodeenv baseos javaenv)
shift
;;
esac
echo "FABRIC_IMAGES:" "${FABRIC_IMAGES[@]}"
echo "===> Pulling fabric Images"
dockerFabricPull "${FABRIC_TAG}"
dockerPull "${FABRIC_TAG}" "${FABRIC_IMAGES[@]}"
echo "===> Pulling fabric ca Image"
dockerCaPull "${CA_TAG}"
CA_IMAGE=(ca)
dockerPull "${CA_TAG}" "${CA_IMAGE[@]}"
echo "===> Pulling thirdparty docker images"
dockerThirdPartyImagesPull "${THIRDPARTY_TAG}"
THIRDPARTY_IMAGES=(zookeeper kafka couchdb)
dockerPull "${THIRDPARTY_TAG}" "${THIRDPARTY_IMAGES[@]}"
echo
echo "===> List out hyperledger docker images"
docker images | grep hyperledger
Expand Down Expand Up @@ -179,19 +179,19 @@ done

if [ "$SAMPLES" == "true" ]; then
echo
echo "Installing hyperledger/fabric-samples repo"
echo "Clone hyperledger/fabric-samples repo"
echo
samplesInstall
cloneSamplesRepo
fi
if [ "$BINARIES" == "true" ]; then
echo
echo "Installing Hyperledger Fabric binaries"
echo "Pull Hyperledger Fabric binaries"
echo
binariesInstall
pullBinaries
fi
if [ "$DOCKER" == "true" ]; then
echo
echo "Installing Hyperledger Fabric docker images"
echo "Pull Hyperledger Fabric docker images"
echo
dockerInstall
pullDockerImages
fi

0 comments on commit ef4b79f

Please sign in to comment.