forked from olegabu/fabric-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-peer.sh
executable file
·34 lines (28 loc) · 1.68 KB
/
generate-peer.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
#!/usr/bin/env bash
############################################################
# DEPRECATED
# see inside-container scripts
############################################################
source lib.sh
## Workaround until docker-compose issue 4601 is solved
# https://github.com/docker/compose/issues/4601
#[ -n "${DOCKER_HOST}" ] && docker run -dit --name alpine --network fabric-overlay alpine
#[ -d "crypto-config/peerOrganizations/$ORG.$DOMAIN" ] && exit TODO: adjust for docker-machine
IFS='.' read -r -a subDomains <<< ${DOMAIN}
echo $DOMAIN
if [ -z "$LDAP_BASE_DN" ]; then
for subDomain in ${subDomains[@]}; do
[ -n "${LDAP_BASE_DN}" ] && COMMA=,
LDAP_BASE_DN="${LDAP_BASE_DN}${COMMA}dc=$subDomain"
done
export LDAP_BASE_DN
fi
[ -n "$LDAP_ENABLED" ] && echo "LDAP Url used: $LDAP_BASE_DN"
envSubst "templates/cryptogen-peer-template.yaml" "crypto-config/cryptogen-$ORG.yaml"
envSubst "templates/fabric-ca-server-template.yaml" "crypto-config/fabric-ca-server-config-$ORG.yaml" "export LDAP_BASE_DN=${LDAP_BASE_DN}"
runCLI "rm -rf crypto-config/peerOrganizations/$ORG.$DOMAIN \
&& cryptogen generate --config=crypto-config/cryptogen-$ORG.yaml \
&& mv crypto-config/peerOrganizations/$ORG.$DOMAIN/ca/*_sk crypto-config/peerOrganizations/$ORG.$DOMAIN/ca/sk.pem \
&& mv crypto-config/peerOrganizations/$ORG.$DOMAIN/users/Admin@$ORG.$DOMAIN/msp/keystore/*_sk crypto-config/peerOrganizations/$ORG.$DOMAIN/users/Admin@$ORG.$DOMAIN/msp/keystore/sk.pem \
&& cp -r crypto-config/ordererOrganizations/$DOMAIN/msp/* crypto-config/peerOrganizations/$ORG.$DOMAIN/msp 2>/dev/null \
&& chown $UID -R crypto-config/ || chown $UID -R crypto-config/"