-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·131 lines (123 loc) · 2.91 KB
/
run.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
echo ".----------------"
echo "|"
echo "| Block R Provisoner"
echo "|"
echo "'----------------"
DIVIDER="-------------------------------"
USER_MESSAGE=""
OPTION_1_TRAIL=""
OPTION_2_TRAIL=""
OPTION_3_TRAIL="*"
OPTION_4_TRAIL="*"
OPTION_5_TRAIL="*"
help_screen() {
echo -e "Invalid option.\n Choose from the list below.\n * indicates an illogical choice."
}
run_status() {
RUN_COUNT=0;
if $(/usr/bin/systemctl -q is-active couchdb) ; then
((RUN_COUNT++))
fi
if $(/usr/bin/systemctl -q is-active kafka) ; then
((RUN_COUNT++))
fi
if $(/usr/bin/systemctl -q is-active zookeeper) ; then
((RUN_COUNT++))
fi
if [ $RUN_COUNT = '3' ]; then
echo true;
else
echo false;
fi
}
display_options() {
clear
echo $DIVIDER
echo " Block R Provisioner"
echo $DIVIDER
if ! [ "$USER_MESSAGE" = "" ]; then
echo " $USER_MESSAGE"
echo $DIVIDER
fi
echo " 1) Provision $OPTION_1_TRAIL"
echo " 2) Start Nodes $OPTION_2_TRAIL"
echo " 3) Create Channel $OPTION_3_TRAIL"
echo " 4) Install Chaincode $OPTION_4_TRAIL"
echo " 5) Stop Nodes $OPTION_5_TRAIL"
echo ""
echo " ?) Help"
echo " q) Quit"
echo $DIVIDER
echo ""
read -p "Enter an option: " USER_OPTION
if [ "$USER_OPTION" = "q" -o "$USER_OPTION" = "Q" ]; then
clear
echo $DIVIDER
echo " Block R Provisioner"
echo $DIVIDER
echo " Goodbye"
echo $DIVIDER
echo ""
exit 0
else
case $USER_OPTION in
1) ./provision.sh
echo $DIVIDER
read -p "Hit Enter to return"
OPTION_1_TRAIL="*"
OPTION_1_TRAIL=""
OPTION_3_TRAIL="*"
OPTION_4_TRAIL="*"
OPTION_5_TRAIL="*"
USER_MESSAGE="All nodes are provisoned" ;;
2) ./start_nodes.sh
echo $DIVIDER
read -p "Hit Enter to return"
OPTION_1_TRAIL="*"
OPTION_2_TRAIL="*"
OPTION_3_TRAIL=""
OPTION_4_TRAIL="*"
OPTION_5_TRAIL=""
USER_MESSAGE="Nodes have started" ;;
3) ./create_channel.sh
echo $DIVIDER
read -p "Hit Enter to return"
OPTION_1_TRAIL="*"
OPTION_2_TRAIL="*"
OPTION_3_TRAIL="*"
OPTION_4_TRAIL=""
OPTION_5_TRAIL=""
USER_MESSAGE="Channel created" ;;
4) ./install_chaincode.sh
echo $DIVIDER
read -p "Hit Enter to return"
OPTION_1_TRAIL="*"
OPTION_2_TRAIL="*"
OPTION_3_TRAIL="*"
OPTION_4_TRAIL="*"
OPTION_5_TRAIL=""
USER_MESSAGE="Chaincode installed" ;;
5) ./stop_nodes.sh
echo $DIVIDER
read -p "Hit Enter to return"
OPTION_1_TRAIL=""
OPTION_2_TRAIL=""
OPTION_3_TRAIL="*"
OPTION_4_TRAIL="*"
OPTION_5_TRAIL="*"
USER_MESSAGE="Nodes have stopped" ;;
*) USER_MESSAGE=$(help_screen) ;;
esac
display_options
fi
}
if [ "$(run_status)" = "true" ]; then
USER_MESSAGE="Nodes are active"
OPTION_1_TRAIL="*"
OPTION_2_TRAIL="*"
OPTION_3_TRAIL="*"
OPTION_4_TRAIL="*"
OPTION_5_TRAIL=""
fi
display_options