github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/bddtests/regression/go/ote/driver.sh (about) 1 #!/bin/bash 2 3 InvalidArgs=0 4 5 #init var 6 nBroker=0 7 nPeer=1 8 9 while getopts ":l:d:w:x:b:c:t:a:o:k:p:" opt; do 10 case $opt in 11 # peer environment options 12 l) 13 CORE_LOGGING_LEVEL=$OPTARG 14 export CORE_LOGGING_LEVEL=$CORE_LOGGING_LEVEL 15 echo "CORE_LOGGING_LEVEL: $CORE_LOGGING_LEVEL" 16 ;; 17 d) 18 db=$OPTARG 19 echo "ledger state database type: $db" 20 ;; 21 w) 22 CORE_SECURITY_LEVEL=$OPTARG 23 export CORE_SECURITY_LEVEL=$CORE_SECURITY_LEVEL 24 echo "CORE_SECURITY_LEVEL: $CORE_SECURITY_LEVEL" 25 ;; 26 x) 27 CORE_SECURITY_HASHALGORITHM=$OPTARG 28 export CORE_SECURITY_HASHALGORITHM=$CORE_SECURITY_HASHALGORITHM 29 echo "CORE_SECURITY_HASHALGORITHM: $CORE_SECURITY_HASHALGORITHM" 30 ;; 31 32 # orderer environment options 33 b) 34 CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT=$OPTARG 35 export CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT=$CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT 36 echo "CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT: $CONFIGTX_ORDERER_BATCHSIZE_MAXMESSAGECOUNT" 37 ;; 38 c) 39 CONFIGTX_ORDERER_BATCHTIMEOUT=$OPTARG 40 export CONFIGTX_ORDERER_BATCHTIMEOUT=$CONFIGTX_ORDERER_BATCHTIMEOUT 41 echo "CONFIGTX_ORDERER_BATCHTIMEOUT: $CONFIGTX_ORDERER_BATCHTIMEOUT" 42 ;; 43 t) 44 CONFIGTX_ORDERER_ORDERERTYPE=$OPTARG 45 export CONFIGTX_ORDERER_ORDERERTYPE=$CONFIGTX_ORDERER_ORDERERTYPE 46 echo "CONFIGTX_ORDERER_ORDERERTYPE: $CONFIGTX_ORDERER_ORDERERTYPE" 47 if [$nBroker == 0 ] && [ $CONFIGTX_ORDERER_ORDERERTYPE == 'kafka' ]; then 48 nBroker=1 # must have at least 1 49 fi 50 ;; 51 52 # network options 53 a) 54 Req=$OPTARG 55 echo "action: $Req" 56 ;; 57 k) 58 nBroker=$OPTARG 59 echo "# of Broker: $nBroker" 60 ;; 61 p) 62 nPeer=$OPTARG 63 echo "# of peer: $nPeer" 64 ;; 65 o) 66 nOrderer=$OPTARG 67 echo "# of orderer: $nOrderer" 68 ;; 69 70 # else 71 \?) 72 echo "Invalid option: -$OPTARG" >&2 73 InvalidArgs=1 74 ;; 75 :) 76 echo "Option -$OPTARG requires an argument." >&2 77 InvalidArgs=1 78 ;; 79 esac 80 done 81 82 83 if [ $InvalidArgs == 1 ]; then 84 echo "Usage: " 85 echo " ./driver.sh [opt] [value] " 86 echo " network variables" 87 echo " -a: action [create|add] " 88 echo " -p: number of peers " 89 echo " -o: number of orderers " 90 echo " -k: number of brokers " 91 echo " " 92 echo " peer environment variables" 93 echo " -l: core logging level [(deafult = not set)|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG]" 94 echo " -w: core security level [256|384]" 95 echo " -x: core security hash algorithm [SHA2|SHA3]" 96 echo " -d: core ledger state DB [goleveldb|couchdb] " 97 echo " " 98 echo " orderer environment variables" 99 echo " -b: batch size [10|msgs in batch/block]" 100 echo " -t: orderer type [solo|kafka] " 101 echo " -c: batch timeout [10s|max secs before send an unfilled batch] " 102 echo " " 103 exit 104 fi 105 106 if [ $nBroker -gt 0 ] && [ $CONFIGTX_ORDERER_ORDERERTYPE == 'solo' ]; then 107 echo "reset Kafka Broker number to 0 due to the CONFIGTX_ORDERER_ORDERERTYPE=$CONFIGTX_ORDERER_ORDERERTYPE" 108 nBroker=0 109 fi 110 111 #OS 112 ##OSName=`uname` 113 ##echo "Operating System: $OSName" 114 115 116 dbType=`echo "$db" | awk '{print tolower($0)}'` 117 echo "action=$Req nPeer=$nPeer nBroker=$nBroker nOrderer=$nOrderer dbType=$dbType" 118 VP=`docker ps -a | grep 'peer node start' | wc -l` 119 echo "existing peers: $VP" 120 121 122 echo "remove old docker-composer.yml" 123 rm -f docker-compose.yml 124 125 # form json input file 126 if [ $nBroker == 0 ]; then 127 #jsonFILE="network_solo.json" 128 jsonFILE="network.json" 129 else 130 # jsonFILE="network_kafka.json" 131 jsonFILE="network.json" 132 fi 133 echo "jsonFILE $jsonFILE" 134 135 # create docker compose yml 136 if [ $Req == "add" ]; then 137 N1=$[nPeer+VP] 138 N=$[N1] 139 VPN="peer"$[N-1] 140 else 141 N1=$nPeer 142 N=$[N1 - 1] 143 VPN="peer"$N 144 fi 145 146 ## echo "N1=$N1 VP=$VP nPeer=$nPeer VPN=$VPN" 147 148 node json2yml.js $jsonFILE $N1 $nOrderer $nBroker $dbType 149 150 ## sed 's/-x86_64/TEST/g' docker-compose.yml > ss.yml 151 ## cp ss.yml docker-compose.yml 152 # create network 153 if [ $Req == "create" ]; then 154 155 #CHANGED FROM ORIG SCRIPT 156 #docker-compose -f docker-compose.yml up -d --force-recreate $VPN cli 157 docker-compose -f docker-compose.yml up -d --force-recreate $VPN 158 for ((i=1; i<$nOrderer; i++)) 159 do 160 tmpOrd="orderer"$i 161 docker-compose -f docker-compose.yml up -d $tmpOrd 162 done 163 fi 164 165 if [ $Req == "add" ]; then 166 docker-compose -f docker-compose.yml up -d $VPN 167 168 fi 169 170 exit