-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenccp.sh
executable file
·32 lines (26 loc) · 1.03 KB
/
genccp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/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#" \
./configs/ccp/ccp-template.json
}
ORG=1
P0PORT=7051
CAPORT=7054
PEERPEM=configs/crypto-config/peerOrganizations/org1.eapproval.com/tlsca/tlsca.org1.eapproval.com-cert.pem
CAPEM=configs/crypto-config/peerOrganizations/org1.eapproval.com/ca/ca.org1.eapproval.com-cert.pem
echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > configs/ccp/connection-org1.json
ORG=2
P0PORT=9051
CAPORT=9054
PEERPEM=configs/crypto-config/peerOrganizations/org2.eapproval.com/tlsca/tlsca.org2.eapproval.com-cert.pem
CAPEM=configs/crypto-config/peerOrganizations/org2.eapproval.com/ca/ca.org2.eapproval.com-cert.pem
echo "$(json_ccp $ORG $P0PORT $CAPORT $PEERPEM $CAPEM)" > configs/ccp/connection-org2.json