github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/Decentralized-Energy-Composer-master/fabric-dev-servers/fabric-scripts/hlfv11/startFabric.sh (about) 1 #!/bin/bash 2 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 # Exit on first error, print all commands. 16 set -e 17 18 Usage() { 19 echo "" 20 echo "Usage: ./startFabric.sh [-d || --dev]" 21 echo "" 22 echo "Options:" 23 echo -e "\t-d or --dev: (Optional) enable fabric development mode" 24 echo "" 25 echo "Example: ./startFabric.sh" 26 echo "" 27 exit 1 28 } 29 30 Parse_Arguments() { 31 while [ $# -gt 0 ]; do 32 case $1 in 33 --help) 34 HELPINFO=true 35 ;; 36 --dev | -d) 37 FABRIC_DEV_MODE=true 38 ;; 39 esac 40 shift 41 done 42 } 43 44 Parse_Arguments $@ 45 46 if [ "${HELPINFO}" == "true" ]; then 47 Usage 48 fi 49 50 #Detect architecture 51 ARCH=`uname -m` 52 53 # Grab the current directory 54 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 55 56 if [ "${FABRIC_DEV_MODE}" == "true" ]; then 57 DOCKER_FILE="${DIR}"/composer/docker-compose-dev.yml 58 else 59 DOCKER_FILE="${DIR}"/composer/docker-compose.yml 60 fi 61 62 ARCH=$ARCH docker-compose -f "${DOCKER_FILE}" down 63 ARCH=$ARCH docker-compose -f "${DOCKER_FILE}" up -d 64 65 # wait for Hyperledger Fabric to start 66 # incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number> 67 echo "sleeping for ${FABRIC_START_TIMEOUT} seconds to wait for fabric to complete start up" 68 sleep ${FABRIC_START_TIMEOUT} 69 70 # Create the channel 71 docker exec peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c composerchannel -f /etc/hyperledger/configtx/composer-channel.tx 72 73 # Join peer0.org1.example.com to the channel. 74 docker exec -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/Admin@org1.example.com/msp" peer0.org1.example.com peer channel join -b composerchannel.block 75 76 if [ "${FABRIC_DEV_MODE}" == "true" ]; then 77 echo "Fabric Network started in chaincode development mode" 78 fi