Last active
July 5, 2018 18:59
-
-
Save himanshuchawla009/6c6d470f32e1dc9a6f37a4c37b581776 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat << "EOF" | |
______ __ __ __ __ __ __ __ ___ _______. __ __ | |
/ __ \ | | | | | | | | | | | | | | / \ / || | | | | |
| | | | | | | | | | | | | | | |__| | / ^ \ | (----`| |__| | | |
| | | | | | | | | | | | | | | __ | / /_\ \ \ \ | __ | | |
| `--' '--.| `--' | | | | `----.| `----.| | | | / _____ \ .----) | | | | | | |
\_____\_____\\______/ |__| |_______||_______||__| |__| /__/ \__\ |_______/ |__| |__| | |
" | |
EOF | |
echo "Removing existing cards if any" | |
rm -fr $HOME/.composer | |
echo "Creating temporary directories for org 1" | |
mkdir -p /tmp/composer/org1 | |
mkdir -p /tmp/composer/org2 | |
echo "Pasting Org 1 certificates in tmp/composer/org1" | |
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' fabric-dev-servers/first-network/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt > /tmp/composer/org1/ca-org1.txt | |
echo "Pasting Org 1 certificates in tmp/composer/org2" | |
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' fabric-dev-servers/first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt > /tmp/composer/org2/ca-org2.txt | |
echo "Pasting Org 1 certificates in tmp/composer/org2" | |
awk 'NF {sub(/\r/, ""); printf "%s\\n",$0;}' fabric-dev-servers/first-network/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt > /tmp/composer/ca-orderer.txt | |
echo "Creating the connection profile file" | |
cp connectionProfile.json /tmp/composer/byfn-network.json | |
echo "Adding the certificates in connection profile" | |
replacementOrg1="/tmp/composer/org1/ca-org1.txt" | |
replacementOrg2="/tmp/composer/org2/ca-org2.txt" | |
replacementOrderer="/tmp/composer/ca-orderer.txt" | |
file="/tmp/composer/byfn-network.json" | |
org1="/tmp/composer/byfnOrg1.json" | |
org2="/tmp/composer/byfnOrg2.json" | |
final="/tmp/composer/byfnFinal.json" | |
sed -i 's/\\n//g' $replacementOrg1 | |
sed -i 's/\\n//g' $replacementOrg2 | |
sed -i 's/\\n//g' $replacementOrderer | |
sed -e "s@INSERT_ORG1_CA_CERT@$(cat $replacementOrg1)@g" $file > $org1 | |
sed -e "s@INSERT_ORG2_CA_CERT@$(cat $replacementOrg2)@g" $org1 > $org2 | |
sed -e "s@INSERT_ORDERER_CA_CERT@(cat $replacementOrderer)@g" $org2 > $final | |
echo "Creating connection profile for org1" | |
cp /tmp/composer/byfnFinal.json /tmp/composer/org1/byfn-network-org1.json | |
ex -sc '4i|"client": { | |
"organization": "Org1", | |
"connection": { | |
"timeout": { | |
"peer": { | |
"endorser": "300", | |
"eventHub": "300", | |
"eventReg": "300" | |
}, | |
"orderer": "300" | |
} | |
} | |
},' -cx /tmp/composer/org1/byfn-network-org1.json | |
echo "Creating connection profile for org2" | |
cp /tmp/composer/byfnFinal.json /tmp/composer/org2/byfn-network-org2.json | |
ex -sc '4i|"client": { | |
"organization": "Org2", | |
"connection": { | |
"timeout": { | |
"peer": { | |
"endorser": "300", | |
"eventHub": "300", | |
"eventReg": "300" | |
}, | |
"orderer": "300" | |
} | |
} | |
},' -cx /tmp/composer/org2/byfn-network-org2.json | |
echo "getting the certificates for administrator of org1" | |
export ORG1=fabric-dev-servers/first-network/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp | |
cp -p $ORG1/signcerts/A*.pem /tmp/composer/org1 | |
cp -p $ORG1/keystore/*_sk /tmp/composer/org1 | |
echo "getting the certificates for administrator of org2" | |
export ORG2=fabric-dev-servers/first-network/crypto-config/peerOrganizations/org2.example.com/users/[email protected]/msp | |
cp -p $ORG2/signcerts/A*.pem /tmp/composer/org2 | |
cp -p $ORG2/keystore/*_sk /tmp/composer/org2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment