fabric-samples/balance-transfer/runApp.sh
hag3 dccd41ec13
Add filtering function to the dkcl function
The original dkcl function deletes all containers regardless of whether they were started by this sample or not (e.g. rancher/agent).
Doing so would corrupt the host's environment and cause inconvenience. So I added conditional filtering to the dkfc function.
2018-12-11 10:46:38 +08:00

62 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
function dkcl(){
CONTAINER_IDS=$(docker ps -a | grep "ca_peerOrg\|.example.com" | awk '{print $1}')
echo
if [ -z "$CONTAINER_IDS" -o "$CONTAINER_IDS" = " " ]; then
echo "========== No containers available for deletion =========="
else
docker rm -f $CONTAINER_IDS
fi
echo
}
function dkrm(){
DOCKER_IMAGE_IDS=$(docker images | grep "dev\|none\|test-vp\|peer[0-9]-" | awk '{print $3}')
echo
if [ -z "$DOCKER_IMAGE_IDS" -o "$DOCKER_IMAGE_IDS" = " " ]; then
echo "========== No images available for deletion ==========="
else
docker rmi -f $DOCKER_IMAGE_IDS
fi
echo
}
function restartNetwork() {
echo
#teardown the network and clean the containers and intermediate images
docker-compose -f ./artifacts/docker-compose.yaml down
dkcl
dkrm
#Cleanup the stores
rm -rf ./fabric-client-kv-org*
#Start the network
docker-compose -f ./artifacts/docker-compose.yaml up -d
echo
}
function installNodeModules() {
echo
if [ -d node_modules ]; then
echo "============== node modules installed already ============="
else
echo "============== Installing node modules ============="
npm install
fi
echo
}
restartNetwork
installNodeModules
PORT=4000 node app