-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvalidator_run.sh
executable file
·215 lines (189 loc) · 6.91 KB
/
validator_run.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
203
204
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash
#
MONIKER=$1
CHAIN_ID=$2
echo "${MONIKER}"
echo "${CHAIN_ID}"
# setup the drive
sudo mkfs.ext4 -m 0 -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb
sudo mkdir -p /mnt/disks/data
sudo mount -o discard,defaults /dev/sdb /mnt/disks/data
sudo mkdir -p /mnt/disks/data/terrad
sudo chown user /mnt/disks/data/terrad
#called data as the quicksync expects it to be in data
mkdir -p /mnt/disks/data/terrad/data
UUID=$(sudo blkid /dev/sdb |cut -d " " -f2| sed s/\"//g )
echo "$UUID /mnt/disks/data ext4 discard,defaults,nofail 0 2" >> /tmp/fstab.add
cat /etc/fstab /tmp/fstab.add > /tmp/fstab
sudo cp /tmp/fstab /etc/fstab
# setup the limits
sudo cp validator/limits.terrad /etc/security/limits.d/terrad.conf
# install the service definitions
case "${CHAIN_ID}" in
"bombay-12")
sudo cp validator/terrad.service /etc/systemd/system/
;;
*)
sudo cp validator/terrad.service /etc/systemd/system/
#sudo cp validator/*.service /etc/systemd/system/
;;
esac
# Google's monitoring agent
curl -sSO https://dl.google.com/cloudagents/add-monitoring-agent-repo.sh
sudo bash add-monitoring-agent-repo.sh
curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh
sudo bash add-logging-agent-repo.sh
# additional stuff required on the box
sudo apt-get update && sudo apt-get upgrade -y
# libleveldb-dev is needed if we want to build terrad with cleveldb. should be harmless otherwise
sudo apt-get install -y build-essential git jq pv libleveldb-dev liblz4-tool aria2 net-tools vim 'stackdriver-agent=6.*'
# logging stuff
sudo apt-get install -y google-fluentd
sudo apt-get install -y google-fluentd-catch-all-config
sudo service google-fluentd start
# GO .. as we're building it from source.
curl -LO https://go.dev/dl/go1.17.8.linux-amd64.tar.gz
#curl -LO https://golang.org/dl/go1.16.8.linux-amd64.tar.gz
if ! sha256sum -c validator/go1.16.8.linux-amd64.tar.gz.sum ; then
echo "GO download did not match checksum"
exit 1
fi
#tar xfz go1.17.8.linux-amd64.tar.gz
tar xfz ./go1.16.8.linux-amd64.tar.gz
if [ -d "/usr/local/go" ];
then
sudo rm -rf /usr/local/go
fi
sudo mv go /usr/local
# set up paths for next time
mv validator/.bashrc ${HOME}
chmod 755 ${HOME}/.bashrc
export GOPATH=${HOME}/go
export PATH=${PATH}:/usr/local/go/bin:${PWD}/go/bin
# get the code
git clone https://github.com/terra-money/core/
cd core
case "${CHAIN_ID}" in
"bombay-12")
git checkout v0.5.17
;;
*)
git checkout v0.5.17
;;
esac
#
# should this use cleveldb
# go build -tags cleveldb
make install
# terraD binaries are in the right place now
terrad init "${MONIKER}" --chain-id ${CHAIN_ID}
if [ -f ".terra/config/genesis.json" ];
then
rm -f .terra/config/genesis.json
fi
case "${CHAIN_ID}" in
"columbus-5")
echo "Columbus-5 not supported yet"
# TBD
# curl https://columbus-genesis.s3-ap-northeast-1.amazonaws.com/genesis.json > $HOME/.terrad/config/genesis.json
# curl https://network.terra.dev/addrbook.json > $HOME/.terrad/config/addrbook.json
# TBD is address.json actually needed?
;;
"bombay-12")
# curl https://raw.githubusercontent.com/terra-project/testnet/master/bombay-9/genesis.json > $HOME/.terra/config/genesis.json
curl https://raw.githubusercontent.com/terra-money/testnet/master/bombay-12/genesis.json > $HOME/.terra/config/genesis.json
;;
*)
echo "${CHAIN_ID} not known"
exit 1
;;
esac
case "${CHAIN_ID}" in
"bombay-12")
pushd ${HOME}/.terra
;;
*)
pushd ${HOME}/.terra
;;
esac
#pushd ${HOME}
cp ./config/config.toml ./config/config.toml.orig
# sed script to fix indexer line to 'null'
# sed 's/indexer = \"kv\"/indexer = \"null\"/' < .terrad/config/config.toml.orig > .terrad/config/config.toml.1
sed 's/\"data/\"\/mnt\/disks\/data\/terrad\/data/' < ./config/config.toml.orig > ./config/config.toml.1
case "${CHAIN_ID}" in
"columbus-5")
echo "Columbia not supported yet"
sed 's/seeds = \"\"/seeds = \"[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656\"/' < ./config/config.toml.1 > ./config/config.toml
;;
"bombay-12")
sed 's/seeds = \"\"/seeds = \"[email protected]:26656\"/' < ./config/config.toml.1 > ./config/config.toml
;;
*)
echo "${CHAIN_ID} not known"
exit 1
;;
esac
# app.toml
cp ./config/app.toml ./config/app.toml.orig
sed 's/minimum-gas-prices = \"\"/minimum-gas-prices=\"0.01133uluna,0.104938usdr,0.15uusd,169.77ukrw,428.571umnt,0.125ueur,0.98ucny,16.37ujpy,0.11ugbp,10.88uinr,0.19ucad,0.14uchf,0.19uaud,0.2usgd,4.62uthb,1.25usek,1.25unok,0.9udkk,2180.0uidr,7.6uphp,1.17uhkd,0.6umyr,4.0utwd\"/' < ./config/app.toml.orig > ./config/app.toml
popd
#case "${CHAIN_ID}" in
# "bombay-12")
# echo "skipping terracli as it isn't installed"
# ;;
# *)
# terracli config node http://127.0.0.1:26657
# terracli config chain-id ${CHAIN_ID}
# ;;
#esac
chmod 700 ${HOME}/validator/checksum.sh
pushd /mnt/disks/data/terrad
case "${CHAIN_ID}" in
"columbus-5")
echo "Columbia not supported yet"
# syncfile=$( curl https://terra.quicksync.io/sync.json|jq -r ".[]| select(.network==\"pruned\")|.file" |grep columbus-4)
# echo "syncfile = ${syncfile}"
# aria2c -x5 https://get.quicksync.io/${syncfile}
# curl -O https://get.quicksync.io/${syncfile}.checksum
# hash=$(curl -s https://get.quicksync.io/${syncfile}.hash)
# curl -s https://lcd.terra.dev/txs/${hash}|jq -r '.tx.value.memo'|sha512sum -c
# ${HOME}/validator/checksum.sh ${syncfile}
# tar -I lz4 -xf columbus-5-pruned.20220320.0410.tar.lz4
# echo "exit code $?"
# echo "waiting..."
# read
mv ${HOME}/.terra/data ${HOME}/.terra/data.orig
ln -s /mnt/disks/data/terrad/data ${HOME}/.terra/
cp ${HOME}/.terra/data.orig/priv_validator_state.json ${HOME}/.terra/data/
;;
"bombay-12")
# mkdir /mnt/disks/data/terrad/data
echo "${CHAIN_ID} no syncing available"
mv ${HOME}/.terra/data ${HOME}/.terra/data.orig
ln -s /mnt/disks/data/terrad/data ${HOME}/.terra/
cp ${HOME}/.terra/data.orig/priv_validator_state.json ${HOME}/.terra/data/
;;
*)
echo "${CHAIN_ID} not known"
exit 1
;;
esac
popd
#mv ${HOME}/.terrad/data/priv_validator_state.json /mnt/disks/data/terrad/data
# everything is in place ..
# lighting up daemons
sudo systemctl daemon-reload
#sudo systemctl enable terrad
case "${CHAIN_ID}" in
"bombay-12")
echo "terracli-server needs to be enabled in [api] section"
;;
*)
echo "terracli-server needs to be enabled in [api] section"
# sudo systemctl enable terracli-server
;;
esac
echo "Remember to hand-edit /etc/stackdriver/collectd.conf Interval for non-prod boxes"
# and machine is ready to rock&roll.
#sudo reboot