-
Notifications
You must be signed in to change notification settings - Fork 0
/
ethforge.sh
executable file
·906 lines (852 loc) · 24.1 KB
/
ethforge.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
#!/bin/bash
VERSION="1.0.0"
BASE_DIR=$HOME/git/ethforge
# Load functions
source $BASE_DIR/functions.sh && cd $BASE_DIR
menuMain() {
# Define the options for the main menu
OPTIONS=(
1 "View Logs (Exit: CTRL+B D)"
- ""
3 "Execution Client"
4 "Consensus Client"
)
test -f /etc/systemd/system/validator.service && OPTIONS+=(5 "Validator Client")
test -f /etc/systemd/system/mevboost.service && OPTIONS+=(6 "MEV-Boost")
OPTIONS+=(
- ""
7 "Start all clients"
8 "Stop all clients"
9 "Restart all clients"
- ""
10 "System Administration"
11 "Tools"
99 "Quit"
)
while true; do
getBackTitle
# Display the main menu and get the user's choice
CHOICE=$(whiptail --clear --cancel-button "Quit" \
--backtitle "$BACKTITLE" \
--title "ethforge - Node Menu $VERSION" \
--menu "Choose a category:" \
0 42 0 \
"${OPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice
case $CHOICE in
1)
runScript view_logs.sh
;;
3)
submenuExecution
;;
4)
submenuConsensus
;;
5)
submenuValidator
;;
6)
submenuMEV-Boost
;;
7)
sudo service execution start
sudo service consensus start
test -f /etc/systemd/system/validator.service && sudo service validator start
test -f /etc/systemd/system/mevboost.service && sudo service mevboost start
;;
8)
sudo service execution stop
sudo service consensus stop
test -f /etc/systemd/system/validator.service && sudo service validator stop
test -f /etc/systemd/system/mevboost.service && sudo service mevboost stop
;;
9)
sudo service execution restart
sudo service consensus restart
test -f /etc/systemd/system/validator.service && sudo service validator restart
test -f /etc/systemd/system/mevboost.service && sudo service mevboost restart
;;
10)
submenuAdminstrative
;;
11)
submenuTools
;;
99)
break
;;
esac
done
}
submenuExecution() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "View logs"
2 "Start execution"
3 "Stop execution"
4 "Restart execution"
5 "Edit configuration"
6 "Update to latest release"
7 "Resync execution client"
- ""
8 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "Execution Client" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
sudo bash -c 'journalctl -fu execution | ccze'
;;
2)
sudo service execution start
;;
3)
sudo service execution stop
;;
4)
sudo service execution restart
;;
5)
sudo nano /etc/systemd/system/execution.service
if whiptail --title "Reload daemon and restart services" --yesno "Do you want to restart execution client?" 8 78; then
sudo systemctl daemon-reload && sudo service execution restart
fi
;;
6)
runScript update_execution.sh
;;
7)
runScript resync_execution.sh
;;
8)
break
;;
esac
done
}
submenuConsensus() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "View logs"
2 "Start consensus"
3 "Stop consensus"
4 "Restart consensus"
5 "Edit configuration"
6 "Update to latest release"
7 "Resync consensus client"
- ""
8 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "Consensus Client" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
sudo bash -c 'journalctl -fu consensus | ccze'
;;
2)
sudo service consensus start
;;
3)
sudo service consensus stop
;;
4)
sudo service consensus restart
;;
5)
sudo nano /etc/systemd/system/consensus.service
if whiptail --title "Reload daemon and restart services" --yesno "Do you want to restart consensus client?" 8 78; then
sudo systemctl daemon-reload && sudo service consensus restart
fi
;;
6)
runScript update_consensus.sh
;;
7)
runScript resync_consensus.sh
;;
8)
break
;;
esac
done
}
submenuValidator() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "View logs"
2 "Start validator"
3 "Stop validator"
4 "Restart validator"
5 "Edit configuration"
- ""
6 "Generate / Import Validator Keys"
7 "View validator pubkeys and indices"
- ""
8 "Generate Voluntary Exit Messages (VEM) with ethdo"
9 "Broadcast Voluntary Exit Messages (VEM) with ethdo"
10 "Check Validator Status by Index with ethdo"
- ""
11 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "Validator" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
sudo bash -c 'journalctl -fu validator | ccze'
;;
2)
sudo service validator start
;;
3)
sudo service validator stop
;;
4)
sudo service validator restart
;;
5)
sudo nano /etc/systemd/system/validator.service
if whiptail --title "Reload daemon and restart services" --yesno "Do you want to restart validator?" 8 78; then
sudo systemctl daemon-reload && sudo service validator restart
fi
;;
6)
runScript manage_validator_keys.sh
;;
7)
getPubKeys && getIndices
viewPubkeyAndIndices
;;
8)
installEthdo
generateVoluntaryExitMessage
;;
9)
installEthdo
broadcastVoluntaryExitMessageLocally
;;
10)
installEthdo
checkValidatorStatus
;;
11)
break
;;
esac
done
}
submenuMEV-Boost() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "View logs"
2 "Start MEV-Boost"
3 "Stop MEV-Boost"
4 "Restart MEV-Boost"
5 "Edit configuration"
6 "Update to latest release"
7 "Check relay registration"
- ""
8 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "MEV-Boost" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
sudo bash -c 'journalctl -fu mevboost | ccze'
;;
2)
sudo service mevboost start
;;
3)
sudo service mevboost stop
;;
4)
sudo service mevboost restart
;;
5)
sudo nano /etc/systemd/system/mevboost.service
if whiptail --title "Reload daemon and restart services" --yesno "Do you want to restart MEV-Boost" 8 78; then
sudo systemctl daemon-reload && sudo service mevboost restart
fi
;;
6)
runScript update_mevboost.sh
;;
7)
checkRelayRegistration
;;
8)
break
;;
esac
done
}
submenuAdminstrative() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "Update system"
2 "Restart system"
3 "Shutdown system"
- ""
4 "View software versions"
5 "View cpu/ram/disk/net (btop)"
6 "View general node information"
- ""
10 "Update ethforge"
11 "About ethforge"
- ""
20 "Configure autostart"
21 "Uninstall node"
- ""
99 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "System Administration" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
;;
2)
if whiptail --title "Reboot" --defaultno --yesno "Are you sure you want to reboot?" 8 78; then sudo reboot now; fi
;;
3)
if whiptail --title "Shutdown" --defaultno --yesno "Are you sure you want to shutdown?" 8 78; then sudo shutdown now; fi
;;
4)
CL=$(curl -s -X GET "${API_BN_ENDPOINT}/eth/v1/node/version" -H "accept: application/json" | jq -r '.data.version')
EL=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":2}' ${EL_RPC_ENDPOINT} | jq -r '.result')
MB=$(if systemctl is-active --quiet mevboost; then printf "$(mev-boost --version | sed 's/.*\s\([0-9]*\.[0-9]*\).*/\1/')"; elif [ -f /etc/systemd/system/mevboost.service ]; then printf "Offline"; else printf "Not Installed"; fi)
if [[ ! $CL ]]; then
CL="Not running or still starting up."
fi
if [[ ! $EL ]]; then
EL="Not running or still starting up."
fi
whiptail --title "Installed versions" --msgbox "Consensus client: $CL\nExecution client: $EL\nMev-boost: $MB" 10 78
;;
5)
# Install btop process monitoring
if ! command -v btop &>/dev/null; then
sudo apt-get install btop -y
fi
btop
;;
6)
print_node_info
;;
10)
cd $BASE_DIR
git fetch origin main
git checkout main
git pull --ff-only
git reset --hard
git clean -xdf
whiptail --title "Updated ethforge" --msgbox "Restart ethforge for latest version." 10 78
;;
11)
MSG_ABOUT="🔧 Developed as an open-source project by Naviat for Ethereum staking since its inception.
\n🛠️ We welcome improvements and suggestions on GitHub: https://github.com/naviat/EthForge" 20 78
;;
20)
configureAutoStart
;;
21)
runScript uninstall.sh
;;
99)
break
;;
esac
done
}
submenuMonitoring() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "View Logs"
2 "Start Monitoring"
3 "Stop Monitoring"
4 "Restart Monitoring"
5 "Edit configuration"
6 "Edit Prometheus.yml configuration"
7 "Update to latest release"
8 "Uninstall monitoring"
- ""
9 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "Monitoring - Ethereum Metrics Exporter" \
--menu "\nAccess Grafana at: http://127.0.0.1:3000 or http://$ip_current:3000\n\nChoose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
sudo bash -c 'journalctl -fu grafana-server -fu prometheus -fu ethereum-metrics-exporter -fu prometheus-node-exporter -n 100 | ccze'
;;
2)
sudo systemctl start grafana-server prometheus ethereum-metrics-exporter prometheus-node-exporter
;;
3)
sudo systemctl stop grafana-server prometheus ethereum-metrics-exporter prometheus-node-exporter
;;
4)
sudo systemctl restart grafana-server prometheus ethereum-metrics-exporter prometheus-node-exporter
;;
5)
sudo nano /etc/systemd/system/ethereum-metrics-exporter.service
if whiptail --title "Reload daemon and restart services" --yesno "Do you want to restart ethereum metrics exporter?" 8 78; then
sudo systemctl daemon-reload && sudo service ethereum-metrics-exporter restart
fi
;;
6)
sudo nano /etc/prometheus/prometheus.yml
if whiptail --title "Restart services" --yesno "Do you want to restart prometheus?" 8 78; then
sudo service prometheus restart
fi
;;
7)
runScript ethereum-metrics-exporter.sh -u
;;
8)
runScript ethereum-metrics-exporter.sh -r
;;
9)
break
;;
esac
done
}
submenuEthduties() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "View duties"
2 "Wait for 90.0% of attestation duties to be executed in 90 sec. or later"
3 "Update to latest release"
4 "Uninstall eth-duties"
- ""
9 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "eth-duties" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
getNetwork && getPubKeys && getIndices
/usr/local/bin/eth-duties --validators ${INDICES[@]} --beacon-nodes $API_BN_ENDPOINT
;;
2)
getNetwork && getPubKeys && getIndices
/usr/local/bin/eth-duties --validators ${INDICES[@]} --beacon-nodes $API_BN_ENDPOINT --max-attestation-duty-logs 60 --mode cicd-wait --mode-cicd-attestation-time 90 --mode-cicd-attestation-proportion 0.90
ohai "Ready! Press ENTER to continue."
read
;;
3)
runScript eth-duties.sh -u
;;
4)
runScript eth-duties.sh -r
;;
9)
break
;;
esac
done
}
submenuEthdo() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "Check Validator Status by Index"
2 "Generate Voluntary Exit Messages (VEM)"
3 "Broadcast Voluntary Exit Messages (VEM)"
4 "Update to latest release"
5 "Uninstall ethdo"
- ""
9 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "ethdo" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
checkValidatorStatus
;;
2)
generateVoluntaryExitMessage
;;
3)
broadcastVoluntaryExitMessageLocally
;;
4)
runScript ethdo.sh -u
;;
5)
runScript ethdo.sh -r
;;
9)
break
;;
esac
done
}
submenuUFW() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "View ufw status"
2 "Allow incoming traffic on a port"
3 "Deny incoming traffic on a port"
4 "Delete a rule"
- ""
5 "Enable firewall with default settings"
6 "RPC Node: Allow local network access to RPC port 8545"
7 "Monitoring: Allow local network access to Grafana port 3000"
8 "Disable firewall"
9 "Reset firewall rules"
- ""
10 "Whitelist an IP address: Allow full access to this node"
- ""
99 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "UFW Firewall" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
sudo ufw status numbered
ohai "Press ENTER to continue."
read
;;
2)
read -p "Enter the port number to allow: " port_number
sudo ufw allow $port_number
ohai "Port allowed."
sleep 2
;;
3)
read -p "Enter the port number to deny: " port_number
sudo ufw deny $port_number
ohai "Port denied."
sleep 2
;;
4)
sudo ufw status numbered
read -p "Enter the rule number to delete: " rule_number
sudo ufw delete $rule_number
ohai "Rule deleted."
sleep 2
;;
5)
# Default ufw settings
sudo ufw default deny incoming
sudo ufw default allow outgoing
echo "${tty_bold}Allow SSH access? [y|n]${tty_reset}"
read -rsn1 yn
if [[ ${yn} = [Yy]* ]]; then
read -r -p "Enter your SSH port. Press Enter to use default '22': " _ssh_port
_ssh_port=${_ssh_port:-22}
sudo ufw allow ${_ssh_port}/tcp comment 'Allow SSH port'
fi
sudo ufw allow 30303 comment 'Allow execution client port'
sudo ufw allow 9000 comment 'Allow consensus client port'
sudo ufw enable
sudo ufw status numbered
ohai "UFW firewall enabled."
sleep 3
;;
6)
sudo ufw allow from ${network_current} to any port 8545 comment 'Allow local network to access RPC'
ohai "Local network ${network_current} can access RPC port 8545"
sleep 2
;;
7)
sudo ufw allow from ${network_current} to any port 3000 comment 'Allow local network to access Grafana'
ohai "Local network ${network_current} can access RPC port 3000"
sleep 2
;;
8)
sudo ufw disable
ohai "UFW firewall disabled."
sleep 2
;;
9)
sudo ufw disable
sudo ufw --force reset
ohai "UFW firewall reset."
sleep 2
;;
10)
read -p "Enter the IP address to whitelist: " ip_whitelist
sudo ufw allow from $ip_whitelist
ohai "IP address whitelisted."
sleep 2
;;
99)
break
;;
esac
done
}
submenuTools() {
while true; do
getBackTitle
# Define the options for the submenu
SUBOPTIONS=(
1 "eth-duties: Show upcoming block proposals, attestations, sync duties"
2 "Monitoring: Observe Ethereum Metrics. Explore Dashboards."
3 "NCDU: Find large files. Analyze disk usage."
4 "Port Checker: Test for Incoming Connections"
5 "ethdo: Conduct Common Validator Tasks"
6 "Peer Count: Show # peers connected to EL & CL"
7 "Beaconcha.in Validator Dashboard: Create a link for my validators"
- ""
9 "EL: Switch Execution Clients"
- ""
10 "Timezone: Update machine's timezone"
11 "Locales: Fix terminal formatting issues"
12 "Privacy: Clear bash shell history"
13 "Swapfile: Use disk space as extra RAM"
14 "UFW Firewall: Control network traffic against unauthorized access"
15 "Speedtest: Test internet bandwidth using speedtest.net"
- ""
99 "Back to main menu"
)
# Display the submenu and get the user's choice
SUBCHOICE=$(whiptail --clear --cancel-button "Back" \
--backtitle "$BACKTITLE" \
--title "Tools" \
--menu "Choose one of the following options:" \
0 0 0 \
"${SUBOPTIONS[@]}" \
3>&1 1>&2 2>&3)
if [ $? -gt 0 ]; then # user pressed <Cancel> button
break
fi
# Handle the user's choice from the submenu
case $SUBCHOICE in
1)
# Skip if no validators installed
if [[ ! -f /etc/systemd/system/validator.service ]]; then
echo "No validator(s) installed. Press ENTER to continue."
read
break
fi
# Install eth-duties if not yet installed
if [[ ! -f /usr/local/bin/eth-duties ]]; then
if whiptail --title "Install eth-duties" --yesno "Do you want to install eth-duties?\n\neth-duties shows upcoming validator duties." 8 78; then
runScript eth-duties.sh -i
fi
fi
submenuEthduties
;;
2)
# Install monitoring if not yet installed
if [[ ! -f /etc/systemd/system/ethereum-metrics-exporter.service ]]; then
if whiptail --title "Install Monitoring" --yesno "Do you want to install Monitoring?\nIncludes: Ethereum Metrics Exporter, grafana, prometheus" 8 78; then
runScript ethereum-metrics-exporter.sh -i
fi
fi
submenuMonitoring
;;
3)
findLargestDiskUsage
;;
4)
checkOpenPorts
;;
5)
installEthdo
submenuEthdo
;;
6)
getPeerCount
;;
7)
createBeaconChainDashboardLink
;;
9)
sudo /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/naviat/el-switcher/master/install.sh)"
;;
10)
sudo dpkg-reconfigure tzdata
ohai "Timezone updated. Press ENTER to continue."
read
;;
11)
sudo update-locale "LANG=en_US.UTF-8"
sudo locale-gen --purge "en_US.UTF-8"
sudo dpkg-reconfigure --frontend noninteractive locales
ohai "Updated locale to en_US.UTF-8"
ohai "Logout and login for terminal locale updates to take effect. Press ENTER to continue."
read
;;
12)
history -c && history -w
ohai "Cleared bash history"
read
;;
13)
addSwapfile
;;
14)
submenuUFW
;;
15)
testBandwidth
;;
99)
break
;;
esac
done
}
function getBackTitle() {
getNetwork
getClient
# Latest block
latest_block_number=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ${EL_RPC_ENDPOINT} | jq -r '.result')
LB=$(printf '%d' "$latest_block_number")
if [[ ! $LB ]]; then
LB="N/A"
fi
# Latest slot
LS=$(curl -s -X GET "${API_BN_ENDPOINT}/eth/v1/node/syncing" -H "accept: application/json" | jq -r '.data.head_slot')
if [[ ! $LS ]]; then
LS="N/A"
fi
# Format gas price
latest_gas_price=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":73}' ${EL_RPC_ENDPOINT} | jq -r '.result')
if [[ $latest_gas_price ]]; then
WEI=$(printf '%d' "$latest_gas_price")
GP=$(echo "scale=3; $WEI / 1000000000" | bc) #convert to Gwei
else
GP="N/A"
fi
# Format backtitle
EL_TEXT=$(if systemctl is-active --quiet execution; then printf "Block $LB | Gas $GP Gwei"; else printf "Offline EL"; fi)
CL_TEXT=$(if systemctl is-active --quiet consensus; then printf "Slot $LS"; else printf "Offline CL"; fi)
VC_TEXT=$(if systemctl is-active --quiet validator && systemctl is-enabled --quiet validator; then printf " | VC $VC"; fi)
NETWORK_TEXT=$(if systemctl is-active --quiet execution; then printf "$NETWORK |"; fi)
BACKTITLE="$NETWORK_TEXT $EL_TEXT | $CL_TEXT | $CL-$EL$VC_TEXT | Toolset for ETH"
}
function checkV1StakingSetup() {
if [[ -f /etc/systemd/system/eth1.service ]]; then
echo "Ethforge is only compatible with V2 Staking Setups. Using ethforge, build a new node in minutes after wiping system or uninstalling V1."
exit
fi
}
# If no consensus client service is installed, ask to install
function askInstallNode() {
if [[ ! -f /etc/systemd/system/consensus.service ]]; then
if whiptail --title "Install Node" --yesno "Would you like to install an Ethereum node (Nimbus CL & Nethermind EL)?" 8 78; then
runScript install-nimbus-nethermind.sh
fi
fi
}
checkV1StakingSetup
setWhiptailColors
askInstallNode
menuMain