-
Notifications
You must be signed in to change notification settings - Fork 184
/
deploy.sh
executable file
·99 lines (77 loc) · 3.44 KB
/
deploy.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
function info() {
echo -e "************************************************************\n\033[1;33m${1}\033[m\n************************************************************"
}
configPathOrOrgName=${1:-org1}
DEV_MODE=${DEV_MODE}
AGENT_MODE=${AGENT_MODE}
if [ -z "${DEV_MODE}" ]; then
HTTPS_MODE=${HTTPS_MODE-1}
export LDAP_ENABLED=${LDAP_ENABLED:-true}
RENEW_IMAGES=${RENEW_IMAGES-1}
fi
export ORG=''
if [ -z "${AGENT_MODE}" ]; then
if [ -f "${configPathOrOrgName}" ]; then
source "${configPathOrOrgName}"
else
if [ -f "org_env" ]; then
source "org_env"
else
source "${configPathOrOrgName}_env"
fi
export ORG=${ORG:-${configPathOrOrgName}}
fi
export ORG=${ORG:-org1}
export DOMAIN=${DOMAIN:-example.com}
fi
echo -e "\n\n\n\n\n\n BOOTSTRAP_IP: $BOOTSTRAP_IP \n\n\n\n\n\n"
export ORDERER_WWW_PORT=${ORDERER_WWW_PORT:-79}
export SERVICE_CHANNEL=${SERVICE_CHANNEL:-common}
export DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker.io}
export FABRIC_STARTER_VERSION=${FABRIC_STARTER_VERSION:-stable}
export FABRIC_STARTER_REPOSITORY=${FABRIC_STARTER_REPOSITORY:-olegabu}
: ${DOCKER_COMPOSE_ORDERER_ARGS:="-f docker-compose-orderer.yaml -f docker-compose-orderer-domain.yaml -f docker-compose-orderer-ports.yaml"}
docker_compose_args=${DOCKER_COMPOSE_ARGS:-"-f docker-compose.yaml -f docker-compose-couchdb.yaml -f docker-compose-ldap.yaml"}
if [ -n "${HTTPS_MODE}" ]; then # https mode
export LDAPADMIN_HTTPS=${LDAPADMIN_HTTPS:-true}
export DOCKER_COMPOSE_EXTRA_ARGS=${DOCKER_COMPOSE_EXTRA_ARGS:-"-f https/docker-compose-https-ports.yaml"}
else # http mode
export LDAPADMIN_HTTPS=${LDAPADMIN_HTTPS:-false}
export DOCKER_COMPOSE_EXTRA_ARGS=${DOCKER_COMPOSE_EXTRA_ARGS:-"-f docker-compose-dev.yaml"}
export BOOTSTRAP_SERVICE_URL=http
fi
if [ -z "${NO_CLEAN}" ]; then
info "Cleaning up"
./clean.sh data
fi
if [[ -n "${RENEW_IMAGES}" ]]; then
docker pull ${DOCKER_REGISTRY:-docker.io}/${FABRIC_STARTER_REPOSITORY}/fabric-tools-extended:${FABRIC_STARTER_VERSION:-stable}
docker pull ${DOCKER_REGISTRY:-docker.io}/${FABRIC_STARTER_REPOSITORY}/fabric-starter-rest:${FABRIC_STARTER_VERSION:-stable}
docker pull ${DOCKER_REGISTRY:-docker.io}/${FABRIC_STARTER_REPOSITORY}/fabric-sdk-api:${FABRIC_STARTER_VERSION:-stable}
fi
export COMPOSE_PROJECT_NAME=${ORG:-org1}
if [[ -z "$AGENT_MODE" && -z "$NO_ORDERER" ]]; then
ORDERER_WWW_PORT=${ORDERER_WWW_PORT} ./ordering-start.sh $ORG ${BOOTSTRAP_ORDERER_DOMAIN:-${BOOTSTRAP_DOMAIN:-$DOMAIN}}
if [ $? -ne 0 ]; then
exit 1
fi
sleep 5
fi
if [ -z "$NO_PEER" ]; then
info "Create first organization ${ORG}"
if [ "${ORDERER_TYPE}" != "RAFT" ]; then
export ORDERER_DOMAIN=${ORDERER_DOMAIN:-${DOMAIN}}
fi
set -x
docker-compose -f docker-compose-preload-images.yaml up -d
BOOTSTRAP_IP=${BOOTSTRAP_IP} ENROLL_SECRET="${ENROLL_SECRET:-adminpw}" docker-compose ${docker_compose_args} ${DOCKER_COMPOSE_EXTRA_ARGS} \
up -d --force-recreate ${AGENT_MODE:+ api www.peer }
docker exec -t ldap.${ORG:-org1}.${DOMAIN:-example.com} bash -c 'set -x; creatorsName=`slapcat|grep "creatorsName:"`; adminDN=${creatorsName:14}; ldapadd -x -D "${adminDN}" -w "${LDAP_ADMIN_PASSWORD}" -f /etc/hyperledger/crypto-config/ldap/admin.ldif'
set +x
if [ -z "${AGENT_MODE}" ]; then
docker logs -f post-install.${PEER_NAME:-peer0}.${ORG}.${DOMAIN}
fi
fi
sleep 2
docker ps