-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
2348 lines (1561 loc) · 54.5 KB
/
setup.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
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
trap ctrl_c SIGINT
clear
if ! command -v dialog &> /dev/null; then
echo -e "\ndialog package, a required dependency could not be found.\n\nInstalling..."
sudo apt-get update && sudo apt-get install -y dialog
fi
function ctrl_c() {
case "$current_menu" in
"under_node")
main_menu
;;
"under_install")
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "ABORTED!!!" \
--msgbox "\nThe installation process was aborted.\n\n$pick INSTALLATION FAILED" 9 45
main_menu
;;
"under_monitor")
main_menu
;;
"monitor_info")
monitor_menu
;;
"under_monitor_info")
monitor_info
;;
"under_prune")
monitor_menu
;;
"validator_menu")
main_menu
;;
"validator_options")
validator_menu
;;
"under_remove")
main_menu
;;
"under_wallet")
main_menu
;;
"wallet_menu")
main_menu
;;
"under_main")
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "QUIT!!!" \
--yesno "\nAre you sure you want to quit?" 7 50
if [ $? -eq 0 ]; then
clear
exit 0
else
main_menu
fi
;;
*)
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "QUIT!!!" \
--yesno "\nAre you sure you want to quit?" 7 50
if [ $? -eq 0 ]; then
clear
exit 0
else
clear
go_verify
fi
;;
esac
sleep 4
main_menu
}
current_menu=""
current_dir=$(pwd)
colored_text() {
local color=$1
local text=$2
echo -n -e "\e[${color}m${text}\e[0m"
}
if [[ $EUID -eq 0 ]]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--msgbox "\nThis script cannot be run with sudo. \n\nRun the command as: ./nodeinstaller.sh" 10 50
clear
exit 1
fi
if ! command -v ping &> /dev/null; then
sudo apt-get update && sudo apt-get install -y iputils-ping
fi
if ! ping -c 1 google.com >/dev/null 2>&1; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--msgbox "\nNo internet connection. \n\nPlease check your internet connection and try again." 10 50
clear
exit 1
fi
check_dir() {
if [ ! -d "$DAEMON_HOME/$CHAIN_DIR" ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\n$pick Node is not installed..." 5 40
sleep 3
main_menu
return
fi
}
check_service_no_running() {
if ! systemctl is-active --quiet "$CHAIN_NAME.service"; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--msgbox "\n$pick Node Service is not running...\n\n\nPlease start it first.:\n\nNode Operations Menu -> \"Start Node\" option" 12 55
monitor_menu
fi
}
check_service_running() {
if systemctl is-active --quiet "$CHAIN_NAME.service"; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\n$pick Node Service is already running..." 6 55
sleep 3
monitor_menu
fi
}
chains_dir="chains"
chains_options=()
for file in "$chains_dir"/*; do
chain_name_ext=$(basename "$file")
chain_name_noext="${chain_name_ext%.*}"
chains_options+=("$chain_name_noext" "")
done
check_wallets() {
if [ -z "$(ls -A "$DAEMON_HOME/$CHAIN_DIR"/*.info 2>/dev/null)" ]; then
dialog \
--clear \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--msgbox "\nNo wallets have been created so far.\n\nPlease create a wallet first." 9 40
wallet_menu
fi
if [ -z $CURRENT_WALLET_ADDR ] && [ -z $WALLET_NAME ]; then
dialog \
--clear \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--msgbox "\nYou must choose a wallet first to interact with it.\n\nPlease choose a wallet in the Wallet Menu >> Choose Wallet option" 11 40
wallet_menu
fi
}
confirm_prune() {
current_menu="under_prune"
if [ -d "$DAEMON_HOME/$CHAIN_DIR/data" ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "PRUNE NODE BLOCKCHAIN" \
--defaultno \
--yesno "\nThis option removes all blockchain data for $pick Node, (Node config files will remain).\n\nThen it will download the latest snapshot from $SNAP_URL\n\nFinally, it will extract it and restart the Node with a smaller disk space usage.\n\n\nARE YOU SURE YOU WANT TO PROCEED?\n\n" 15 110
if [ $? -eq 0 ]; then
clear
prune_node
elif [ $? -eq 1 ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nCanceled. Returning to Main menu..." 5 40
sleep 3
main_menu
else
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nAn unexpected error has occurred..." 5 40
sleep 3
main_menu
fi
elif [ ! -d "$DAEMON_HOME/$CHAIN_DIR/data" ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--infobox "\n$pick Node data folder is not installed..." 5 40
sleep 3
monitor_menu
else
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nAn unexpected error has occurred..." 5 50
sleep 3
monitor_menu
fi
}
prune_node() {
snap_file=$(basename "$SNAP_URL")
current_menu="under_prune"
colored_text "36;1" "Stopping $CHAIN_NAME service...
"
sudo systemctl stop $CHAIN_NAME.service
colored_text "36;1" "
Backing up (priv_validator_state.json) to $DAEMON_HOME/$CHAIN_DIR/
"
cp -v $DAEMON_HOME/$CHAIN_DIR/data/priv_validator_state.json $DAEMON_HOME/$CHAIN_DIR/priv_validator_state.json
colored_text "32" "
Files SAVED to $DAEMON_HOME/$CHAIN_DIR
"
colored_text "32;1" "
Press any key to continue...
"
read -p ""
clear
colored_text "36;1" "Removing $pick Blockchain database files...
"
rm -rfv $DAEMON_HOME/$CHAIN_DIR/data/
colored_text "32;1" "
All Blockchain files have been removed...
"
colored_text "36;1" "
Downloading latest $pick snapshot from NexuSecurus Servers...
"
wget -O $snap_file $SNAP_URL --inet4-only
colored_text "36;1" "
Extracting snapshot to $DAEMON_HOME/$CHAIN_DIR
"
if [[ $snap_file == *.tar.gz ]]; then
tar -xvf $snap_file -C $DAEMON_HOME/$CHAIN_DIR
elif [[ $snap_file == *.lz4 ]]; then
lz4 -c -d $snap_file | tar -xv -C $DAEMON_HOME/$CHAIN_DIR
else
coloror_text "31;1" "
Error: Unsupported compression snapshot format. Only .tar.gz and .lz4 are supported...
INSTALLATION ABORTED!!!
Press any key to exit...
"
read -p ""
main_menu
fi
colored_text "36;1" "
Removing $snap_file snapshot...
"
rm -rfv $snap_file
colored_text "36;1" "
Replacing (priv_validator_state.json) with backup...
"
mv -v $DAEMON_HOME/$CHAIN_DIR/priv_validator_state.json $DAEMON_HOME/$CHAIN_DIR/data/priv_validator_state.json
colored_text "36;1" "
Restarting $CHAIN_NAME service...
"
sudo systemctl start $CHAIN_NAME.service
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--msgbox "\n$pick Node has been successfully pruned..." 6 50
monitor_menu
}
chain_list() {
current_menu="under_chain"
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "Chain List" \
--cancel-label "Exit" \
--menu "\nSelect a chain to interact:\n" 20 50 5 "${chains_options[@]}" \
3>&1 1>&2 2>&3
if [ $? -ne 0 ]; then
clear
exit 1
fi
}
main_menu() {
current_menu="under_main"
choice=$(dialog --clear \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "Main Menu" \
--cancel-label "Exit" \
--menu "\nSelected Chain: $pick\n\nPlease select an option:\n" 20 60 8 \
"1" "Install Node" \
"2" "Node Operations" \
"3" "Wallet Operations" \
"4" "Validator Operations" \
"5" "Change Chain" \
"0" "Exit" \
3>&1 1>&2 2>&3)
if [ $? -ne 0 ]; then
clear
exit 0
fi
case $choice in
1)
install_node $pick ;;
2)
monitor_menu $pick ;;
3)
wallet_menu $pick;;
4)
validator_menu $pick ;;
5)
go_verify ;;
0)
clear
exit 0 ;;
esac
}
update_environment() {
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--msgbox "\nIn the next screen, you might be propmted to enter your sudo password" 7 75
dependencies_install
}
dependencies_install() {
clear
sudo apt update
if [ $? -eq 0 ]; then
sudo apt dist-upgrade -y
sudo apt install -y \
ntpdate \
curl \
wget \
git \
make \
cmake \
jq \
build-essential \
gcc \
snapd \
lz4 \
ufw \
xclip \
bc \
qrencode \
# Check if installation was successful
if [ $? -eq 0 ]; then
colored_text "32;1" "
System Update was successful!"
sleep 2
else
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nSystem update has failed..." 5 35
sleep 3
clear
exit 0
fi
else
dialog \
--title "WARNING!!!" \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--infobox "\nSystem update has failed or was aborted by the User..." 5 60
sleep 3
clear
exit 0
fi
sleep 3
}
go_verify() {
source_profile
if ! command -v go &> /dev/null; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--msgbox "\nThis is the first time you are running this program.\n\nSome dependencies need to be installed.\n\n\nPLEASE BE PATIENT..." 11 70
clear
update_environment
go_install
else
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WELCOME" \
--infobox "\nWelcome to NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" 5 85
sleep 3
current_menu="under_chain"
pick=$(chain_list)
if [ $? -ne 0 ]; then
clear
exit 0
fi
source "$current_dir/chains/$pick.txt"
chain_file="$current_dir/chains/$pick.txt"
main_menu
fi
}
source_profile() {
source ~/.profile
}
go_install() {
current_menu="fisrt_setup"
clear
colored_text "36;1" "The program will now check additional required dependencies...
"
sudo rm -rfv /usr/local/go
clear
colored_text "36;1" "Downloading GO v1.20...
"
wget https://go.dev/dl/go1.20.linux-amd64.tar.gz
clear
colored_text "36;1" "Installing GO v1.20...
"
sudo tar -C /usr/local -xvzf "go1.20.linux-amd64.tar.gz"
rm go1.20.linux-amd64.tar.gz
# Set environment variables in .profile
clear
echo "export GOROOT=/usr/local/go" >> ~/.profile
echo "export GOPATH=$HOME/go" >> ~/.profile
echo "export GO111MODULE=on" >> ~/.profile
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.profile # Upda environment variables systemwide
source_profile # save go version to variable
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "SUCCESS!!!" \
--pause "\nFirst time setup was successful.\n\nSystem will now reboot in 5 seconds..." 15 65 5
if [ $? -eq 0 ]; then
clear
sudo reboot
else
clear
main_menu
fi
}
install_node() {
current_menu="under_node"
if [ -d "$DAEMON_HOME/$CHAIN_DIR" ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--msgbox "\n$pick Node is already installed.\n\n\nTo reinstall it, remove it first, using the Remove Node Menu." 10 70
main_menu
return
fi
edited_content=$(dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "Edit file" \
--editbox "$chain_file" 80 120 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
echo "$edited_content" > "$chain_file"
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--infobox "\nFile saved successfully.\n\n$pick will use these settings..." 7 50
sleep 3
elif [ $? -eq 1 ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nThe installation process was canceled..." 5 45
sleep 3
main_menu
else
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nAn unexpected error has occurred..." 5 45
sleep 3
main_menu
fi
source "$chain_file"
if [ "$MONIKER" = "defaultmoniker" ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "CANNOT PROCEED" \
--msgbox "\nTo proceed, you must change the default MONIKER name in file:\n\n$chain_file" 11 65
main_menu
fi
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "PROCEED?" \
--defaultno \
--pause "\nNode installation will start in 10 seconds\n\nPress Cancel to abort the installation." 12 75 10
if [ $? -eq 0 ]; then
clear
install_chain
elif [ $? -eq 1 ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nAborted. Returning to Main menu..." 5 45
sleep 3
main_menu
else
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nAn unexpected error has occurred..." 5 45
sleep 3
main_menu
fi
}
monitor_menu() {
current_menu="under_monitor"
check_dir
if ! systemctl is-active --quiet "$CHAIN_NAME.service"; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--msgbox "\n$pick Node Service is not running...\n\nSome monitoring options will not display any data..." 9 60
start="STOPPED"
mon="(Limited)"
else
start="RUNNING"
mon=""
fi
if [ $start = "STOPPED" ]; then
sync="NODE STOPPED "
else
output=$($DAEMON_NAME status 2>&1 | jq .SyncInfo)
sync=$(echo "$output" | jq -r '.catching_up')
if [ "$sync" = "false" ]; then
sync="FULLY SYNCRONIZED"
elif [ "$sync" = "true" ]; then
sync="CATCHING UP"
else
sync="NOT SYNCING"
fi
fi
option=$(dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "Monitor Menu" \
--cancel-label "Back" \
--menu "\n$pick Node Service Status: "$start"\n\nNode Sync Status: $sync\n" 20 50 5 \
"1" "Start Node" \
"2" "Stop Node" \
"3" "View Node General Info "$mon"" \
"4" "Prune Node (ADVANCED)"\
"5" "Remove Node (CAREFUL)" \
"0" "Return to Main Menu" \
3>&1 1>&2 2>&3)
if [ $? -ne 0 ]; then
main_menu
fi
case "$option" in
1)
start_node
;;
2)
stop_node
;;
3)
monitor_info
;;
4)
confirm_prune
;;
5)
rm_menu
;;
0)
main_menu
;;
*)
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nAn unexpected error has occurred..." 5 50
sleep 3
monitor_menu
;;
esac
}
start_node() {
check_service_running
sudo systemctl start $CHAIN_NAME.service
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--infobox "\n$pick Node is starting..." 5 50
sleep 3
monitor_menu
}
stop_node() {
check_service_no_running
sudo systemctl stop $CHAIN_NAME.service
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--infobox "\n$pick Node is stopping..." 5 50
sleep 3
monitor_menu
}
monitor_info() {
current_menu="monitor_info"
clear
option=$(dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "Monitor Menu" \
--cancel-label "Back" \
--menu "\n$pick Node Service Status: "$start"\n\nNode Sync Status: $sync\n" 20 60 5 \
"1" "View Node Log" \
"2" "View Node Sync Status" \
"3" "View Node Peers" \
"4" "View Node Details" \
"0" "Return to Main Menu" \
3>&1 1>&2 2>&3)
if [ $? -ne 0 ]; then
monitor_menu
fi
case "$option" in
1)
current_menu="under_monitor_info"
clear
colored_text "36" "Press CTRL+C to exit the daemon monitor...
If this is the first time you are running the daemon, it may take a few minutes for the service to start.
"
sleep 2
colored_text "32" "
Please wait...
Loading Node Log...
"
sudo journalctl -u $CHAIN_NAME.service -f --no-hostname -o cat
monitor_info
;;
2)
current_menu="under_monitor_info"
clear
colored_text "36" "
Press CTRL+C to exit the daemon monitor...
"
colored_text "32" "
Please wait...
Loading Node Sync Status...
"
sleep 2
watch "$DAEMON_NAME status 2>&1 | jq .SyncInfo"
monitor_info
;;
3)
current_menu="under_monitor_info"
clear
colored_text "36" "The $pick node is connected to the following peers:
"
curl -sS http://localhost:"$PORT_PREFIX"57/net_info | jq -r '.result.peers[] | "\(.node_info.id)@\(.remote_ip):\(.node_info.listen_addr)"' | awk -F ':' '{print $1":"$(NF)}'
colored_text "32;1" "
Press any key to continue...
"
read -p ""
monitor_info
;;
4)
current_menu="under_monitor_info"
clear
colored_text "36" "Node Details:
"
$DAEMON_NAME config
colored_text "36" "
Node ID:
"
$DAEMON_NAME tendermint show-node-id
colored_text "36" "
Node Private IP Address:
"
hostname -I | awk '{print $1}'
colored_text "33" "
Node Public IP Address:
"
curl ifconfig.me
colored_text "32;1" "
Press any key to continue...
"
read -p ""
monitor_info
;;
0)
clear
monitor_menu
;;
*)
colored_text "31" "
Invalid option selected. Please try again...
"
sleep 3
monitor_info
;;
esac
}
rm_menu() {
current_menu="monitor_info"
if [ -d "$DAEMON_HOME/$CHAIN_DIR" ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "PROCEED?" \
--defaultno \
--yesno "\nAre you sure you want to remove $pick Node?\n\n" 7 50
if [ $? -eq 0 ]; then
clear
remove_chain
elif [ $? -eq 1 ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nCanceled. Returning to Main menu..." 5 40
sleep 3
monitor_menu
else
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nAn unexpected error has occurred..." 5 40
sleep 3
monitor_menu
fi
elif [ ! -d "$DAEMON_HOME/$CHAIN_DIR" ]; then
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "INFO" \
--infobox "\n$1 Node is not installed..." 5 40
sleep 3
monitor_menu
else
dialog \
--backtitle "NexuSecurus Cosmos Ecosystem Node / Wallet / Monitor Manager - v0.5b" \
--title "WARNING!!!" \
--infobox "\nAn unexpected error has occurred..." 5 50
sleep 3
monitor_menu
fi
}
remove_chain() {
colored_text "36;1" "Stopping $CHAIN_NAME service...
"
sudo systemctl stop $CHAIN_NAME.service
sudo systemctl disable $CHAIN_NAME.service
sudo systemctl daemon-reload
clear
colored_text "36;1" "Backing up $CHAIN_NAME important files to $DAEMON_HOME/$CHAIN_NAME-backups
"
mkdir -p $DAEMON_HOME/$CHAIN_NAME-backups
cp -v $DAEMON_HOME/$CHAIN_DIR/config/node_key.json $DAEMON_HOME/$CHAIN_NAME-backups/node_key.json.bak
cp -v $DAEMON_HOME/$CHAIN_DIR/config/priv_validator_key.json $DAEMON_HOME/$CHAIN_NAME-backups/priv_validator_key.json.bak
cp -v $DAEMON_HOME/$CHAIN_DIR/data/priv_validator_state.json $DAEMON_HOME/$CHAIN_NAME-backups/priv_validator_state.json.bak
cp -v $DAEMON_HOME/$CHAIN_DIR/config/config.toml $DAEMON_HOME/$CHAIN_NAME-backups/config.toml.bak
cp -v $DAEMON_HOME/$CHAIN_DIR/config/app.toml $DAEMON_HOME/$CHAIN_NAME-backups/app.toml.bak
colored_text "32" "