|
6 | 6 | #
|
7 | 7 |
|
8 | 8 | # if version not passed in, default to latest released version
|
9 |
| -export VERSION=${1:-1.1.0} |
| 9 | +export VERSION=1.1.0 |
10 | 10 | # if ca version not passed in, default to latest released version
|
11 |
| -export CA_VERSION=${2:-$VERSION} |
| 11 | +export CA_VERSION=$VERSION |
12 | 12 | # current version of thirdparty images (couchdb, kafka and zookeeper) released
|
13 | 13 | export THIRDPARTY_IMAGE_VERSION=0.4.6
|
14 | 14 | export ARCH=$(echo "$(uname -s|tr '[:upper:]' '[:lower:]'|sed 's/mingw64_nt.*/windows/')-$(uname -m | sed 's/x86_64/amd64/g')" | awk '{print tolower($0)}')
|
15 | 15 | #Set MARCH variable i.e ppc64le,s390x,x86_64,i386
|
16 | 16 | MARCH=`uname -m`
|
17 | 17 |
|
| 18 | +printHelp() { |
| 19 | + echo "Usage: bootstrap.sh [<version>] [<ca_version>] [-d -s -b]" |
| 20 | + echo |
| 21 | + echo "-d - bypass docker image download" |
| 22 | + echo "-s - bypass fabric-samples repo clone" |
| 23 | + echo "-b - bypass download of platform-specific binaries" |
| 24 | + echo |
| 25 | + echo "e.g. bootstrap.sh 1.1.1 -s" |
| 26 | + echo "would download docker images and binaries for version 1.1.1" |
| 27 | +} |
| 28 | + |
18 | 29 | dockerFabricPull() {
|
19 | 30 | local FABRIC_TAG=$1
|
20 | 31 | for IMAGES in peer orderer ccenv javaenv tools; do
|
@@ -47,36 +58,101 @@ dockerCaPull() {
|
47 | 58 | : ${FABRIC_TAG:="$MARCH-$VERSION"}
|
48 | 59 | : ${THIRDPARTY_TAG:="$MARCH-$THIRDPARTY_IMAGE_VERSION"}
|
49 | 60 |
|
50 |
| -echo "===> Downloading platform specific fabric binaries" |
51 |
| -curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz |
| 61 | +samplesInstall() { |
| 62 | + # clone (if needed) hyperledger/fabric-samples and checkout corresponding |
| 63 | + # version to the binaries and docker images to be downloaded |
| 64 | + if [ -d first-network ]; then |
| 65 | + # if we are in the fabric-samples repo, checkout corresponding version |
| 66 | + echo "===> Checking out v${VERSION} branch of hyperledger/fabric-samples" |
| 67 | + git checkout v${VERSION} |
| 68 | + elif [ -d fabric-samples ]; then |
| 69 | + # if fabric-samples repo already cloned and in current directory, |
| 70 | + # cd fabric-samples and checkout corresponding version |
| 71 | + echo "===> Checking out v${VERSION} branch of hyperledger/fabric-samples" |
| 72 | + cd fabric-samples && git checkout v${VERSION} |
| 73 | + else |
| 74 | + echo "===> Cloning hyperledger/fabric-samples repo and checkout v${VERSION}" |
| 75 | + git clone -b master https://github.com/hyperledger/fabric-samples.git && cd fabric-samples && git checkout v${VERSION} |
| 76 | + fi |
| 77 | +} |
| 78 | + |
| 79 | +binariesInstall() { |
| 80 | + echo "===> Downloading version ${FABRIC_TAG} platform specific fabric binaries" |
| 81 | + curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/${ARCH}-${VERSION}/hyperledger-fabric-${ARCH}-${VERSION}.tar.gz | tar xz |
52 | 82 |
|
53 |
| -echo "===> Downloading platform specific fabric-ca-client binary" |
54 |
| -curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${VERSION}/hyperledger-fabric-ca-${ARCH}-${VERSION}.tar.gz | tar xz |
55 |
| -if [ $? != 0 ]; then |
| 83 | + echo "===> Downloading version ${CA_TAG} platform specific fabric-ca-client binary" |
| 84 | + curl https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric-ca/hyperledger-fabric-ca/${ARCH}-${VERSION}/hyperledger-fabric-ca-${ARCH}-${VERSION}.tar.gz | tar xz |
| 85 | + if [ $? != 0 ]; then |
56 | 86 | echo
|
57 |
| - echo "------> $VERSION fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----" |
| 87 | + echo "------> ${CA_TAG} fabric-ca-client binary is not available to download (Avaialble from 1.1.0-rc1) <----" |
58 | 88 | echo
|
59 |
| -fi |
60 |
| - |
61 |
| -which docker >& /dev/null |
62 |
| -NODOCKER=$? |
| 89 | + fi |
| 90 | +} |
63 | 91 |
|
64 |
| -if [ "${NODOCKER}" == 0 ]; then |
| 92 | +dockerInstall() { |
| 93 | + which docker >& /dev/null |
| 94 | + NODOCKER=$? |
| 95 | + if [ "${NODOCKER}" == 0 ]; then |
| 96 | + echo "===> Pulling fabric Images" |
| 97 | + dockerFabricPull ${FABRIC_TAG} |
| 98 | + echo "===> Pulling fabric ca Image" |
| 99 | + dockerCaPull ${CA_TAG} |
| 100 | + echo "===> Pulling thirdparty docker images" |
| 101 | + dockerThirdPartyImagesPull ${THIRDPARTY_TAG} |
| 102 | + echo |
| 103 | + echo "===> List out hyperledger docker images" |
| 104 | + docker images | grep hyperledger* |
| 105 | + else |
| 106 | + echo "=========================================================" |
| 107 | + echo "Docker not installed, bypassing download of Fabric images" |
| 108 | + echo "=========================================================" |
| 109 | + fi |
| 110 | +} |
65 | 111 |
|
66 |
| - echo "===> Pulling fabric Images" |
67 |
| - dockerFabricPull ${FABRIC_TAG} |
| 112 | +DOCKER=true |
| 113 | +SAMPLES=true |
| 114 | +BINARIES=true |
68 | 115 |
|
69 |
| - echo "===> Pulling fabric ca Image" |
70 |
| - dockerCaPull ${CA_TAG} |
| 116 | +# Parse commandline args pull out |
| 117 | +# version and/or ca-version strings first |
| 118 | +if echo $1 | grep -q '\d'; then |
| 119 | + VERSION=$1;shift |
| 120 | + if echo $1 | grep -q '\d'; then |
| 121 | + CA_VERSION=$1;shift |
| 122 | + fi |
| 123 | +fi |
71 | 124 |
|
72 |
| - echo "===> Pulling thirdparty docker images" |
73 |
| - dockerThirdPartyImagesPull ${THIRDPARTY_TAG} |
74 |
| - echo |
| 125 | +# then parse opts |
| 126 | +while getopts "h?dsb" opt; do |
| 127 | + case "$opt" in |
| 128 | + h|\?) |
| 129 | + printHelp |
| 130 | + exit 0 |
| 131 | + ;; |
| 132 | + d) DOCKER=false |
| 133 | + ;; |
| 134 | + s) SAMPLES=false |
| 135 | + ;; |
| 136 | + b) BINARIES=false |
| 137 | + ;; |
| 138 | + esac |
| 139 | +done |
75 | 140 |
|
76 |
| - echo "===> List out hyperledger docker images" |
77 |
| - docker images | grep hyperledger* |
78 |
| -else |
79 |
| - echo "=========================================================" |
80 |
| - echo "Docker not installed, bypassing download of Fabric images" |
81 |
| - echo "=========================================================" |
| 141 | +if [ "$SAMPLES" == "true" ]; then |
| 142 | + echo |
| 143 | + echo "Installing hyperledger/fabric-samples repo" |
| 144 | + echo |
| 145 | + samplesInstall |
| 146 | +fi |
| 147 | +if [ "$BINARIES" == "true" ]; then |
| 148 | + echo |
| 149 | + echo "Installing Hyperledger Fabric binaries" |
| 150 | + echo |
| 151 | + binariesInstall |
| 152 | +fi |
| 153 | +if [ "$DOCKER" == "true" ]; then |
| 154 | + echo |
| 155 | + echo "Installing Hyperledger Fabric docker images" |
| 156 | + echo |
| 157 | + dockerInstall |
82 | 158 | fi
|
0 commit comments