-
Notifications
You must be signed in to change notification settings - Fork 10
/
initia_installer.sh
151 lines (130 loc) · 5.49 KB
/
initia_installer.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
set -e
if [ $# -lt 1 ]; then
echo "Kullanım: $0 <moniker>"
exit 1
else
MONIKER=$1
fi
apt update -y
apt install -y build-essential lz4 git jq wget
# Check if Go is installed
if ! command -v go &> /dev/null
then
echo "Go is not installed. Installing..."
echo "Downloading Go..."
wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin:/root/go/bin' >> /root/.bashrc
export PATH=$PATH:/usr/local/go/bin:/root/go/bin
echo "Go is installed."
else
echo "Go is already installed."
fi
echo '* soft nofile 65535' >> /etc/security/limits.conf
echo '* hard nofile 65535' >> /etc/security/limits.conf
if ! command -v initiad &> /dev/null
then
echo "Initia is not installed. Installing..."
git clone https://github.com/initia-labs/initia.git
cd initia
TAG=v0.2.14
git checkout $TAG
make install
else
echo "Initia is already installed."
fi
initiad init $MONIKER --chain-id initiation-1
curl -Ls https://initia.s3.ap-southeast-1.amazonaws.com/initiation-1/genesis.json > \
$HOME/.initia/config/genesis.json
cd $HOME
#check if slinky folder present
if [ -d "/root/slinky" ]; then
echo "Slinky is already installed."
else
echo "Slinky is not installed. Installing..."
git clone https://github.com/skip-mev/slinky.git
cd slinky
git checkout v0.4.3
# Build the Slinky binary in the repo.
make build
fi
if [ ! -d "/etc/systemd/system/oracle.service" ]; then
# Run with the core oracle config from the repo.
sudo tee /etc/systemd/system/oracle.service > /dev/null << EOF
[Unit]
Description=oracle
[Service]
Type=simple
User=root
ExecStart=/root/slinky/build/slinky --oracle-config-path /root/slinky/config/core/oracle.json --market-map-endpoint 0.0.0.0:9090
Restart=on-abort
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=initiad
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
systemctl enable oracle
fi
systemctl restart oracle
if [ ! -d "/etc/systemd/system/initiad.service" ]; then
PEERS="[email protected]:48656,[email protected]:30656,[email protected]:26656,[email protected]:53456,[email protected]:26313,[email protected]:25756,[email protected]:26656,[email protected]:26656,[email protected]:53456,[email protected]:26656,[email protected]:26656,[email protected]:19656,[email protected]:26656,[email protected]:53456,[email protected]:26656,[email protected]:53456,[email protected]:26656,[email protected]:36656,[email protected]:53456,[email protected]:53456,[email protected]:26656,[email protected]:26656,[email protected]:17956"
SEEDS="[email protected]:26656,c28827cb96c14c905b127b92065a3fb4cd77d7f6@testnet-seeds.whispernode.com:25756"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.initia/config/config.toml
sed -i '/^\[oracle\]$/,/^\[/ s/^enabled = .*/enabled = "true"/; s/^oracle_address = .*/oracle_address = "127.0.0.1:8080"/' /root/.initia/config/app.toml
sudo tee /etc/systemd/system/initiad.service > /dev/null << EOF
[Unit]
Description=initiad
[Service]
Type=simple
User=root
ExecStart=/root/go/bin/initiad start
Restart=on-abort
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=initiad
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
systemctl enable initiad
systemctl start initiad
systemctl stop initiad
initiad tendermint unsafe-reset-all --home $HOME/.initia --keep-addr-book
curl -o - -L https://snapshots-testnet.nodejumper.io/initia-testnet/initia-testnet_latest.tar.lz4 | lz4 -c -d - | tar -x -C $HOME/.initia
systemctl start initiad
fi
if ! command -v cosmovisor &> /dev/null
then
echo "Cosmovisor is not installed. Installing..."
export DAEMON_HOME=$HOME/.initia
export DAEMON_NAME=initiad
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
cosmovisor init /root/go/bin/initiad
sudo tee /etc/systemd/system/initiad.service > /dev/null << EOF
[Unit]
Description=initiad
[Service]
Type=simple
User=root
ExecStart=/root/go/bin/cosmovisor run start --home /root/.initia
Restart=on-abort
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=initiad
LimitNOFILE=4096
Environment="DAEMON_NAME=initiad"
Environment="DAEMON_HOME=/root/.initia"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="LD_LIBRARY_PATH=/root/.initia/cosmovisor/current/bin"
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl restart initiad
else
echo "Cosmovisor is already installed."
fi
echo "Installation finished successfully."