addOrg4.sh

This commit is contained in:
Kurt Seifried 2021-03-10 09:43:04 -07:00
parent 862b7a86cd
commit 8320010b8c
No known key found for this signature in database
GPG key ID: F15CADC4A00F8174
2 changed files with 55 additions and 49 deletions

View file

@ -20,11 +20,11 @@ export VERBOSE=false
# Print the usage message # Print the usage message
function printHelp () { function printHelp () {
echo "Usage: " echo "Usage: "
echo " addOrg3.sh up|down|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]" echo " addOrg4.sh up|down|generate [-c <channel name>] [-t <timeout>] [-d <delay>] [-f <docker-compose-file>] [-s <dbtype>]"
echo " addOrg3.sh -h|--help (print this message)" echo " addOrg4.sh -h|--help (print this message)"
echo " <mode> - one of 'up', 'down', or 'generate'" echo " <mode> - one of 'up', 'down', or 'generate'"
echo " - 'up' - add org3 to the sample network. You need to bring up the test network and create a channel first." echo " - 'up' - add org4 to the sample network. You need to bring up the test network and create a channel first."
echo " - 'down' - bring down the test network and org3 nodes" echo " - 'down' - bring down the test network and org4 nodes"
echo " - 'generate' - generate required certificates and org definition" echo " - 'generate' - generate required certificates and org definition"
echo " -c <channel name> - test network channel name (defaults to \"mychannel\")" echo " -c <channel name> - test network channel name (defaults to \"mychannel\")"
echo " -ca <use CA> - Use a CA to generate the crypto material" echo " -ca <use CA> - Use a CA to generate the crypto material"
@ -36,14 +36,14 @@ function printHelp () {
echo "Typically, one would first generate the required certificates and " echo "Typically, one would first generate the required certificates and "
echo "genesis block, then bring up the network. e.g.:" echo "genesis block, then bring up the network. e.g.:"
echo echo
echo " addOrg3.sh generate" echo " addOrg4.sh generate"
echo " addOrg3.sh up" echo " addOrg4.sh up"
echo " addOrg3.sh up -c mychannel -s couchdb" echo " addOrg4.sh up -c mychannel -s couchdb"
echo " addOrg3.sh down" echo " addOrg4.sh down"
echo echo
echo "Taking all defaults:" echo "Taking all defaults:"
echo " addOrg3.sh up" echo " addOrg4.sh up"
echo " addOrg3.sh down" echo " addOrg4.sh down"
} }
# We use the cryptogen tool to generate the cryptographic material # We use the cryptogen tool to generate the cryptographic material
@ -51,7 +51,7 @@ function printHelp () {
# be put in the organizations folder with org1 and org2 # be put in the organizations folder with org1 and org2
# Create Organziation crypto material using cryptogen or CAs # Create Organziation crypto material using cryptogen or CAs
function generateOrg3() { function generateOrg4() {
# Create crypto material using cryptogen # Create crypto material using cryptogen
if [ "$CRYPTO" == "cryptogen" ]; then if [ "$CRYPTO" == "cryptogen" ]; then
which cryptogen which cryptogen
@ -60,10 +60,10 @@ function generateOrg3() {
fi fi
infoln "Generating certificates using cryptogen tool" infoln "Generating certificates using cryptogen tool"
infoln "Creating Org3 Identities" infoln "Creating Org4 Identities"
set -x set -x
cryptogen generate --config=org3-crypto.yaml --output="../organizations" cryptogen generate --config=org4-crypto.yaml --output="../organizations"
res=$? res=$?
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
if [ $res -ne 0 ]; then if [ $res -ne 0 ]; then
@ -84,78 +84,78 @@ function generateOrg3() {
fi fi
infoln "Generating certificates using Fabric CA" infoln "Generating certificates using Fabric CA"
docker-compose -f $COMPOSE_FILE_CA_ORG3 up -d 2>&1 docker-compose -f $COMPOSE_FILE_CA_ORG4 up -d 2>&1
. fabric-ca/registerEnroll.sh . fabric-ca/registerEnroll.sh
sleep 10 sleep 10
infoln "Creating Org3 Identities" infoln "Creating Org4 Identities"
createOrg3 createOrg4
fi fi
infoln "Generating CCP files for Org3" infoln "Generating CCP files for Org4"
./ccp-generate.sh ./ccp-generate.sh
} }
# Generate channel configuration transaction # Generate channel configuration transaction
function generateOrg3Definition() { function generateOrg4Definition() {
which configtxgen which configtxgen
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
fatalln "configtxgen tool not found. exiting" fatalln "configtxgen tool not found. exiting"
fi fi
infoln "Generating Org3 organization definition" infoln "Generating Org4 organization definition"
export FABRIC_CFG_PATH=$PWD export FABRIC_CFG_PATH=$PWD
set -x set -x
configtxgen -printOrg Org3MSP > ../organizations/peerOrganizations/org3.example.com/org3.json configtxgen -printOrg Org4MSP > ../organizations/peerOrganizations/org4.example.com/org4.json
res=$? res=$?
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
if [ $res -ne 0 ]; then if [ $res -ne 0 ]; then
fatalln "Failed to generate Org3 organization definition..." fatalln "Failed to generate Org4 organization definition..."
fi fi
} }
function Org3Up () { function Org4Up () {
# start org3 nodes # start org4 nodes
if [ "${DATABASE}" == "couchdb" ]; then if [ "${DATABASE}" == "couchdb" ]; then
docker-compose -f $COMPOSE_FILE_ORG3 -f $COMPOSE_FILE_COUCH_ORG3 up -d 2>&1 docker-compose -f $COMPOSE_FILE_ORG4 -f $COMPOSE_FILE_COUCH_ORG4 up -d 2>&1
else else
docker-compose -f $COMPOSE_FILE_ORG3 up -d 2>&1 docker-compose -f $COMPOSE_FILE_ORG4 up -d 2>&1
fi fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
fatalln "ERROR !!!! Unable to start Org3 network" fatalln "ERROR !!!! Unable to start Org4 network"
fi fi
} }
# Generate the needed certificates, the genesis block and start the network. # Generate the needed certificates, the genesis block and start the network.
function addOrg3 () { function addOrg4 () {
# If the test network is not up, abort # If the test network is not up, abort
if [ ! -d ../organizations/ordererOrganizations ]; then if [ ! -d ../organizations/ordererOrganizations ]; then
fatalln "ERROR: Please, run ./network.sh up createChannel first." fatalln "ERROR: Please, run ./network.sh up createChannel first."
fi fi
# generate artifacts if they don't exist # generate artifacts if they don't exist
if [ ! -d "../organizations/peerOrganizations/org3.example.com" ]; then if [ ! -d "../organizations/peerOrganizations/org4.example.com" ]; then
generateOrg3 generateOrg4
generateOrg3Definition generateOrg4Definition
fi fi
infoln "Bringing up Org3 peer" infoln "Bringing up Org4 peer"
Org3Up Org4Up
# Use the CLI container to create the configuration transaction needed to add # Use the CLI container to create the configuration transaction needed to add
# Org3 to the network # Org4 to the network
infoln "Generating and submitting config tx to add Org3" infoln "Generating and submitting config tx to add Org4"
docker exec cli ./scripts/org3-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE docker exec cli ./scripts/org4-scripts/updateChannelConfig.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
fatalln "ERROR !!!! Unable to create config tx" fatalln "ERROR !!!! Unable to create config tx"
fi fi
infoln "Joining Org3 peers to network" infoln "Joining Org4 peers to network"
docker exec cli ./scripts/org3-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE docker exec cli ./scripts/org4-scripts/joinChannel.sh $CHANNEL_NAME $CLI_DELAY $CLI_TIMEOUT $VERBOSE
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
fatalln "ERROR !!!! Unable to join Org3 peers to network" fatalln "ERROR !!!! Unable to join Org4 peers to network"
fi fi
} }
@ -175,11 +175,11 @@ CLI_DELAY=3
# channel name defaults to "mychannel" # channel name defaults to "mychannel"
CHANNEL_NAME="mychannel" CHANNEL_NAME="mychannel"
# use this as the docker compose couch file # use this as the docker compose couch file
COMPOSE_FILE_COUCH_ORG3=docker/docker-compose-couch-org3.yaml COMPOSE_FILE_COUCH_ORG4=docker/docker-compose-couch-org4.yaml
# use this as the default docker-compose yaml definition # use this as the default docker-compose yaml definition
COMPOSE_FILE_ORG3=docker/docker-compose-org3.yaml COMPOSE_FILE_ORG4=docker/docker-compose-org4.yaml
# certificate authorities compose file # certificate authorities compose file
COMPOSE_FILE_CA_ORG3=docker/docker-compose-ca-org3.yaml COMPOSE_FILE_CA_ORG4=docker/docker-compose-ca-org4.yaml
# database # database
DATABASE="leveldb" DATABASE="leveldb"
@ -238,12 +238,12 @@ done
# Determine whether starting, stopping, restarting or generating for announce # Determine whether starting, stopping, restarting or generating for announce
if [ "$MODE" == "up" ]; then if [ "$MODE" == "up" ]; then
infoln "Adding org3 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'" infoln "Adding org4 to channel '${CHANNEL_NAME}' with '${CLI_TIMEOUT}' seconds and CLI delay of '${CLI_DELAY}' seconds and using database '${DATABASE}'"
echo echo
elif [ "$MODE" == "down" ]; then elif [ "$MODE" == "down" ]; then
EXPMODE="Stopping network" EXPMODE="Stopping network"
elif [ "$MODE" == "generate" ]; then elif [ "$MODE" == "generate" ]; then
EXPMODE="Generating certs and organization definition for Org3" EXPMODE="Generating certs and organization definition for Org4"
else else
printHelp printHelp
exit 1 exit 1
@ -251,12 +251,12 @@ fi
#Create the network using docker compose #Create the network using docker compose
if [ "${MODE}" == "up" ]; then if [ "${MODE}" == "up" ]; then
addOrg3 addOrg4
elif [ "${MODE}" == "down" ]; then ## Clear the network elif [ "${MODE}" == "down" ]; then ## Clear the network
networkDown networkDown
elif [ "${MODE}" == "generate" ]; then ## Generate Artifacts elif [ "${MODE}" == "generate" ]; then ## Generate Artifacts
generateOrg3 generateOrg4
generateOrg3Definition generateOrg4Definition
else else
printHelp printHelp
exit 1 exit 1

View file

@ -5,13 +5,19 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
function createOrg3 { #
# 4 5 6
#
function createOrg4 {
infoln "Enrolling the CA admin" infoln "Enrolling the CA admin"
mkdir -p ../organizations/peerOrganizations/org3.example.com/ mkdir -p ../organizations/peerOrganizations/org4.example.com/
export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org3.example.com/ export FABRIC_CA_CLIENT_HOME=${PWD}/../organizations/peerOrganizations/org4.example.com/
set -x set -x
#
# 4 5 6
#
fabric-ca-client enroll -u https://admin:adminpw@localhost:11054 --caname ca-org3 --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem" fabric-ca-client enroll -u https://admin:adminpw@localhost:11054 --caname ca-org3 --tls.certfiles "${PWD}/fabric-ca/org3/tls-cert.pem"
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null