This repository has been archived by the owner on Jan 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-composer.sh
68 lines (55 loc) · 2.3 KB
/
install-composer.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
#!/usr/bin/env bash
FABRIC_DEV_SERVERS_URL=https://raw.githubusercontent.com/hyperledger/composer-tools/master/packages/fabric-dev-servers/fabric-dev-servers.tar.gz
if [ -z $1 ]; then
COMPOSER_VERSION=latest
else
COMPOSER_VERSION=$1
fi
if [ ${COMPOSER_VERSION} = 'none' ]; then
echo "Skipping Composer install"
exit 0
elif [ ${COMPOSER_VERSION:0:5} = '0.16.' ]; then
export FABRIC_VERSION=hlfv1
elif [ ${COMPOSER_VERSION:0:5} = '0.18.' -o ${COMPOSER_VERSION:0:5} = '0.19.' ]; then
export FABRIC_VERSION=hlfv11
elif [ ${COMPOSER_VERSION} = 'latest' -o ${COMPOSER_VERSION} = 'unstable' -o ${COMPOSER_VERSION:0:5} = '0.20.' ]; then
export FABRIC_VERSION=hlfv12
else
>&2 echo "Unexpected COMPOSER_VERSION ${COMPOSER_VERSION}"
>&2 echo "COMPOSER_VERSION must be a 0.16.x, 0.18.x, 0.19.x, or 0.20.x (latest) version"
>&2 echo "Alternatively use 'none' to skip the Composer install"
exit 1
fi
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"
# Install Composer modules
npm ls -g composer-cli@${COMPOSER_VERSION} >/dev/null 2>&1 || npm install -g composer-cli@${COMPOSER_VERSION}
npm ls -g composer-rest-server@${COMPOSER_VERSION} >/dev/null 2>&1 || npm install -g composer-rest-server@${COMPOSER_VERSION}
npm ls -g generator-hyperledger-composer@${COMPOSER_VERSION} >/dev/null 2>&1 || npm install -g generator-hyperledger-composer@${COMPOSER_VERSION}
npm ls -g composer-playground@${COMPOSER_VERSION} >/dev/null 2>&1 || npm install -g composer-playground@${COMPOSER_VERSION}
# Install and start Fabric dev env for Composer
FABRIC_DIR="$HOME/fabric-dev-servers"
if [ ! -d ${FABRIC_DIR} ]; then
mkdir -p ${FABRIC_DIR}
cd ${FABRIC_DIR}
curl -O "$FABRIC_DEV_SERVERS_URL"
tar -xvzf fabric-dev-servers.tar.gz
./downloadFabric.sh
sg docker ./startFabric.sh
./createPeerAdminCard.sh
fi
#
# add devenv section to .profile
#
# Note: this will remove any existing devenv section so that
# multiple 'vagrant provision' commands do not cause duplication
#
DEVENV_START_COMMENT="# ---BEGIN-COMPOSER-DEVENV-PROFILE-SECTION---"
DEVENV_END_COMMENT="# ---END-COMPOSER-DEVENV-PROFILE-SECTION---"
sed -i.bak "/$DEVENV_START_COMMENT/,/$DEVENV_END_COMMENT/d" ~/.profile
cat << END-PROFILE-SECTION >> ~/.profile
$DEVENV_START_COMMENT
# set fabric version
export FABRIC_VERSION=$FABRIC_VERSION
$DEVENV_END_COMMENT
END-PROFILE-SECTION