Commit c230419e authored by o4's avatar o4
Browse files

added comments to all the Scripts in composer-network/fabric-network/scripts...

added comments to all the Scripts in composer-network/fabric-network/scripts that were created by us
parent 5169d823
#!/bin/bash
#Script for resetting the docker containers and images of the hyperledger fabric infrastructure
echo ""
echo "----REMOVING IMAGES----"
#remove the images by using the script that comes with the hyperledger code in the fabric-tools folder. Copied here to be used even when the tools are not installed locally
echo 2 | ./teardownAllDocker.sh
echo "----DOWNLOADING IMAGES----"
#download the given versions of the hyperledger fabric nodes and cas
curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0 1.1.0 0.4.6
echo "----DONE----"
#remove the folder with the samples that also gets downloaded by the above command
rm -rf fabric-samples
#!/bin/bash
#Script to startup everything. First docker landscape, then the two channels including BNAs
#Script to startup everything. First hyperledger fabric on docker landscape, then the two channels including BNAs
#variable for starting without parameters
NOBNA=0
if [ "$#" -lt 2 ]; then
NOBNA=1
echo "Start like this: <./startup.sh auditchain-exchange.bna auditchain-acquisition.bna>"
exit 1
fi
#Filename of the first .bna file
#Filename of the first .bna file, for the auditchain-exchange channel
BNA1=$1
#Filename of the second bna file
#Filename of the second bna file, for the auditchain-acquisition channel
BNA2=$2
#only to be executed if bna files are provided
if [ "$NOBNA" -eq 0 ]; then
#delete all old imported cards
#delete all old imported cards and everything else composer related
rm -rf ~/.composer
#composer card list | grep @ > cards.txt
#sed 's/[^ ]* //' cards.txt > cards2.txt
#sed 's/\s.*$//' cards2.txt > cards3.txt
#while read -r line;
#do composer card delete -c $line;
#done < cards3.txt
rm cards.txt
rm cards2.txt
rm cards3.txt
#delete participant-cards that are not needed anymore
rm -rf ../participant-cards/a*
#Docker landscape
#delete participant-cards that are not needed anymore (admin and user)
rm -rf ../participant-cards
#startup the hyperledger fabric on docker landscape (orderer, nodes, cas)
./startup_docker_infrastructure.sh
#channel exchange
#create the channel auditchain-exchange on the hyoerledger fabric and create admin/user cards for them to be imported in composer
./startup_fabric_exchange.sh $BNA1
#channel acquisition
#create the channel auditchain-acquisition on the hyoerledger fabric and create admin/user cards for them to be imported in composer
./startup_fabric_acquisition.sh $BNA2
fi
#!/bin/bash
#Exported variabebles to be used in the hyperledger fabric channel creation
export CHANNEL_NAME1=auditchain-exchange-channel
export CHANNEL_NAME2=auditchain-acquisition-channel
export DELAY=3
export TIMEOUT=1000
export COMPOSE_PROJECT_NAME=auditchain
#if no parameter is given to the script, then the debug information is displayed in the terminal. Breaks automatic execution of the channel start scripts
MODE="-d"
if [ "$#" -gt 0 ]; then
MODE=""
fi
#kill al previous docker container/images before execution. Otherwise channels created in the last run remain there and block creation of the channels
echo 1 | ./teardownAllDocker.sh
#start docker with the config files that are provided, and include all necessary information, like ports, private keys for cas
docker-compose -f ../docker-compose-cli.yaml -f ../docker-compose-cas.yaml up $MODE
#!/bin/bash
#Script to create the auditchain-exchange channel on the hyperledger fabric and create admin/usercards for each organization that are imported into composer afterwards. These are used by the application
NOBNA=0
#check if a .bna file is given as a parameter. If not, only the channel is created on the hyperledger fabric, and the whole composer part is left out. Debug option for finding problems in the fabric code
if [ "$#" -lt 1 ]; then
NOBNA=1
fi
#Filename of the first .bna File, without file extension
#Filename of the .bna file
BNA=$1
#splitting full filename
#Splitter of full filename on the "."
IFS='.'
#BNAwithoutextension
#BNA without the .bna extension, so just the name of the network
BNAWITHOUT=''
#Splitting the full filename, networkname resides in BNAWITHOUT afterwards
COUNTER=0
read -ra ARR <<< "$BNA"
for i in "${ARR[@]}"
......@@ -19,9 +22,10 @@ for i in "${ARR[@]}"
COUNTER=1
done
IFS=' '
#variable for the name of the network.
CHANNELTYPE=acquisition
#Importing the cards, errors if already exist can be ignored
#Importing the peeradmin-cards, one for each organization, errors if already exist can be ignored
composer card import -f ../peeradmin-cards/PeerAdmin@auditchain-$CHANNELTYPE-system.card --card PeerAdmin@auditchain-$CHANNELTYPE-system
composer card import -f ../peeradmin-cards/PeerAdmin@auditchain-$CHANNELTYPE-manufacturer2.card --card PeerAdmin@auditchain-$CHANNELTYPE-manufacturer2
composer card import -f ../peeradmin-cards/PeerAdmin@auditchain-$CHANNELTYPE-supplier1.card --card PeerAdmin@auditchain-$CHANNELTYPE-supplier1
......@@ -37,30 +41,33 @@ CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/1.supplier.auditchain.org/users/Admin@1.supplier.auditchain.org/msp CORE_PEER_ADDRESS=peer0.1.supplier.auditchain.org:7051 CORE_PEER_LOCALMSPID="Supplier1MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/1.supplier.auditchain.org/peers/peer0.1.supplier.auditchain.org/tls/ca.crt peer channel update -o orderer.auditchain.org:7050 -c $CHANNEL_NAME2 -f ./channel-artifacts/Supplier1MSPanchors_$CHANNEL_NAME2.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/auditchain.org/orderers/orderer.auditchain.org/msp/tlscacerts/tlsca.auditchain.org-cert.pem ;
exit'
#check for a start of the script without a parameter
if [ "$NOBNA" -eq 0 ]; then
#Install BNA
#Install the BNA on each organization using the peeradmin-card of the respective organization
composer network install --card PeerAdmin@auditchain-$CHANNELTYPE-system --archiveFile $BNA
composer network install --card PeerAdmin@auditchain-$CHANNELTYPE-manufacturer2 --archiveFile $BNA
composer network install --card PeerAdmin@auditchain-$CHANNELTYPE-supplier1 --archiveFile $BNA
#request an identity for the admin of each organization on this channel
composer identity request -c PeerAdmin@auditchain-$CHANNELTYPE-system -u adminsystem -s adminpw -d ../participant-cards/admin-$CHANNELTYPE-system
composer identity request -c PeerAdmin@auditchain-$CHANNELTYPE-manufacturer2 -u adminmanufacturer2 -s adminpw -d ../participant-cards/admin-$CHANNELTYPE-manufacturer2
composer identity request -c PeerAdmin@auditchain-$CHANNELTYPE-supplier1 -u adminsupplier1 -s adminpw -d ../participant-cards/admin-$CHANNELTYPE-supplier1
#start the network
#start the composer network with the previously issued admin identities and the generated endorsement policy, using the peeradmin of the system organization
composer network start -c PeerAdmin@auditchain-$CHANNELTYPE-system -n $BNAWITHOUT -V 0.0.1 -o ../auditchaintmp/endorsement-policy-$CHANNELTYPE.json -A admin-system -C ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-priv.pem -A admin-manufacturer2 -C ../participant-cards/admin-$CHANNELTYPE-manufacturer2/adminmanufacturer2-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-manufacturer2/adminmanufacturer2-priv.pem -A admin-supplier1 -C ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-priv.pem
#composer network start -c PeerAdmin@auditchain-$CHANNELTYPE-system -n $BNAWITHOUT -V 0.0.1 -A admin-system -C ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-priv.pem -A admin-manufacturer2 -C ../participant-cards/admin-$CHANNELTYPE-manufacturer2/adminmanufacturer2-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-manufacturer2/adminmanufacturer2-priv.pem -A admin-supplier1 -C ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-priv.pem
#creation and import of the admin-cards for each organization
composer card create -p ../auditchaintmp/auditchain/auditchain-$CHANNELTYPE-system.json -u admin-system -n $BNAWITHOUT -c ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-pub.pem -k ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-priv.pem -f ../participant-cards/admin-$CHANNELTYPE-system@$BNAWITHOUT.card
composer card import -f ../participant-cards/admin-$CHANNELTYPE-system@$BNAWITHOUT.card
composer card create -p ../auditchaintmp/manufacturer/2/auditchain-$CHANNELTYPE-manufacturer2.json -u admin-manufacturer2 -n $BNAWITHOUT -c ../participant-cards/admin-$CHANNELTYPE-manufacturer2/adminmanufacturer2-pub.pem -k ../participant-cards/admin-$CHANNELTYPE-manufacturer2/adminmanufacturer2-priv.pem -f ../participant-cards/admin-$CHANNELTYPE-manufacturer2@$BNAWITHOUT.card
composer card import -f ../participant-cards/admin-$CHANNELTYPE-manufacturer2@$BNAWITHOUT.card
composer card create -p ../auditchaintmp/supplier/1/auditchain-$CHANNELTYPE-supplier1.json -u admin-supplier1 -n $BNAWITHOUT -c ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-pub.pem -k ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-priv.pem -f ../participant-cards/admin-$CHANNELTYPE-supplier1@$BNAWITHOUT.card
composer card import -f ../participant-cards/admin-$CHANNELTYPE-supplier1@$BNAWITHOUT.card
#test each admin-card for functionality by pinging the network
composer network ping -c admin-system@$BNAWITHOUT
composer network ping -c admin-manufacturer2@$BNAWITHOUT
composer network ping -c admin-supplier1@$BNAWITHOUT
#request user cards for each organization, install and test themi
#request user identities for each organization, create cards, install and test them
composer participant add -c admin-system@auditchain-$CHANNELTYPE -d '{"$class":"org.auditchain.System","pid":"2000", "name":"user2-system"}'
composer participant add -c admin-manufacturer2@auditchain-$CHANNELTYPE -d '{"$class":"org.auditchain.Manufacturer","pid":"2001", "name":"user2-manufacturer2"}'
composer participant add -c admin-supplier1@auditchain-$CHANNELTYPE -d '{"$class":"org.auditchain.Supplier","pid":"2101", "name":"user2-supplier1", "publicKey":"intentionallyLeftBlank"}'
......
#!/bin/bash
#Script to create the auditchain-exchange channel on the hyperledger fabric and create admin/usercards for each organization that are imported into composer afterwards. These are used by the application
NOBNA=0
#check if a .bna file is given as a parameter. If not, only the channel is created on the hyperledger fabric, and the whole composer part is left out. Debug option for finding problems in the fabric code
if [ "$#" -lt 1 ]; then
NOBNA=1
fi
#Filename of the first .bna file
#Filename of the .bna file
BNA=$1
#splitting full filename
#Splitter of full filename on the "."
IFS='.'
#BNAwithoutextension
#BNA without the .bna extension, so just the name of the network
BNAWITHOUT=''
#Splitting the full filename, networkname resides in BNAWITHOUT afterwards
COUNTER=0
read -ra ARR <<< "$BNA"
for i in "${ARR[@]}"
......@@ -19,14 +22,15 @@ for i in "${ARR[@]}"
COUNTER=1
done
IFS=' '
#variable for the name of the network.
CHANNELTYPE=exchange
#Importing the cards, errors if already exist can be ignored
#Importing the peeradmin-cards, one for each organization, errors if already exist can be ignored
composer card import -f ../peeradmin-cards/PeerAdmin@auditchain-$CHANNELTYPE-system.card --card PeerAdmin@auditchain-$CHANNELTYPE-system
composer card import -f ../peeradmin-cards/PeerAdmin@auditchain-$CHANNELTYPE-manufacturer1.card --card PeerAdmin@auditchain-$CHANNELTYPE-manufacturer1
composer card import -f ../peeradmin-cards/PeerAdmin@auditchain-$CHANNELTYPE-supplier1.card --card PeerAdmin@auditchain-$CHANNELTYPE-supplier1
#create the channels
#create the channel on the hyperledger fabric and join the peers of the participating organizations, via a docker container named cli
docker exec -it -e CHANNEL_NAME1=auditchain-$CHANNELTYPE-channel cli bash -c '
peer channel create -o orderer.auditchain.org:7050 -c $CHANNEL_NAME1 -f ./channel-artifacts/$CHANNEL_NAME1.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/auditchain.org/orderers/orderer.auditchain.org/msp/tlscacerts/tlsca.auditchain.org-cert.pem ;
peer channel join -b $CHANNEL_NAME1.block ;
......@@ -37,30 +41,33 @@ CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypt
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/1.supplier.auditchain.org/users/Admin@1.supplier.auditchain.org/msp CORE_PEER_ADDRESS=peer0.1.supplier.auditchain.org:7051 CORE_PEER_LOCALMSPID="Supplier1MSP" CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/1.supplier.auditchain.org/peers/peer0.1.supplier.auditchain.org/tls/ca.crt peer channel update -o orderer.auditchain.org:7050 -c $CHANNEL_NAME1 -f ./channel-artifacts/Supplier1MSPanchors_$CHANNEL_NAME1.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/auditchain.org/orderers/orderer.auditchain.org/msp/tlscacerts/tlsca.auditchain.org-cert.pem ;
exit'
#check for a start of the script without a parameter
if [ "$NOBNA" -eq 0 ]; then
#Install BNA
#Install the BNA on each organization using the peeradmin-card of the respective organization
composer network install --card PeerAdmin@auditchain-$CHANNELTYPE-system --archiveFile $BNA
composer network install --card PeerAdmin@auditchain-$CHANNELTYPE-manufacturer1 --archiveFile $BNA
composer network install --card PeerAdmin@auditchain-$CHANNELTYPE-supplier1 --archiveFile $BNA
#request an identity for the admin of each organization on this channel
composer identity request -c PeerAdmin@auditchain-$CHANNELTYPE-system -u adminsystem -s adminpw -d ../participant-cards/admin-$CHANNELTYPE-system
composer identity request -c PeerAdmin@auditchain-$CHANNELTYPE-manufacturer1 -u adminmanufacturer1 -s adminpw -d ../participant-cards/admin-$CHANNELTYPE-manufacturer1
composer identity request -c PeerAdmin@auditchain-$CHANNELTYPE-supplier1 -u adminsupplier1 -s adminpw -d ../participant-cards/admin-$CHANNELTYPE-supplier1
#start the network
#start the composer network with the previously issued admin identities and the generated endorsement policy, using the peeradmin of the system organization
composer network start -c PeerAdmin@auditchain-$CHANNELTYPE-system -n $BNAWITHOUT -V 0.0.1 -o ../auditchaintmp/endorsement-policy-$CHANNELTYPE.json -A admin-system -C ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-priv.pem -A admin-manufacturer1 -C ../participant-cards/admin-$CHANNELTYPE-manufacturer1/adminmanufacturer1-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-manufacturer1/adminmanufacturer1-priv.pem -A admin-supplier1 -C ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-priv.pem
#composer network start -c PeerAdmin@auditchain-$CHANNELTYPE-system -n $BNAWITHOUT -V 0.0.1 -A admin-system -C ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-priv.pem -A admin-manufacturer1 -C ../participant-cards/admin-$CHANNELTYPE-manufacturer1/adminmanufacturer1-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-manufacturer1/adminmanufacturer1-priv.pem -A admin-supplier1 -C ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-pub.pem -K ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-priv.pem
#creation and import of the admin-cards for each organization
composer card create -p ../auditchaintmp/auditchain/auditchain-$CHANNELTYPE-system.json -u admin-system -n $BNAWITHOUT -c ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-pub.pem -k ../participant-cards/admin-$CHANNELTYPE-system/adminsystem-priv.pem -f ../participant-cards/admin-$CHANNELTYPE-system@$BNAWITHOUT.card
composer card import -f ../participant-cards/admin-$CHANNELTYPE-system@$BNAWITHOUT.card
composer card create -p ../auditchaintmp/manufacturer/1/auditchain-$CHANNELTYPE-manufacturer1.json -u admin-manufacturer1 -n $BNAWITHOUT -c ../participant-cards/admin-$CHANNELTYPE-manufacturer1/adminmanufacturer1-pub.pem -k ../participant-cards/admin-$CHANNELTYPE-manufacturer1/adminmanufacturer1-priv.pem -f ../participant-cards/admin-$CHANNELTYPE-manufacturer1@$BNAWITHOUT.card
composer card import -f ../participant-cards/admin-$CHANNELTYPE-manufacturer1@$BNAWITHOUT.card
composer card create -p ../auditchaintmp/supplier/1/auditchain-$CHANNELTYPE-supplier1.json -u admin-supplier1 -n $BNAWITHOUT -c ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-pub.pem -k ../participant-cards/admin-$CHANNELTYPE-supplier1/adminsupplier1-priv.pem -f ../participant-cards/admin-$CHANNELTYPE-supplier1@$BNAWITHOUT.card
composer card import -f ../participant-cards/admin-$CHANNELTYPE-supplier1@$BNAWITHOUT.card
#test each admin-card for functionality by pinging the network
composer network ping -c admin-system@$BNAWITHOUT
composer network ping -c admin-manufacturer1@$BNAWITHOUT
composer network ping -c admin-supplier1@$BNAWITHOUT
#request user cards for each organization, install and test them
#request user identities for each organization, create cards, install and test them
composer participant add -c admin-system@auditchain-$CHANNELTYPE -d '{"$class":"org.auditchain.System","pid":"0001", "name":"user1-system"}'
composer participant add -c admin-manufacturer1@auditchain-$CHANNELTYPE -d '{"$class":"org.auditchain.Manufacturer","pid":"1001", "name":"user1-manufacturer1"}'
composer participant add -c admin-supplier1@auditchain-$CHANNELTYPE -d '{"$class":"org.auditchain.Supplier","pid":"1101", "name":"user1-supplier1", "publicKey":"intentionallyLeftBlank"}'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment