-
Notifications
You must be signed in to change notification settings - Fork 0
/
StartFabric.sh
63 lines (52 loc) · 2 KB
/
StartFabric.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
#!/bin/bash
. ./Vars.sh
echo -e "\n\n"
echo -e "###############################"
echo -e "#### Deploying Fabric ####"
echo -e "###############################\n\n"
sleep ${SLEEP_SECONDS}
if [ -d "fabric" ]; then
cd fabric
else
mkdir "fabric"
cd fabric
fi
if [ -d "fabric-samples" ]; then
echo "fabric-samples directory already exists..."
else
echo "Directory fabric-samples does not exist. Downloading install-fabric.sh script..."
curl -sSLO https://raw.githubusercontent.com/hyperledger/fabric/main/scripts/install-fabric.sh && chmod +x install-fabric.sh
echo "Running install-fabric.sh..."
./install-fabric.sh
fi
echo -e "\n\n"
echo -e "######################################"
echo -e "#### Starting Fabric Network ####"
echo -e "######################################\n\n"
sleep ${SLEEP_SECONDS}
cd fabric-samples/test-network
./network.sh down
./network.sh up createChannel -c "$FABRIC_CHANNEL_NAME" -ca
echo -e "\n\n"
echo -e "###############################################"
echo -e "#### Deploying Fabric Smart Contracts ####"
echo -e "###############################################\n\n"
sleep ${SLEEP_SECONDS}
if [ -d "../../$FABRIC_CHAINCODE_NAME" ]; then
echo "$FABRIC_CHAINCODE_NAME already exists..."
cd "../../$FABRIC_CHAINCODE_NAME"
else
echo "Directory $FABRIC_CHAINCODE_NAME does not exist. Cloning smart contracts..."
cd ../..
mkdir "$FABRIC_CHAINCODE_NAME"
cd "$FABRIC_CHAINCODE_NAME"
git clone https://github.com/TIHBS/fabric-resource-manager.git .
fi
cd ../fabric-samples/test-network
./network.sh deployCC -ccn "$FABRIC_CHAINCODE_NAME" -ccp ../../$FABRIC_CHAINCODE_NAME -ccl javascript
echo -e "\n\n"
echo -e "###############################################"
echo -e "## Initializing Fabric Smart Contracts ###"
echo -e "###############################################\n\n"
sleep ${SLEEP_SECONDS}
./network.sh cc invoke -c "$FABRIC_CHANNEL_NAME" -ccn "$FABRIC_CHAINCODE_NAME" -ccic '{"Args":["BasicFlightBookingManager:InitLedger"]}'