fabric-samples/test-network/organizations/ccp-generate.sh
Naser Mirzaei 1dbf999992 fix ccp template and generator to include orderer and channel
Signed-off-by: Naser Mirzaei <nasermirzaei89@gmail.com>
2020-08-28 00:42:38 +04:30

54 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
function one_line_pem {
echo "`awk 'NF {sub(/\\n/, ""); printf "%s\\\\\\\n",$0;}' $1`"
}
function json_ccp {
local OP=$(one_line_pem $5)
local PP=$(one_line_pem $6)
local CP=$(one_line_pem $7)
sed -e "s/\${ORG}/$1/" \
-e "s/\${ORDERERPORT}/$2/" \
-e "s/\${P0PORT}/$3/" \
-e "s/\${CAPORT}/$4/" \
-e "s#\${ORDERERPEM}#$OP#" \
-e "s#\${PEERPEM}#$PP#" \
-e "s#\${CAPEM}#$CP#" \
organizations/ccp-template.json
}
function yaml_ccp {
local OP=$(one_line_pem $5)
local PP=$(one_line_pem $6)
local CP=$(one_line_pem $7)
sed -e "s/\${ORG}/$1/" \
-e "s/\${ORDERERPORT}/$2/" \
-e "s/\${P0PORT}/$3/" \
-e "s/\${CAPORT}/$4/" \
-e "s#\${ORDERERPEM}#$OP#" \
-e "s#\${PEERPEM}#$PP#" \
-e "s#\${CAPEM}#$CP#" \
organizations/ccp-template.yaml | sed -e $'s/\\\\n/\\\n /g'
}
ORDERERPORT=7050
ORDERERPEM=organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem
ORG=1
P0PORT=7051
CAPORT=7054
PEERPEM=organizations/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem
CAPEM=organizations/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem
echo "$(json_ccp $ORG $ORDERERPORT $P0PORT $CAPORT $ORDERERPEM $PEERPEM $CAPEM)" > organizations/peerOrganizations/org1.example.com/connection-org1.json
echo "$(yaml_ccp $ORG $ORDERERPORT $P0PORT $CAPORT $ORDERERPEM $PEERPEM $CAPEM)" > organizations/peerOrganizations/org1.example.com/connection-org1.yaml
ORG=2
P0PORT=9051
CAPORT=8054
PEERPEM=organizations/peerOrganizations/org2.example.com/tlsca/tlsca.org2.example.com-cert.pem
CAPEM=organizations/peerOrganizations/org2.example.com/ca/ca.org2.example.com-cert.pem
echo "$(json_ccp $ORG $ORDERERPORT $P0PORT $CAPORT $ORDERERPEM $PEERPEM $CAPEM)" > organizations/peerOrganizations/org2.example.com/connection-org2.json
echo "$(yaml_ccp $ORG $ORDERERPORT $P0PORT $CAPORT $ORDERERPEM $PEERPEM $CAPEM)" > organizations/peerOrganizations/org2.example.com/connection-org2.yaml