forked from OlKurbatov/dlab_tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dlab
executable file
·295 lines (255 loc) · 11.1 KB
/
dlab
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#!/bin/bash
core_directory="$(dirname "$(readlink -f "$0")")"
number_of_nodes=2
#813X
zmq_rpc_port=813
#823X
rpc_port=823
#833X
port=833
ports_to_close=()
trap clear_up INT
function logo {
$core_directory/logo.sh
}
function clear_up {
printf "\n"
for port in "${ports_to_close[@]}"
do
printf "[*]Found open port $port, closing..."
sleep 1
fuser -k "$port/tcp" > /dev/null 2>&1
printf "Success!\n"
done
exit
}
function main_menu {
printf "0.Exit dlab\n1.Bitcoin\n2.Ethereum\n3.Monero\n4.EOS\n5.IPFS\n"
printf "Enter the number and confirm: "
}
#menu_choice
function menu1 {
printf "0.Go back\n"
$1
printf "Enter the number and confirm: "
}
function bitcoin_menu {
printf "1.Start multiple nodes on the local machine\n"
}
function ethereum_menu {
printf "1.Start multiple nodes on the local machine\n"
}
function eos_menu {
printf "1.Setup nodeos and keosd containers\n"
}
function monero_menu {
printf "1.Start multiple nodes on the local machine\n"
}
function ipfs_menu {
printf "1.Start ipfs daemon with console\n"
}
#tab1_name tab1_command tab2_name tab2_command
function open_terminal {
if [[ ! -z "$3" ]];then
xfce4-terminal --window -T $1 -e "$2" -H --tab -T $3 -e "$4" -H
else
xfce4-terminal --window -T $1 -e "$2" -H
fi
}
while true; do
clear
logo
main_menu
read system_name
if [ "$system_name" == "0" ]; then
exit
fi
#BITCOIN
if [ "$system_name" == "1" ]; then
clear
logo
menu1 bitcoin_menu
read bitcoin_ch
if [ "$bitcoin_ch" == "0" ]; then
continue
fi
if [ "$bitcoin_ch" == "1" ]; then
if [ -d "$core_directory/bitcoin/node0" ]; then
rm -r $core_directory/bitcoin/node*
fi
for (( i=0; i<$number_of_nodes; i++ ))
do
mkdir "$core_directory/bitcoin/node$i"
touch "$core_directory/bitcoin/node$i/bitcoin.conf"
echo [regtest] >> "$core_directory/bitcoin/node$i/bitcoin.conf"
echo regtest=1 >> "$core_directory/bitcoin/node$i/bitcoin.conf"
echo rpcuser="student$i" >> "$core_directory/bitcoin/node$i/bitcoin.conf"
echo rpcpassword="rpc" >> "$core_directory/bitcoin/node$i/bitcoin.conf"
echo port="$port$i" >> "$core_directory/bitcoin/node$i/bitcoin.conf"
echo rpcport="$rpc_port$i" >> "$core_directory/bitcoin/node$i/bitcoin.conf"
for (( j=0; j<$number_of_nodes; j++ ))
do
echo addnode=127.0.0.1:"$port$j" >> "$core_directory/bitcoin/node$i/bitcoin.conf"
done
open_terminal "node_console$i" "$core_directory/bitcoin/bitcoind -regtest -datadir=$core_directory/bitcoin/node$i/" "cli-console" "$core_directory/bitcoin/bitcoin-cli-layer $core_directory $core_directory/bitcoin/node$i/" &
ports_to_close+=( "$port$i" )
ports_to_close+=( "$rpc_port$i" )
done
while true; do
clear
logo
printf "0.Shutdown the deployed network and dlab\n"
printf "1.Add new node\n"
printf "If needed, enter the number and confirm: "
read bitcoin_sub_ch
if [ "$bitcoin_sub_ch" == "0" ]; then
clear_up
fi
if [ "$bitcoin_sub_ch" == "1" ]; then
mkdir "$core_directory/bitcoin/node"$(($number_of_nodes))
touch "$core_directory/bitcoin/node$(($number_of_nodes))/bitcoin.conf"
echo [regtest] >> "$core_directory/bitcoin/node$(($number_of_nodes))/bitcoin.conf"
echo regtest=1 >> "$core_directory/bitcoin/node$(($number_of_nodes))/bitcoin.conf"
echo rpcuser="student$(($number_of_nodes))" >> "$core_directory/bitcoin/node$(($number_of_nodes))/bitcoin.conf"
echo rpcpassword="rpc" >> "$core_directory/bitcoin/node$(($number_of_nodes))/bitcoin.conf"
echo port="$port$(($number_of_nodes))" >> "$core_directory/bitcoin/node$(($number_of_nodes))/bitcoin.conf"
echo rpcport="$rpc_port$(($number_of_nodes))" >> "$core_directory/bitcoin/node$(($number_of_nodes))/bitcoin.conf"
number_of_nodes=$(($number_of_nodes + 1))
for (( j=0; j<$number_of_nodes; j++ ))
do
echo addnode=127.0.0.1:"$port$j" >> "$core_directory/bitcoin/node$(($number_of_nodes - 1))/bitcoin.conf"
done
open_terminal "node_console$(($number_of_nodes - 1))" "$core_directory/bitcoin/bitcoind -regtest -datadir=$core_directory/bitcoin/node$(($number_of_nodes - 1))/" "cli-console" "$core_directory/bitcoin/bitcoin-cli-layer $core_directory $core_directory/bitcoin/node$(($number_of_nodes - 1))/" &
ports_to_close+=( "$port$(($number_of_nodes - 1))" )
ports_to_close+=( "$rpc_port$(($number_of_nodes - 1))" )
fi
done
fi
fi
#ETHEREUM
if [ "$system_name" == "2" ]; then
clear
logo
menu1 ethereum_menu
read ethereum_ch
if [ "$ethereum_ch" == "0" ]; then
continue
fi
if [ "$ethereum_ch" == "1" ]; then
if [ -d "$core_directory/ethereum/node0" ]; then
rm -r $core_directory/ethereum/node*
fi
for (( i=0; i<$number_of_nodes; i++ ))
do
mkdir "$core_directory/ethereum/node$i"
$core_directory/ethereum/geth --datadir $core_directory/ethereum/node$i/ init $core_directory/ethereum/GenesisBlock.json
start_command="$core_directory/ethereum/geth --identity node$i --datadir $core_directory/ethereum/node$i/ --networkid 2019 --port $port$i --rpc --rpcport $rpc_port$i console"
open_terminal "node_console" "$start_command" &
ports_to_close+=( "$port$i" )
ports_to_close+=( "$rpc_port$i" )
done
while true; do
clear
logo
printf "0.Shutdown the deployed network and dlab\n"
printf "1.Add new node\n"
printf "If needed, enter the number and confirm: "
read ethereum_sub_ch
if [ "$ethereum_sub_ch" == "0" ]; then
clear_up
fi
if [ "$ethereum_sub_ch" == "1" ]; then
mkdir "$core_directory/ethereum/node$number_of_nodes"
$core_directory/ethereum/geth --datadir $core_directory/ethereum/node$number_of_nodes/ init $core_directory/ethereum/GenesisBlock.json
start_command="$core_directory/ethereum/geth --identity node$number_of_nodes --datadir $core_directory/ethereum/node$number_of_nodes/ --networkid 2019 --port $port$number_of_nodes --rpc --rpcport $rpc_port$number_of_nodes console"
open_terminal "node_console" "$start_command" &
ports_to_close+=( "$port$number_of_nodes" )
ports_to_close+=( "$rpc_port$number_of_nodes" )
number_of_nodes=$(($number_of_nodes + 1))
fi
done
fi
fi
#MONERO
if [ "$system_name" == "3" ]; then
clear
logo
menu1 monero_menu
read monero_ch
if [ "$monero_ch" == "0" ]; then
continue
fi
if [ "$monero_ch" == "1" ]; then
if [ -d "$core_directory/monero/node0" ]; then
rm -r $core_directory/monero/node*
fi
for ((i=0; i<$number_of_nodes; i++))
do
start_command="$core_directory/monero/monerod --testnet --no-igd --allow-local-ip --data-dir $core_directory/monero/node$i --p2p-bind-ip 127.0.0.1 --log-level 0 --fixed-difficulty 100 --p2p-bind-port $port$i --rpc-bind-port $rpc_port$i --zmq-rpc-bind-port $zmq_rpc_port$i"
for ((j=0; j<10; j++))
do
add_nodes_string="--add-exclusive-node 127.0.0.1:$port$j"
start_command="$start_command $add_nodes_string"
done
wallet_create_command="$core_directory/monero/monero-wallet-cli --testnet --daemon-port $rpc_port$i --generate-new-wallet $core_directory/monero/node$i/walletfile.bin --password 'bit' "
open_terminal "node$i-console" "$start_command" "wallet$i-console" "$wallet_create_command" &
ports_to_close+=( "$port$i" )
ports_to_close+=( "$rpc_port$i" )
ports_to_close+=( "$zmq_rpc_port$i" )
done
while true; do
clear
logo
printf "0.Shutdown the deployed network and dlab\n"
printf "1.Add new node\n"
printf "If needed, enter the number and confirm: "
read monero_sub_ch
if [ "$monero_sub_ch" == "0" ]; then
clear_up
fi
if [ "$monero_sub_ch" == "1" ]; then
start_command="$core_directory/monero/monerod --testnet --no-igd --data-dir $core_directory/monero/node$number_of_nodes --p2p-bind-ip 127.0.0.1 --log-level 0 --fixed-difficulty 100 --p2p-bind-port $port$number_of_nodes --rpc-bind-port $rpc_port$number_of_nodes --zmq-rpc-bind-port $zmq_rpc_port$number_of_nodes"
wallet_create_command="$core_directory/monero/monero-wallet-cli --testnet --daemon-port $rpc_port$number_of_nodes --generate-new-wallet $core_directory/monero/node$number_of_nodes/walletfile.bin --password 'bit' "
for ((j=0; j<$number_of_nodes; j++))
do
add_nodes_string="--add-exclusive-node 127.0.0.1:$port$j"
start_command="$start_command $add_nodes_string"
done
add_nodes_string="--add-exclusive-node 127.0.0.1:$port$number_of_nodes"
start_command="$start_command $add_nodes_string"
ports_to_close+=( "$port$number_of_nodes" )
ports_to_close+=( "$rpc_port$number_of_nodes" )
ports_to_close+=( "$zmq_rpc_port$number_of_nodes" )
open_terminal "node$number_of_nodes-console" "$start_command" "wallet$number_of_nodes-command" "$wallet_create_command" &
number_of_nodes=$(($number_of_nodes + 1))
fi
done
fi
fi
#EOS
if [ "$system_name" == "4" ]; then
clear
logo
menu1 eos_menu
read eos_ch
if [ "$eos_ch" == "0" ]; then
continue
fi
if [ "$eos_ch" == "1" ]; then
$core_directory/eos/setup.sh
fi
fi
#IPFS
if [ "$system_name" == "5" ]; then
clear
logo
menu1 ipfs_menu
read ipfs_sub_ch
if [ "$ipfs_ch" == "0" ]; then
continue
fi
if [ "$ipfs_sub_ch" == "1" ]; then
open_terminal node_console "$core_directory/ipfs/ipfs daemon" cli_console "$core_directory/ipfs/ipfs-cli-layer.sh $core_directory" &
fi
fi
done