-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathreset-validator.sh
44 lines (35 loc) · 1.41 KB
/
reset-validator.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
#!/usr/bin/env bash
#
# PulseChain validator helper script stuff to "reset" things so you can try again
#
I_KNOW_WHAT_I_AM_DOING=false # CHANGE ME ONLY IF YOU TRULY UNDERSTAND
if [ "$I_KNOW_WHAT_I_AM_DOING" = false ]; then
echo "Make sure you understand what this script does, then flip I_KNOW_WHAT_I_AM_DOING to true if you want to run it"
echo "If you want to delete the blockchain then flip REMOVE_BLOCKCHAIN_DATA to true"
exit 1
fi
GETH_DIR="/opt/geth"
LIGHTHOUSE_DIR="/opt/lighthouse"
REMOVE_BLOCKCHAIN_DATA=false
echo -e "ARE YOU SURE YOU WANT TO RESET AND DELETE CLIENT DATA ON THE VALIDATOR?\n"
read -p "Press [Enter] to Continue"
# stop the client services
sudo systemctl stop geth &>/dev/null
sudo systemctl stop lighthouse-beacon &>/dev/null
sudo systemctl stop lighthouse-validator &>/dev/null
# remove the services and reload service daemon
sudo rm -rf /etc/systemd/system/geth.service
sudo rm -rf /etc/systemd/system/lighthouse*
sudo systemctl daemon-reload
# remove client data (leave blockchain by default)
if [ "$REMOVE_BLOCKCHAIN_DATA" = false ]; then
sudo find $GETH_DIR -mindepth 1 -name data -prune -o -exec rm -rf {} + &>/dev/null
sudo find $LIGHTHOUSE_DIR -mindepth 1 -name beacon -prune -o -exec rm -rf {} + &>/dev/null
else
sudo rm -rf $GETH_DIR
sudo rm -rf $LIGHTHOUSE_DIR
fi
# remove the user
sudo userdel -r node &>/dev/null
sudo rm -rf /home/node
echo -e "\nProcess is complete"