-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathUpgradebinarysystemd.sh
100 lines (84 loc) · 3.5 KB
/
Upgradebinarysystemd.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
#! /bin/bash
sudo apt update
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
# Determining Axelar versions
echo "Determining Axelar version"
CORE_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep axelar-core | cut -d \` -f 4)
echo ${CORE_VERSION}
echo "Determining Vald version"
VALD_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep vald | cut -d \` -f 4)
echo ${VALD_VERSION}
echo "Determining Tofnd version"
TOFND_VERSION=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/pages/resources/$NETWORK.md | grep tofnd | cut -d \` -f 4)
echo ${TOFND_VERSION}
echo
if [ "$NETWORK" == testnet ]; then
echo "Setup node for axelar testnet"
echo "Determining testnet chain"
NETWORKPATH=".axelar_testnet"
else
echo "Setup node for axelar mainnet"
echo "Determining mainnet chain"
NETWORKPATH=".axelar"
fi
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
echo "stop Axelar services"
sudo systemctl stop axelar-node
if [[ "$validator" == "yes" ]]; then
sudo systemctl stop tofnd.service
sudo systemctl stop axelard-val.service
fi
echo "Download binary files"
sudo curl -s "https://axelar-releases.s3.us-east-2.amazonaws.com/axelard/$CORE_VERSION/axelard-linux-amd64-$CORE_VERSION" -o /usr/local/bin/axelard
sudo curl -s --fail https://axelar-releases.s3.us-east-2.amazonaws.com/tofnd/$TOFND_VERSION/tofnd-linux-amd64-$TOFND_VERSION -o /usr/local/bin/tofnd
sudo curl -s "https://axelar-releases.s3.us-east-2.amazonaws.com/axelard/$VALD_VERSION/axelard-linux-amd64-$VALD_VERSION" -o /usr/local/bin/vald
cp $HOME/axelarate-community/configuration/app.toml $HOME/$NETWORKPATH/.core/config
cp $HOME/axelarate-community/configuration/app.toml $HOME/$NETWORKPATH/.vald/config
echo "done"
echo
read -p "Did axelar announce genesis file upgrade, answer yes or no: " genesis
if [[ "$genesis" == "yes" ]]; then
echo "Downloading new genesis file"
curl -s --fail https://axelar-$NETWORK.s3.us-east-2.amazonaws.com/genesis.json -o $HOME/$NETWORKPATH/.core/config/genesis.json
if [[ "$validator" == "yes" ]]; then
cp $HOME/$NETWORKPATH/.core/config/genesis.json $HOME/$NETWORKPATH/.vald/config/genesis.json
fi
fi
echo "starting Axelar services"
sudo systemctl start axelar-node
echo "check Axelar service log"
sudo journalctl --unit=axelar-node.service | tail -n 3
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 "Starting Axelar tools"
sudo systemctl start tofnd.service
sleep 10
sudo systemctl start axelard-val.service
echo "Axelar tools started, check if your node is working correctly again"
echo "wait 10 seconds to see if vald and tofnd are working properly"
sleep 10
echo "Check vald log"
sudo journalctl --unit=axelard-val.service | tail -n 3
echo "check Tofnd log"
sudo journalctl --unit=tofnd.service | tail -n 3
fi
echo "Node upgrade executed"