github.com/IBM-Blockchain/fabric-operator@v1.0.4/sample-network/scripts/prereqs.sh (about) 1 #!/bin/bash 2 # 3 # Copyright contributors to the Hyperledger Fabric Operator project 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 # Licensed under the Apache License, Version 2.0 (the "License"); 8 # you may not use this file except in compliance with the License. 9 # You may obtain a copy of the License at: 10 # 11 # http://www.apache.org/licenses/LICENSE-2.0 12 # 13 # Unless required by applicable law or agreed to in writing, software 14 # distributed under the License is distributed on an "AS IS" BASIS, 15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 # See the License for the specific language governing permissions and 17 # limitations under the License. 18 # 19 20 # Double check that kind, kubectl, docker, and all required images are present. 21 function check_prereqs() { 22 23 set +e 24 25 ${CONTAINER_CLI} version > /dev/null 26 if [[ $? -ne 0 ]]; then 27 echo "No '${CONTAINER_CLI}' binary available?" 28 exit 1 29 fi 30 31 if [ "${CLUSTER_RUNTIME}" == "kind" ]; then 32 kind version > /dev/null 33 if [[ $? -ne 0 ]]; then 34 echo "No 'kind' binary available? (https://kind.sigs.k8s.io/docs/user/quick-start/#installation)" 35 exit 1 36 fi 37 fi 38 39 kubectl > /dev/null 40 if [[ $? -ne 0 ]]; then 41 echo "No 'kubectl' binary available? (https://kubernetes.io/docs/tasks/tools/)" 42 exit 1 43 fi 44 45 jq --version > /dev/null 46 if [[ $? -ne 0 ]]; then 47 echo "No 'jq' binary available? (https://stedolan.github.io/jq/)" 48 exit 1 49 fi 50 51 # Use the local fabric binaries if available. If not, go get them. 52 bin/peer version &> /dev/null 53 if [[ $? -ne 0 ]]; then 54 echo "Downloading LATEST Fabric binaries and config" 55 56 mkdir -p $TEMP_DIR 57 58 # The download / installation of binaries will also transfer a core.yaml, which overlaps with a local configuration. 59 # Pull the binaries into a temp folder and then move them into the target location. 60 (pushd $TEMP_DIR && curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/bootstrap.sh \ 61 | bash -s -- $FABRIC_VERSION $FABRIC_CA_VERSION -s -d) 62 mkdir bin && mv $TEMP_DIR/bin/* bin 63 64 # delete config files transferred by the installer 65 rm $TEMP_DIR/config/configtx.yaml 66 rm $TEMP_DIR/config/core.yaml 67 rm $TEMP_DIR/config/orderer.yaml 68 fi 69 70 export PATH=bin:$PATH 71 72 # Double-check that the binary transfer was OK 73 peer version > /dev/null 74 if [[ $? -ne 0 ]]; then 75 log "No 'peer' binary available?" 76 exit 1 77 fi 78 79 set -e 80 }