-
Notifications
You must be signed in to change notification settings - Fork 42
/
createPeerAdminCard.sh
executable file
·66 lines (58 loc) · 2.01 KB
/
createPeerAdminCard.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Exit on first error
set -e
# Grab the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo
# check that the composer command exists at a version >v0.14
if hash composer 2>/dev/null; then
composer --version | awk -F. '{if ($2<15) exit 1}'
if [ $? -eq 1 ]; then
echo 'Sorry, Use createConnectionProfile for versions before v0.15.0'
exit 1
else
echo Using composer-cli at $(composer --version)
fi
else
echo 'Need to have composer-cli installed at v0.15 or greater'
exit 1
fi
# need to get the certificate
cat << EOF > /tmp/.connection.json
{
"name": "hlfv1",
"type": "hlfv1",
"orderers": [
{ "url" : "grpc://localhost:7050" }
],
"ca": {
"url": "http://localhost:7054",
"name": "ca.org1.example.com"
},
"peers": [
{
"requestURL": "grpc://localhost:7051",
"eventURL": "grpc://localhost:7053"
}, {
"requestURL": "grpc://localhost:8051",
"eventURL": "grpc://localhost:8053"
}, {
"requestURL": "grpc://localhost:9051",
"eventURL": "grpc://localhost:9053"
}
],
"channel": "composerchannel",
"mspID": "Org1MSP",
"timeout": 300
}
EOF
PRIVATE_KEY="${DIR}"/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/7fe58742a0b6d1102c74293808f1736dea010d3451f9e1a804c0b86ecf90baa0_sk
CERT="${DIR}"/composer/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem
if composer card list -n PeerAdmin@hlfv1 > /dev/null; then
composer card delete -n PeerAdmin@hlfv1
fi
composer card create -p /tmp/.connection.json -u PeerAdmin -c "${CERT}" -k "${PRIVATE_KEY}" -r PeerAdmin -r ChannelAdmin --file /tmp/PeerAdmin@hlfv1.card
composer card import --file /tmp/PeerAdmin@hlfv1.card
rm -rf /tmp/.connection.json
echo "Hyperledger Composer PeerAdmin card has been imported"
composer card list