-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbinaryinstallsystemd.sh
202 lines (166 loc) · 7.2 KB
/
binaryinstallsystemd.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
#! /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
REQUIRED_PKG="liblz4-tool"
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
if [ -z $MONIKER ]; then
echo "Please enter Moniker name below"
read -p "Enter Moniker name :" MONIKER
fi
if [ -z "$NETWORK" ];then
read -p "Enter network, testnet or mainnet :" NETWORK
fi
read -p "Enter your KEYRING PASSWORD : " KEYRING
# 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"
CHAIN_ID=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelarate-community/main/scripts/node.sh | grep chain_id=axelar-t | cut -f2 -d "=")
NETWORKPATH=".axelar_testnet"
SNAPSHOTURL=$(curl -L https://quicksync.io/axelar.json|jq -r '.[] |select(.file=="axelartestnet-lisbon-3-pruned")|.url')
SNAPSHOTFILE=$(curl -L https://quicksync.io/axelar.json|jq -r '.[] |select(.file=="axelartestnet-lisbon-3-pruned")|.url' | cut -c26-)
else
echo "Setup node for axelar mainnet"
echo "Determining mainnet chain"
CHAIN_ID=$(curl -s https://raw.githubusercontent.com/axelarnetwork/axelarate-community/main/scripts/node.sh | grep chain_id=axelar-d | cut -f2 -d "=")
NETWORKPATH=".axelar"
SNAPSHOTURL=$(curl -L https://quicksync.io/axelar.json|jq -r '.[] |select(.file=="axelar-dojo-1-default")|.url')
SNAPSHOTFILE=$(curl -L https://quicksync.io/axelar.json|jq -r '.[] |select(.file=="axelar-dojo-1-default")|.url' | cut -c26-)
fi
echo "Clone Axelar Community Github"
# Remove repo for a clean git clone
sudo rm -rf ~/axelarate-community/
cd ~
git clone https://github.com/axelarnetwork/axelarate-community.git >/dev/null 2>&1
cd ~/axelarate-community
echo "done"
echo
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
echo "done"
echo
echo "make the binary executable"
sudo chmod +x /usr/local/bin/axelard
sudo chmod +x /usr/local/bin/tofnd
sudo chmod +x /usr/local/bin/vald
echo "done"
echo
echo "setting vaiables"
echo "make directory"
mkdir $HOME/$NETWORKPATH
mkdir $HOME/$NETWORKPATH/.core
mkdir $HOME/$NETWORKPATH/.core/config/
echo "done"
echo
echo "Initialize node"
axelard init "$MONIKER" --chain-id $CHAIN_ID --home $HOME/$NETWORKPATH
echo "done"
echo
echo "Downloading config files"
echo "--> Downloading genesis file"
curl -s --fail https://axelar-$NETWORK.s3.us-east-2.amazonaws.com/genesis.json -o $HOME/$NETWORKPATH/.core/config/genesis.json
echo "--> Downloading latest seeds"
curl -s --fail https://axelar-$NETWORK.s3.us-east-2.amazonaws.com/seeds.txt -o $HOME/$NETWORKPATH/.core/config/seeds.txt
echo "--> Copying config files"
cp $HOME/axelarate-community/configuration/config.toml $HOME/$NETWORKPATH/.core/config/
cp $HOME/axelarate-community/configuration/app.toml $HOME/$NETWORKPATH/.core/config/
echo "done"
echo
echo "Adding seeds to config toml"
add_seeds() {
seeds=$(cat "$HOME/$NETWORKPATH/.core/config/seeds.txt")
sed "s/^seeds =.*/seeds = \"$seeds\"/g" "$HOME/$NETWORKPATH/.core/config/config.toml" >"$HOME/$NETWORKPATH/.core/config/config.toml.tmp"
mv "$HOME/$NETWORKPATH/.core/config/config.toml.tmp" "$HOME/$NETWORKPATH/.core/config/config.toml"
}
add_seeds
echo "done"
echo
echo "Adding external ip to config file"
public_ip=$(curl -s ifconfig.me)
echo "See your public IP: $public_ip, this will be used to update config.toml"
read -p "Press enter to continue, or type ENTERIP to reenter a new one: " reenterip
if [ ! -z $reenterip ] && [ $reenterip == "ENTERIP" ]; then
read -p "Enter your public ip : " public_ip
test='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
while [[ !($public_ip =~ ^$test\.$test\.$test\.$test$) ]]; do
read -p "invalid ip, pleeas re-enter : " public_ip
done
fi
echo "Final public ip used is $public_ip"
sed -i "s/external_address = \"\"/external_address = \"$public_ip:26656\"/" $HOME/$NETWORKPATH/.core/config/config.toml
echo "done"
echo
echo "downloading snapshot file"
cd $HOME/$NETWORKPATH/.core
wget $SNAPSHOTURL
echo "remove any old data"
rm -rf $HOME/$NETWORKPATH/.core/data
echo "extracting the data"
lz4 -d $SNAPSHOTFILE | tar xf -
rm $SNAPSHOTFILE
echo "done"
echo
echo "creating service"
sudo bash -c "cat > /etc/systemd/system/axelar-node.service << EOF
[Unit]
Description=axelard-node
After=network-online.target
[Service]
User=$USER
ExecStart=/usr/local/bin/axelard start --home $HOME/$NETWORKPATH/.core
Restart=always
RestartSec=3
LimitNOFILE=16384
MemoryMax=8G
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
EOF"
sudo systemctl enable axelar-node.service
sudo systemctl start axelar-node
echo "done"
echo
echo "wait a few seconds to start the node"
sleep 15
echo "done"
echo "creating wallets"
echo "--> creating axelar validator wallet"
(echo $KEYRING ; echo $KEYRING) | axelard keys add validator --home $HOME/$NETWORKPATH/.core &> $HOME/validator.txt
echo "--> creating axelar broadcaster wallet"
(echo $KEYRING ; echo $KEYRING) | axelard keys add broadcaster --home $HOME/$NETWORKPATH/.core &> $HOME/broadcaster.txt
echo "--> creating Tofnd wallet"
echo $KEYRING | tofnd -m create -d "$HOME/$NETWORKPATH/.tofnd"
mv $HOME/$NETWORKPATH/.tofnd/export $HOME/$NETWORKPATH/.tofnd/import
echo $KEYRING | axelard keys show validator --home $HOME/$NETWORKPATH/.core --bech val -a > $HOME/$NETWORKPATH/validator.bech
echo "Node setup done"
echo "Please fund broadcaster and validator address"
validator=$(tail $HOME/validator.txt | grep address | cut -f2 -d ":")
echo "validator adress is : $validator"
broadcaster=$(tail $HOME/broadcaster.txt | grep address | cut -f2 -d ":")
echo "broadcaster adress is : $broadcaster"
echo "Please copy and fund the addresses"
echo "If setting up a validator wait for the sync is complete please check with curl -s "http://localhost:26657/status" | jq -r '.result.sync_info' "
echo "node install is done, use option 6 for setting up the validator for systemd"