#!/bin/bash # # Copyright IBM Corp. All Rights Reserved. # # SPDX-License-Identifier: Apache-2.0 # function dkcl(){ CONTAINER_IDS=$(docker ps -aq) 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 material rm -rf /tmp/hfc-test-kvs_peerOrg* $HOME/.hfc-key-store/ /tmp/fabric-client-kvs_peerOrg* #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 copyIndex fabric-client/index.d.ts copyIndex fabric-ca-client/index.d.ts echo } function copyIndex() { if [ ! -f node_modules/$1 ]; then cp types/$1 node_modules/$1 fi } restartNetwork installNodeModules PORT=4000 ts-node app.ts