fabric-samples/test-network-nano-bash/ca/ccp-generate.sh
Aadithyan Raju b82a309d91
NixOS support (Multi-Linux Distro Support) (#1310)
Signed-off-by: AadithyanRaju <aadithyan75@gmail.com>
Signed-off-by: Aadithyan Raju <93834376+AadithyanRaju@users.noreply.github.com>
2025-03-24 19:15:58 +00:00

45 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env bash
function one_line_pem {
echo "`awk 'NF {sub(/\\n/, ""); printf "%s\\\\\\\n",$0;}' $1`"
}
function json_ccp {
local PP=$(one_line_pem $4)
local CP=$(one_line_pem $5)
sed -e "s/\${ORG}/$1/" \
-e "s/\${P0PORT}/$2/" \
-e "s/\${CAPORT}/$3/" \
-e "s#\${PEERPEM}#$PP#" \
-e "s#\${CAPEM}#$CP#" \
./ca/ccp-template.json
}
function yaml_ccp {
local PP=$(one_line_pem $4)
local CP=$(one_line_pem $5)
sed -e "s/\${ORG}/$1/" \
-e "s/\${P0PORT}/$2/" \
-e "s/\${CAPORT}/$3/" \
-e "s#\${PEERPEM}#$PP#" \
-e "s#\${CAPEM}#$CP#" \
./ca/ccp-template.yaml | sed -e $'s/\\\\n/\\\n /g'
}
ORG=1
P0PORT=7051
CAPORT=5053
PEERPEM=./crypto-config/peerOrganizations/org1.example.com/msp/tlscacerts/tlsca.org1.example.com-cert.pem
CAPEM=./crypto-config/peerOrganizations/org1.example.com/ca/msp/cacerts/ca.org1.example.com-cert.pem
echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > ./crypto-config/peerOrganizations/org1.example.com/connection-org1.json
echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > ./crypto-config/peerOrganizations/org1.example.com/connection-org1.yaml
ORG=2
P0PORT=7054
CAPORT=5054
PEERPEM=./crypto-config/peerOrganizations/org2.example.com/msp/tlscacerts/tlsca.org2.example.com-cert.pem
CAPEM=./crypto-config/peerOrganizations/org2.example.com/ca/msp/cacerts/ca.org2.example.com-cert.pem
echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > ./crypto-config/peerOrganizations/org2.example.com/connection-org2.json
echo "$(yaml_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > ./crypto-config/peerOrganizations/org2.example.com/connection-org2.yaml