forked from dominant-strategies/quai-node-cli-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quai-admin.sh
executable file
·695 lines (668 loc) · 29.3 KB
/
quai-admin.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
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
#!/bin/bash
DIALOG_CANCEL=1
DIALOG_ESC=255
STYLECONFIG=~/.dialogrc
MAIN_DIR="quainetwork"
NODE_PROCESS="go-quai"
MINER_PROCESS="quai-cpu-miner"
if [ -f "$STYLECONFIG" ]; then
echo "Styling config found."
if cmp --silent "$STYLECONFIG" ".dialogrc"; then
echo "Styling config is up to date."
else
echo "Styling config is out of date."
cp .dialogrc ~/.dialogrc
fi
else
dialog --create-rc $STYLECONFIG
cp .dialogrc ~/.dialogrc
fi
if command -v go 2>/dev/null; then
:
else
dialog --title "Installation" --msgbox "\nGolang is not installed. \nPlease install to run this script." 0 0
echo "Golang can be installed at https://go.dev/doc/install"
exit
fi
if command -v git 2>/dev/null; then
:
else
dialog --title "Installation" --msgbox "\nGit is not installed. \nPlease install to run this script." 0 0
echo "Git can be installed at https://github.com/git-guides/install-git"
exit
fi
# Check installation status, if not found, prompt the user to install.
if [[ -d "$HOME/$MAIN_DIR/go-quai" && -d "$HOME/$MAIN_DIR/quai-cpu-miner" ]]; then
:
else
# Check if user has configured wallet addresses
dialog --title "Installation" --yesno "\nHave you configured 13 Quai addresses? \nYou'll need them to run a node and mine." 0 0
response=$?
case $response in
0) : ;;
1)
# Inform user to configure addresses
dialog --title "Installation" --msgbox "\nPlease configure your wallet addresses before continuing." 0 0
echo "You can set up addresses here: https://docs.quai.network/use-quai/wallets/quaisnap"
exit
;;
255)
exit
;;
esac
# Check if user wants to install
dialog --title "Installation" --yesno "\nThis will install go-quai and quai-cpu-miner in the home directory.\n \nContinue?" 0 0
response=$?
case $response in
0)
# Create directory
cd $HOME
mkdir $MAIN_DIR
# Clone into go-quai
cd $MAIN_DIR
git clone https://github.com/dominant-strategies/go-quai>/dev/null 2>&1 | \
dialog --title "Installation" \
--no-collapse \
--infobox "\nInstalling Node. Please wait." 7 28
#Inform user node is installed
dialog --title "Installation" \
--no-collapse \
--msgbox "\nNode installed.\n \nPress OK to continue." 7 28
#Configure go-quai
cd $HOME/$MAIN_DIR/go-quai
cp network.env.dist network.env
make go-quai>/dev/null 2>&1 |
dialog --title "Installation" \
--no-collapse \
--infobox "\nGenerating binaries.\n \nPlease wait. " 7 28
#Inform user node is configured
dialog --title "Installation" \
--no-collapse \
--msgbox "\nNode configured.\n \nPress OK to continue." 0 0
# Clone into quai-cpu-miner
cd $HOME/$MAIN_DIR
git clone https://github.com/dominant-strategies/quai-cpu-miner>/dev/null 2>&1 | \
dialog --title "Installation" \
--no-collapse \
--infobox "\nInstalling Miner.\n \nPlease wait." 7 28
#Inform user cpu-miner is installed
dialog --title "Installation" \
--no-collapse \
--msgbox "\nMiner installed.\n \nPress OK to continue." 7 28
#Configure quai-cpu-miner
cd $HOME/$MAIN_DIR/quai-cpu-miner/config
cp config.yaml.dist config.yaml
cd $HOME/$MAIN_DIR/quai-cpu-miner
make quai-cpu-miner>/dev/null 2>&1 | \
dialog --title "Installation"
--no-collapse \
--infobox "\nGenerating binaries.\n \nPlease wait. " 7 28
#Inform user miner is configured
dialog --title "Installation" \
--no-collapse \
--msgbox "\nMiner configured.\n \nInstallation complete." 0 0
;;
1)
echo "Installation cancelled."
exit ;;
255)
echo "Installation cancelled."
exit ;;
esac
fi
while true; do
if [ -d "$HOME/quainetwork/go-quai/nodelogs" ]; then
NODELOGS="True"
else
NODELOGS="False"
fi
if [ -d "$HOME/quainetwork/quai-cpu-miner/logs" ]; then
MININGLOGS="True"
else
MININGLOGS="False"
fi
# Check if node is running
if pgrep -x "$NODE_PROCESS">/dev/null 2>&1; then
ISRUNNING="True"
STARTFULLNODE="Node - \Z2Running\Zn"
else
ISRUNNING="False"
STARTFULLNODE="Start Node - \Z1Stopped\Zn"
fi
# Check if miner is running
if pgrep -x "$MINER_PROCESS">/dev/null 2>&1; then
ISMINING="True"
STARTMINING="Miner - \Z2Running\Zn"
else
ISMINING="False"
STARTMINING="Start Miner - \Z1Stopped\Zn"
fi
exec 3>&1
selection=$(dialog \
--backtitle "Quai Hardware Manager" \
--clear \
--colors \
--cancel-label "EXIT" \
--menu "Select an Option:" 17 50 10 \
"1" "$STARTFULLNODE" \
"2" "$STARTMINING" \
"3" "Stop" \
"4" "Update" \
"5" "Node Logs" \
"6" "Miner Logs" \
"7" "Edit Mining Addresses" \
"8" "Edit Config Variables" \
"9" "Clear logs & db" \
2>&1 1>&3)
exit_status=$?
exec 3>&-
case $exit_status in
$DIALOG_CANCEL)
# Verify the user wants to stop their node and miner
dialog --title "Alert" --colors --yesno "\nExit the Quai Hardware Manager?\n \n\Z1This will stop your node and miner.\Zn" 0 0
response=$?
EXIT="False"
case $response in
0) EXIT="True";;
1) EXIT="False";;
255) EXIT="False";;
esac
if [ $EXIT = "True" ]; then
#If user chooses stop, kill node
cd $HOME/quainetwork/quai-cpu-miner
make stop>/dev/null 2>&1
cd $HOME/quainetwork/go-quai
make stop>/dev/null 2>&1 | \
dialog --title "Stop" \
--no-collapse \
--infobox "\nStopping Node and/or Miner.\n \nPlease wait." 0 0
clear
echo "Quai Hardware Manager stopped."
exit
fi
;;
$DIALOG_ESC)
# Verify the user wants to stop their node and miner
dialog --title "Alert" --yesno "\nExit the Quai Hardware Manager?\n \n\Z1This will stop your node and miner.\Zn" 0 0
response=$?
EXIT="False"
case $response in
0) EXIT="True";;
1) EXIT="False";;
255) EXIT="False";;
esac
if [ $EXIT = "True" ]; then
#If user chooses stop, kill node
cd $HOME/quainetwork/quai-cpu-miner
make stop>/dev/null 2>&1
cd $HOME/quainetwork/go-quai
make stop>/dev/null 2>&1 | \
dialog --title "Stop" \
--no-collapse \
--infobox "\nStopping Node and/or Miner.\n \nPlease wait." 0 0
clear
echo "Quai Hardware Manager stopped."
exit
fi
;;
esac
case $selection in
1 )
#If node is running, redirect back to menu
if [ $ISRUNNING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nNode is already running." 0 0
else
# Start go-quai
cd $HOME/quainetwork/go-quai && make run-all >/dev/null 2>&1 | \
dialog --title "Node" \
--no-collapse \
--infobox "\nStarting Node.\n \nPlease wait." 0 0
# Ask the user if they would like to view nodelogs
dialog --title "Alert" \
--no-collapse \
--yesno "\nWould you like to view the last 40 lines of your nodelogs?" 0 0
response=$?
case $response in
0)
#Print nodelogs
cd
LOCATION=$(dialog --nocancel --menu "In which location would you like to view nodelogs?" 0 0 13 \
1 "Prime" \
2 "Cyprus" \
3 "Paxos" \
4 "Hydra" \
5 "Cyprus-1" \
6 "Cyprus-2" \
7 "Cyprus-3" \
8 "Paxos-1" \
9 "Paxos-2" \
10 "Paxos-3" \
11 "Hydra-1" \
12 "Hydra-2" \
13 "Hydra-3" 3>&1 1>&2 2>&3 3>&- )
case $LOCATION in
1)
FILE="quainetwork/go-quai/nodelogs/prime.log"
;;
2)
FILE="quainetwork/go-quai/nodelogs/region-0.log"
;;
3)
FILE="quainetwork/go-quai/nodelogs/region-1.log"
;;
4)
FILE="quainetwork/go-quai/nodelogs/region-2.log"
;;
5)
FILE="quainetwork/go-quai/nodelogs/zone-0-0.log"
;;
6)
FILE="quainetwork/go-quai/nodelogs/zone-0-1.log"
;;
7)
FILE="quainetwork/go-quai/nodelogs/zone-0-2.log"
;;
8)
FILE="quainetwork/go-quai/nodelogs/zone-1-0.log"
;;
9)
FILE="quainetwork/go-quai/nodelogs/zone-1-1.log"
;;
10)
FILE="quainetwork/go-quai/nodelogs/zone-1-2.log"
;;
11)
FILE="quainetwork/go-quai/nodelogs/zone-2-0.log"
;;
12)
FILE="quainetwork/go-quai/nodelogs/zone-2-1.log"
;;
13)
FILE="quainetwork/go-quai/nodelogs/zone-2-2.log"
;;
esac
result=`tail -40 $FILE`
dialog --cr-wrap --title "$FILE" --no-collapse --msgbox "\n$result" 30 90
;;
1) clear;;
255) clear;;
esac
fi
;;
2 )
#If miner is running, redirect back to menu
if [ $ISMINING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nMiner is already running." 0 0
elif [ $ISRUNNING = "False" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease start your Node before starting the Miner." 0 0
else
REGION=$(dialog --nocancel --menu "Which region would you like to mine?" 0 0 3 \
1 "Cyprus" \
2 "Paxos" \
3 "Hydra" 3>&1 1>&2 2>&3 3>&- )
ZONE=$(dialog --nocancel --menu "Which region would you like to mine?" 0 0 3 \
1 "Zone-1" \
2 "Zone-2" \
3 "Zone-3" 3>&1 1>&2 2>&3 3>&- )
# Start miner
REGION=$(($REGION-1))
ZONE=$(($ZONE-1))
cd $HOME/quainetwork/quai-cpu-miner && make run-mine-background region=$REGION zone=$ZONE >/dev/null 2>&1 | \
dialog --title "Miner" \
--no-collapse \
--infobox "\nStarting Miner.\n \nPlease wait." 0 0
# Ask the user if they would like to view miner logs
dialog --title "Alert" \
--no-collapse \
--yesno "\nWould you like to view the last 40 lines of your miner logs?" 0 0
response=$?
case $response in
0)
# Print miner logs
cd
result=`tail -40 quainetwork/quai-cpu-miner/logs/slice-$REGION-$ZONE.log`
dialog --cr-wrap --title "quainetwork/quai-cpu-miner/logs/slice-$REGION-$ZONE.log" --msgbox "\n$result" 30 90
;;
1) clear;;
255) clear;;
esac
fi
;;
3 )
# Verify the user wants to stop their node and miner
dialog --title "Alert" --colors --yesno "\n\Z1Are you sure you want to stop the Node and/or Miner?\Zn" 0 0
response=$?
STOP="False"
case $response in
0) STOP="True";;
1) STOP="False";;
255) STOP="False";;
esac
if [ $STOP = "True" ]; then
#If user chooses stop, kill node
cd $HOME/$MAIN_DIR/quai-cpu-miner
make stop>/dev/null 2>&1
cd $HOME/$MAIN_DIR/go-quai
make stop>/dev/null 2>&1 | \
dialog --title "Stop" \
--no-collapse \
--infobox "\nStopping Node and/or Miner.\n \nPlease wait." 0 0
dialog --title "Stop" \
--no-cancel \
--msgbox "\nNode and/or Miner stopped.\n \nPress OK to return to the menu." 0 0
fi
;;
4 )
# Update go-quai
if [ $ISMINING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease stop your node and miner to update." 0 0
elif [ $ISRUNNING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease stop your node and miner to update." 0 0
else
cd $HOME/$MAIN_DIR/go-quai
git pull>/dev/null 2>&1 | \
dialog --title "Update" \
--no-collapse \
--infobox "\nUpdating Node.\n \nPlease wait." 0 0
make go-quai>/dev/null 2>&1 | \
dialog --title "Update" \
--no-collapse \
--infobox "\nUpdating Node.\n \nPlease wait." 0 0
dialog --title "Update" \
--no-collapse \
--msgbox "\nNode updated.\n \nPress OK to continue." 0 0
# Update quai-cpu-miner
cd $HOME/$MAIN_DIR/quai-cpu-miner
git pull>/dev/null 2>&1 | \
dialog --title "Update" \
--no-collapse \
--infobox "\nUpdating Miner.\n \nPlease wait." 0 0
make quai-cpu-miner>/dev/null 2>&1 | \
dialog --title "Update" \
--no-collapse \
--infobox "\nUpdating Miner.\n \nPlease wait." 0 0
dialog --title "Update" \
--no-collapse \
--msgbox "\nMiner updated.\n \nPress OK to return to the menu." 0 0
fi
;;
5 )
if [ $NODELOGS = "False" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease start your node before viewing nodelogs." 0 0
else
#Print nodelogs
cd
LOCATION=$(dialog --nocancel --menu "In which location would you like to view nodelogs?" 0 0 13 \
1 "Prime" \
2 "Cyprus" \
3 "Paxos" \
4 "Hydra" \
5 "Cyprus-1" \
6 "Cyprus-2" \
7 "Cyprus-3" \
8 "Paxos-1" \
9 "Paxos-2" \
10 "Paxos-3" \
11 "Hydra-1" \
12 "Hydra-2" \
13 "Hydra-3" 3>&1 1>&2 2>&3 3>&- )
case $LOCATION in
1)
FILE="quainetwork/go-quai/nodelogs/prime.log"
;;
2)
FILE="quainetwork/go-quai/nodelogs/region-0.log"
;;
3)
FILE="quainetwork/go-quai/nodelogs/region-1.log"
;;
4)
FILE="quainetwork/go-quai/nodelogs/region-2.log"
;;
5)
FILE="quainetwork/go-quai/nodelogs/zone-0-0.log"
;;
6)
FILE="quainetwork/go-quai/nodelogs/zone-0-1.log"
;;
7)
FILE="quainetwork/go-quai/nodelogs/zone-0-2.log"
;;
8)
FILE="quainetwork/go-quai/nodelogs/zone-1-0.log"
;;
9)
FILE="quainetwork/go-quai/nodelogs/zone-1-1.log"
;;
10)
FILE="quainetwork/go-quai/nodelogs/zone-1-2.log"
;;
11)
FILE="quainetwork/go-quai/nodelogs/zone-2-0.log"
;;
12)
FILE="quainetwork/go-quai/nodelogs/zone-2-1.log"
;;
13)
FILE="quainetwork/go-quai/nodelogs/zone-2-2.log"
;;
esac
result=`tail -40 $FILE`
dialog --cr-wrap --title "$FILE" --msgbox "\n$result" 0 0
fi
;;
6 )
if [ $MININGLOGS = "False" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease start your miner before viewing logs." 0 0
else
# Print Miner Logs
REGION=$(dialog --nocancel --menu "Which region would you like to view logs for?" 0 0 3 \
1 "Cyprus" \
2 "Paxos" \
3 "Hydra" 3>&1 1>&2 2>&3 3>&- )
ZONE=$(dialog --nocancel --menu "Which region would you like to view logs for?" 0 0 3 \
1 "Zone-1" \
2 "Zone-2" \
3 "Zone-3" 3>&1 1>&2 2>&3 3>&- )
# Start miner
REGION=$(($REGION-1))
ZONE=$(($ZONE-1))
cd
result=`tail -40 quainetwork/quai-cpu-miner/logs/slice-$REGION-$ZONE.log`
dialog --cr-wrap --title "quainetwork/quai-cpu-miner/logs/slice-$REGION-$ZONE.log" --msgbox "\n$result" 30 90
fi
;;
7 )
# Edit coinbase addresses in network.env
if [ $ISMINING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease stop your node and miner to edit mining addresses." 0 0
elif [ $ISRUNNING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease stop your node and miner to edit mining addresses." 0 0
else
cd $HOME/quainetwork/go-quai
LOCATION=$(dialog --colors --menu "Which mining address would you like to edit?\n \n\Z1Note: Entering an incorrect address will either break your node or send rewards to another user.\Zn" 0 0 13 \
1 "Prime" \
2 "Cyprus" \
3 "Paxos" \
4 "Hydra" \
5 "Cyprus-1" \
6 "Cyprus-2" \
7 "Cyprus-3" \
8 "Paxos-1" \
9 "Paxos-2" \
10 "Paxos-3" \
11 "Hydra-1" \
12 "Hydra-2" \
13 "Hydra-3" 3>&1 1>&2 2>&3 3>&- )
case $LOCATION in
1)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Prime mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^PRIME_COINBASE *=.*/PRIME_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Prime address updated." 0 0
;;
2)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Cyprus mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^REGION_0_COINBASE *=.*/REGION_0_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Cyprus address updated." 0 0
;;
3)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Paxos mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^REGION_1_COINBASE *=.*/REGION_1_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Paxos address updated." 0 0
;;
4)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Hydra mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^REGION_2_COINBASE *=.*/REGION_2_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Hydra address updated." 0 0
;;
5)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Cyprus-1 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_0_0_COINBASE *=.*/ZONE_0_0_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Cyprus-1 address updated." 0 0
;;
6)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Cyprus-2 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_0_1_COINBASE *=.*/ZONE_0_1_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Cyprus-2 address updated." 0 0
;;
7)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Cyprus-3 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_0_2_COINBASE *=.*/ZONE_0_2_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Cyprus-3 address updated." 0 0
;;
8)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Paxos-1 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_1_0_COINBASE *=.*/ZONE_1_0_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Paxos-1 address updated." 0 0
;;
9)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Paxos-2 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_1_1_COINBASE *=.*/ZONE_1_1_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Paxos-2 address updated." 0 0
;;
10)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Paxos-3 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_1_2_COINBASE *=.*/ZONE_1_2_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Paxos-3 address updated." 0 0
;;
11)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Hydra-1 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_2_0_COINBASE *=.*/ZONE_2_0_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Hydra-1 address updated." 0 0
;;
12)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Hydra-2 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_2_1_COINBASE *=.*/ZONE_2_1_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Hydra-2 address updated." 0 0
;;
13)
ADDRESS=$(dialog --nocancel --inputbox "Enter your Hydra-3 mining address:" 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ZONE_2_2_COINBASE *=.*/ZONE_2_2_COINBASE=$ADDRESS/" network.env | dialog --msgbox "Hydra-3 address updated." 0 0
;;
esac
rm -rf network.env.save
fi
;;
8)
if [ $ISMINING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease stop your node and miner to edit your config file." 0 0
elif [ $ISRUNNING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease stop your node and miner to edit your config file." 0 0
else
cd $HOME/quainetwork/go-quai
LOCATION=$(dialog --colors --menu "Which config variable would you like to edit?\n \n\Z1Note: do not change these values without knowing what they do.\Zn" 0 0 13 \
1 "ENABLE_HTTP" \
2 "ENABLE_WS" \
3 "ENABLE_UNLOCK" \
4 "ENABLE_ARCHIVE" \
5 "NETWORK" \
6 "HTTP_ADDR" \
7 "WS_ADDR" \
8 "WS_API" \
9 "HTTP_API" \
10 "QUAI_MINING" \
11 "THREADS" 3>&1 1>&2 2>&3 3>&- )
case $LOCATION in
1)
ENABLE_HTTP=$(dialog --nocancel --inputbox "Input desired value for ENABLE_HTTP (true/false). " 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ENABLE_HTTP *=.*/ENABLE_HTTP=$ENABLE_HTTP/" network.env | dialog --msgbox "ENABLE_HTTP set to $ENABLE_HTTP" 0 0
;;
2)
ENABLE_WS=$(dialog --nocancel --inputbox "Input desired value for ENABLE_WS (true/false). " 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ENABLE_WS *=.*/ENABLE_WS=$ENABLE_WS/" network.env | dialog --msgbox "ENABLE_WS set to $ENABLE_WS" 0 0
;;
3)
ENABLE_UNLOCK=$(dialog --nocancel --inputbox "Input desired value for ENABLE_UNLOCK (true/false). " 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ENABLE_UNLOCK *=.*/ENABLE_UNLOCK=$ENABLE_UNLOCK/" network.env | dialog --msgbox "ENABLE_UNLOCK set to $ENABLE_UNLOCK" 0 0
;;
4)
ENABLE_ARCHIVE=$(dialog --nocancel --inputbox "Input desired value for ENABLE_ARCHIVE (true/false). " 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^ENABLE_ARCHIVE *=.*/ENABLE_ARCHIVE=$ENABLE_ARCHIVE/" network.env | dialog --msgbox "ENABLE_ARCHIVE set to $ENABLE_ARCHIVE" 0 0
;;
5)
NETWORK=$(dialog --nocancel --inputbox "Input desired value for NETWORK. Options include colosseum (testnet), garden (devnet), and local." 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^NETWORK *=.*/NETWORK=$NETWORK/" network.env | dialog --msgbox "NETWORK set to $NETWORK" 0 0
;;
6)
HTTP_ADDR=$(dialog --nocancel --inputbox "Input desired value for HTTP_ADDR. Options include 0.0.0.0 and 127.0.0.1 (localhost)." 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^HTTP_ADDR *=.*/HTTP_ADDR=$HTTP_ADDR/" network.env | dialog --msgbox "HTTP_ADDR set to $HTTP_ADDR" 0 0
;;
7)
WS_ADDR=$(dialog --nocancel --inputbox "Input desired value for WS_ADDR. Options include 0.0.0.0 and 127.0.0.1 (localhost)." 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^WS_ADDR *=.*/WS_ADDR=$WS_ADDR/" network.env | dialog --msgbox "WS_ADDR set to $WS_ADDR" 0 0
;;
8)
WS_API=$(dialog --nocancel --inputbox "Input desired value for WS_API. Options include debug, net, quai, and txpool." 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^WS_API *=.*/WS_API=$WS_API/" network.env | dialog --msgbox "WS_API set to $WS_API" 0 0
;;
9)
HTTP_API=$(dialog --nocancel --inputbox "Input desired value for HTTP_API. Options include debug, net, quai, and txpool." 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^HTTP_API *=.*/HTTP_API=$HTTP_API/" network.env | dialog --msgbox "HTTP_API set to $HTTP_API" 0 0
;;
10)
QUAI_MINING=$(dialog --nocancel --inputbox "Input desired value for QUAI_MINING (true/false). " 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^QUAI_MINING *=.*/QUAI_MINING=$QUAI_MINING/" network.env | dialog --msgbox "QUAI_MINING set to $QUAI_MINING" 0 0
;;
11)
THREADS=$(dialog --nocancel --inputbox "Input desired value for THREADS. Set this lower than the number of threads your machine has for best performance." 0 0 3>&1 1>&2 2>&3 3>&-)
sed -i.save "s/^THREADS *=.*/THREADS=$THREADS/" network.env | dialog --msgbox "THREADS set to $THREADS" 0 0
;;
esac
rm -rf network.env.save
fi
;;
9)
# Clear db
if [ $ISMINING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease stop your node and miner to clear the db." 0 0
elif [ $ISRUNNING = "True" ]; then
dialog --title "Alert" \
--no-collapse \
--msgbox "\nPlease stop your node and miner to clear the db." 0 0
else
dialog --colors --yesno "Are you sure you want to clear your database and logs?\n \n\Z1Warning: This will fully reset your node and miner.\Zn" 0 0
if [ $? -eq 0 ]; then
cd $HOME/quainetwork/go-quai
rm -rf nodelogs
rm -rf ~/Library/Quai
yes | ./build/bin/quai removedb
cd $HOME/quainetwork/quai-cpu-miner
rm -rf logs
dialog --cr-wrap --msgbox "Database cleared. Node and miner logs removed." 0 0
fi
fi
;;
esac
done