-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathUpgradevalidator.sh
106 lines (90 loc) · 3.78 KB
/
Upgradevalidator.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
#! /bin/bash
sudo apt update
REQUIRED_PKG="jq"
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
echo "Checking for $REQUIRED_PKG: $PKG_OK"
if [ "" = "$PKG_OK" ]; then
echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG."
sudo apt-get --yes install $REQUIRED_PKG
fi
### CONFIG ##################################################################################################
CONFIG="" # config.toml file for node, eg. $HOME/.gaia/config/config.toml
NETWORK="" # Network for choosing testnet or mainnet, no caps!
KEYRING="" # if left empty monitoring won't work
if [ -z "$NETWORK" ];then
read -p "Enter network, testnet or mainnet :" NETWORK
fi
read -p "Do you run a validator, answer yes or no: " validator
if [ "$NETWORK" == testnet ]; then
echo "Network switched to Testnet"
NETWORKPATH=".axelar_testnet"
CONFIG=$HOME/$NETWORKPATH/.core/config/config.toml
CORE_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep axelar-core | cut -d \` -f 4)
TOFND_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep tofnd | cut -d \` -f 4)
else
echo "Network switched to Mainnet"
NETWORKPATH=".axelar"
CONFIG=$HOME/$NETWORKPATH/.core/config/config.toml
CORE_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep axelar-core | cut -d \` -f 4)
TOFND_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep tofnd | cut -d \` -f 4)
fi
if [ -z "$CONFIG" ]; then
echo "please configure config.toml in script"
exit 1
fi
if [ -z "$KEYRING" ]; then
echo "Please enter the password one time below, if setting up as a service fill the field in the script"
read -p "Enter your password for polling the keys :" KEYRING
fi
url=$(sudo sed '/^\[rpc\]/,/^\[/!d;//d' "$CONFIG" | grep "^laddr\b" | awk -v FS='("tcp://|")' '{print $2}')
if [ -z "$url" ]; then
echo "please configure config.toml in script correctly"
exit 1
fi
url="http://${url}"
# stop validator binary tools
echo Stopping axelar-core, vald and tofnd processes
pkill -f 'axelard start'
pkill -f tofnd
kill -9 $(pgrep -f "axelard vald-start")
echo "done"
echo
echo "Clone/Refresh Axerlar Community Github"
rm -rf ~/axelarate-community/
cd ~
git clone https://github.com/axelarnetwork/axelarate-community.git
cd ~/axelarate-community
echo "done"
echo
# Backup .axelar_testnet folder
echo "Backup the $NETWORKPATH folder"
mkdir "$HOME/backup"
rsync -av "$HOME/$NETWORKPATH" "$HOME/backup" --exclude="*.db" --exclude="*.ldb" --exclude=*/wal.*
backupdir=$HOME/backup
echo "Copy created, you can find it at $backupdir"
echo
# starting Axelar-core
echo "restoring old config file regarding chainmaintainers"
cp $backupdir/$NETWORKPATH/shared/config.toml ~/axelarate-community/configuration/config.toml
echo "done"
echo
echo "Starting axelar core"
cd ~/axelarate-community/
KEYRING_PASSWORD=$KEYRING ./scripts/node.sh -e host -n "$NETWORK" -a "$CORE_VERSION"
echo "Checking if node is on latest block"
catchingup=$(jq -r '.result.sync_info.catching_up' <<<$(curl -s "http://localhost:26657/status"))
while [[ $catchingup == "true" ]]; do
echo "Your node is NOT fully synced yet"
echo "we'll wait 30s and retry"
echo
sleep 30
catchingup=$(jq -r '.result.sync_info.catching_up' <<<$(curl -s "http://localhost:26657/status"))
done
echo "Node is on latest block"
echo
if [[ "$validator" == "yes" ]]; then
echo "start axelar validator tools"
KEYRING_PASSWORD=$KEYRING TOFND_PASSWORD=$KEYRING ./scripts/validator-tools-host.sh -n "$NETWORK" -a "$CORE_VERSION" -q "$TOFND_VERSION"
echo "done"
fi
echo