-
Notifications
You must be signed in to change notification settings - Fork 0
/
resync_consensus.sh
executable file
·96 lines (85 loc) · 2.17 KB
/
resync_consensus.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
#!/bin/bash
# Load functions
source $BASE_DIR/functions.sh
function getClient() {
CL=$(cat /etc/systemd/system/consensus.service | grep Description= | awk -F'=' '{print $2}' | awk '{print $1}')
}
function promptYesNo() {
if whiptail --title "Resync Consensus - $CL" --yesno "This will only take a minute or two.\nAre you sure you want to resync $CL?" 9 78; then
resyncClient
promptViewLogs
fi
}
function promptViewLogs() {
if whiptail --title "Resync $CL complete" --yesno "Would you like to view logs and confirm everything is running properly?" 8 78; then
sudo bash -c 'journalctl -fu consensus | ccze'
fi
}
function getNetwork() {
# Get network name from execution client
result=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}' ${EL_RPC_ENDPOINT} | jq -r '.result')
case $result in
17000)
NETWORK="Holesky"
;;
11155111)
NETWORK="Sepolia"
;;
esac
}
function resyncClient() {
case $CL in
Lighthouse)
sudo systemctl stop consensus
sudo rm -rf /var/lib/lighthouse/beacon
sudo systemctl restart consensus
;;
Lodestar)
sudo systemctl stop consensus
sudo rm -rf /var/lib/lodestar/chain-db
sudo systemctl restart consensus
;;
Teku)
sudo systemctl stop consensus
sudo rm -rf /var/lib/teku/beacon
sudo systemctl restart consensus
;;
Nimbus)
getNetwork
case $NETWORK in
Holesky)
URL="https://holesky.beaconstate.ethstaker.cc"
;;
Sepolia)
URL="https://sepolia.beaconstate.info"
;;
esac
sudo systemctl stop consensus
sudo rm -rf /var/lib/nimbus/db
sudo -u consensus /usr/local/bin/nimbus_beacon_node trustedNodeSync \
--network=$(echo $NETWORK | tr '[:upper:]' '[:lower:]') \
--trusted-node-url=$URL \
--data-dir=/var/lib/nimbus \
--backfill=false
sudo systemctl restart consensus
;;
esac
}
function setWhiptailColors() {
export NEWT_COLORS='root=,black
border=green,black
title=green,black
roottext=red,black
window=red,black
textbox=white,black
button=black,green
compactbutton=white,black
listbox=white,black
actlistbox=black,white
actsellistbox=black,green
checkbox=green,black
actcheckbox=black,green'
}
setWhiptailColors
getClient
promptYesNo