-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·112 lines (98 loc) · 3.93 KB
/
setup.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
NODE_NAME="my-validator"
NODE_TYPE="VALIDATOR"
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\\n$fmt\\n" "$@"
}
# Replace the line of the given line number with the given replacement in the given file.
function replace_line() {
local file=config.toml
local line_num=18
local replacement=$1
# Escape backslash, forward slash and ampersand for use as a sed replacement.
replacement_escaped=$( echo "$replacement" | sed -e 's/[\/&]/\\&/g' )
sed -i "${line_num}s/.*/$replacement_escaped/" "$file"
}
setup_golang() {
snap install go --classic
echo "export PATH=$PATH:$(go env GOPATH)/bin" >> ~/.profile
source ~/.profile
fancy_echo "$(go version)"
}
install_astra() {
fancy_echo "install astra"
curl -OL https://github.com/AstraProtocol/astra/releases/download/v3.1.0/astra_3.1.0_Linux_amd64.tar.gz
tar -C ./ -xvf astra_3.1.0_Linux_amd64.tar.gz
cp bin/astrad /usr/bin/astrad
mv bin/astrad ./astrad
}
setup_astra() {
./astrad init $NODE_NAME --chain-id astra_11110-1
cd ~/.astrad/config
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/genesis.json > genesis.json
sed -i "s/genesisValidator/$NODE_NAME/" config.toml
if [[ "$NODE_TYPE" == "RPC" ]];
then
fancy_echo "download rpc"
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/astra_11110-1/api/config.toml > config.toml
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/astra_11110-1/api/app.toml > app.toml
elif [[ "$NODE_TYPE" == "VALIDATOR" ]];
then
fancy_echo "download validator"
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/astra_11110-1/validators/app.toml > app.toml
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/astra_11110-1/validators/config.toml > config.toml
elif [[ "$NODE_TYPE" == "API" ]];
then
fancy_echo "download api"
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/astra_11110-1/api/config.toml > config.toml
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/astra_11110-1/api/app.toml > app.toml
elif [[ "$NODE_TYPE" == "FULLNODE" ]];
then
fancy_echo "download fullnode"
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/astra_11110-1/fullnode/config.toml > config.toml
curl https://raw.githubusercontent.com/AstraProtocol/mainnet/main/astra_11110-1/fullnode/app.toml > app.toml
fi
}
fancy_echo "setting golang"
RESULT=$(go version)
if (exit $?)
then
fancy_echo "$(go version)"
else
fancy_echo "installing golang"
setup_golang
fi
fancy_echo "setting astra"
fancy_echo "setting astra $NODE_NAME"
RESULT=$(astrad version)
if (exit $?)
then
fancy_echo "bravo $(astrad version)"
install_astra
setup_astra
else
fancy_echo "installing astra"
install_astra
setup_astra
fi
cd ~
source ~/.profile
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/[email protected]
echo "# Setup Cosmovisor" >> ~/.profile
echo "export DAEMON_NAME=astrad" >> ~/.profile
echo "export DAEMON_HOME=/root/.astrad" >> ~/.profile
echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=true" >> ~/.profile
echo "export UNSAFE_SKIP_BACKUP=true" >> ~/.profile
source ~/.profile
mkdir -p ~/.astrad/cosmovisor
mkdir -p ~/.astrad/cosmovisor/genesis
mkdir -p ~/.astrad/cosmovisor/genesis/bin
mkdir -p ~/.astrad/cosmovisor/upgrades
cp ~/setup/astrad ~/.astrad/cosmovisor/genesis/bin
fancy_echo "Setup service ----"
curl -s https://raw.githubusercontent.com/AstraProtocol/docs/main/systemd/create-service.sh -o create-service.sh && curl -s https://raw.githubusercontent.com/AstraProtocol/docs/main/systemd/astrad.service.template -o astrad.service.template
chmod +x ./create-service.sh && ./create-service.sh
curl -s https://raw.githubusercontent.com/AstraProtocol/mainnet/main/script > /etc/systemd/system/astrad.service
systemctl daemon-reload
fancy_echo "done !!!"