matiru
Blockchain-Based Supply Chain Transparency for Agricultural Producegit clone https://github.com/maydayv7/matiru
fabric/network/scripts/utils.sh (3137B)
1#!/usr/bin/env bash
2
3C_RESET='\033[0m'
4C_RED='\033[0;31m'
5C_GREEN='\033[0;32m'
6C_BLUE='\033[0;34m'
7C_YELLOW='\033[1;33m'
8
9function printHelp() {
10 USAGE="$1"
11 if [ "$USAGE" == "up" ]; then
12 println "Usage: "
13 println " network.sh \033[0;32mup\033[0m [Flags]"
14 println " Flags:"
15 println " -ca <use CAs> - Use Certificate Authorities to generate network crypto material"
16 println " -c <channel name> - Name of channel to create (defaults to \"mychannel\")"
17 println " -s <dbtype> - Peer state database to deploy: goleveldb (default) or couchdb"
18 println " -verbose - Verbose mode"
19 println " -h - Print this message"
20 elif [ "$USAGE" == "createChannel" ]; then
21 println "Usage: "
22 println " network.sh \033[0;32mcreateChannel\033[0m [Flags]"
23 println " Flags:"
24 println " -c <channel name> - Name of channel to create (defaults to \"mychannel\")"
25 println " -verbose - Verbose mode"
26 println " -h - Print this message"
27 elif [ "$USAGE" == "deployCC" ]; then
28 println "Usage: "
29 println " network.sh \033[0;32mdeployCC\033[0m [Flags]"
30 println " Flags:"
31 println " -c <channel name> - Name of channel to deploy chaincode to"
32 println " -ccn <name> - Chaincode name."
33 println " -ccl <language> - Programming language of chaincode: go, java, javascript, typescript"
34 println " -ccv <version> - Chaincode version. 1.0 (default)"
35 println " -ccs <sequence> - Chaincode definition sequence. 1 (default)"
36 println " -ccp <path> - File path to the chaincode."
37 println " -ccep <policy> - (Optional) Chaincode endorsement policy."
38 println " -cccg <collection-config> - (Optional) File path to private data collections configuration file"
39 println " -cci <fcn name> - (Optional) Name of chaincode initialization function."
40 println " -h - Print this message"
41 else
42 println "Usage: "
43 println " network.sh <Mode> [Flags]"
44 println " Modes:"
45 println " \033[0;32mup\033[0m - Bring up Fabric orderer and peer nodes. No channel is created"
46 println " \033[0;32mup createChannel\033[0m - Bring up fabric network with one channel"
47 println " \033[0;32mcreateChannel\033[0m - Create and join a channel after the network is created"
48 println " \033[0;32mdeployCC\033[0m - Deploy a chaincode to a channel"
49 println " \033[0;32mdown\033[0m - Bring down the network"
50 println " Flags:"
51 println " -ca: Use Certificate Authorities"
52 println " -c <channel name>: channel name (defaults to \"mychannel\")"
53 println " -s <dbtype>: Peer state database (defaults to goleveldb)"
54 println " -verbose: Verbose mode"
55 fi
56}
57
58function println() {
59 echo -e "$1"
60}
61
62function errorln() {
63 println "${C_RED}${1}${C_RESET}"
64}
65
66function successln() {
67 println "${C_GREEN}${1}${C_RESET}"
68}
69
70function infoln() {
71 println "${C_BLUE}${1}${C_RESET}"
72}
73
74function warnln() {
75 println "${C_YELLOW}${1}${C_RESET}"
76}
77
78function fatalln() {
79 errorln "$1"
80 exit 1
81}
82
83export -f errorln
84export -f successln
85export -f infoln
86export -f warnln