-
Notifications
You must be signed in to change notification settings - Fork 2
/
nibiru.sh
175 lines (145 loc) · 11.5 KB
/
nibiru.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
#!/bin/bash
while true
do
# Logo
echo -e '\e[40m\e[91m'
echo -e ' ____ _ '
echo -e ' / ___|_ __ _ _ _ __ | |_ ___ _ __ '
echo -e '| | | __| | | | _ \| __/ _ \| _ \ '
echo -e '| |___| | | |_| | |_) | || (_) | | | | '
echo -e ' \____|_| \__ | __/ \__\___/|_| |_| '
echo -e ' |___/|_| '
echo -e '\e[0m'
sleep 2
# Menu
PS3='Select an action: '
options=(
"Install"
"Create Wallet"
"Create Validator"
"Exit")
select opt in "${options[@]}"
do
case $opt in
"Install")
echo "============================================================"
echo "Install start"
echo "============================================================"
# set vars
if [ ! $NODENAME ]; then
read -p "Enter node name: " NODENAME
echo 'export NODENAME='$NODENAME >> $HOME/.bash_profile
fi
NIBIRU_PORT=39
if [ ! $WALLET ]; then
echo "export WALLET=wallet" >> $HOME/.bash_profile
fi
echo "export NIBIRU_CHAIN_ID=nibiru-testnet-1" >> $HOME/.bash_profile
echo "export NIBIRU_PORT=${NIBIRU_PORT}" >> $HOME/.bash_profile
source $HOME/.bash_profile
# update
sudo apt update && sudo apt upgrade -y
# packages
sudo apt install curl build-essential git wget jq make gcc tmux chrony -y
# install go
if ! [ -x "$(command -v go)" ]; then
ver="1.18.2"
cd $HOME
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz"
rm "go$ver.linux-amd64.tar.gz"
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile
source ~/.bash_profile
fi
# download binary
cd $HOME && rm -rf nibiru
git clone https://github.com/NibiruChain/nibiru.git
cd nibiru
git checkout v0.15.0
make install
# config
nibid config chain-id $NIBIRU_CHAIN_ID
nibid config keyring-backend test
nibid config node tcp://localhost:${NIBIRU_PORT}657
# init
nibid init $NODENAME --chain-id $NIBIRU_CHAIN_ID
# download genesis and addrbook
curl -s https://rpc.testnet-1.nibiru.fi/genesis | jq -r .result.genesis > $HOME/.nibid/config/genesis.json
# set minimum gas price
sed -i -e "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0unibi\"/" $HOME/.nibid/config/app.toml
# set peers and seeds
SEEDS=""
PEERS="[email protected]:60656,b32bb87364a52df3efcbe9eacc178c96b35c823a@nibiru-testnet.nodejumper.io:27656,[email protected]:19656,[email protected]:26656,[email protected]:39656,[email protected]:26656,[email protected]:29656,[email protected]:19656,[email protected]:16656,[email protected]:39656,[email protected]:26656,[email protected]:60656,[email protected]:26656,[email protected]:26656,[email protected]:36656,[email protected]:39656,[email protected]:39656,[email protected]:26656,[email protected]:20086,[email protected]:39656,[email protected]:39656,[email protected]:26656,[email protected]:39656,[email protected]:36656,[email protected]:26656,[email protected]:26656,[email protected]:39656,[email protected]:39656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:46656,[email protected]:29656,[email protected]:39656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:39656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:39656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:39656,[email protected]:16656,[email protected]:39656,[email protected]:46656,[email protected]:39656,[email protected]:36656,[email protected]:26656,[email protected]:26656,[email protected]:39656,[email protected]:39656,[email protected]:60856,[email protected]:26656,[email protected]:26656,[email protected]:39656,[email protected]:26656,[email protected]:26656,[email protected]:29656,[email protected]:39656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:39656,[email protected]:26656,[email protected]:39656,[email protected]:39656,[email protected]:26656,[email protected]:2486,[email protected]:39656,[email protected]:16656,[email protected]:28656,[email protected]:26656,[email protected]:28656,[email protected]:39656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:29656,[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:39656,[email protected]:26656,[email protected]:21656,[email protected]:21656"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/; s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $HOME/.nibid/config/config.toml
# disable indexing
indexer="null"
sed -i -e "s/^indexer *=.*/indexer = \"$indexer\"/" $HOME/.uptickd/config/config.toml
# config pruning
pruning="custom"
pruning_keep_recent="100"
pruning_keep_every="0"
pruning_interval="50"
sed -i -e "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME/.nibid/config/app.toml
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME/.nibid/config/app.toml
sed -i -e "s/^pruning-keep-every *=.*/pruning-keep-every = \"$pruning_keep_every\"/" $HOME/.nibid/config/app.toml
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME/.nibid/config/app.toml
# set custom ports
sed -i.bak -e "s%^proxy_app = \"tcp://127.0.0.1:26658\"%proxy_app = \"tcp://127.0.0.1:${NIBIRU_PORT}658\"%; s%^laddr = \"tcp://127.0.0.1:26657\"%laddr = \"tcp://127.0.0.1:${NIBIRU_PORT}657\"%; s%^pprof_laddr = \"localhost:6060\"%pprof_laddr = \"localhost:${NIBIRU_PORT}060\"%; s%^laddr = \"tcp://0.0.0.0:26656\"%laddr = \"tcp://0.0.0.0:${NIBIRU_PORT}656\"%; s%^prometheus_listen_addr = \":26660\"%prometheus_listen_addr = \":${NIBIRU_PORT}660\"%" $HOME/.nibid/config/config.toml
sed -i.bak -e "s%^address = \"tcp://0.0.0.0:1317\"%address = \"tcp://0.0.0.0:${NIBIRU_PORT}317\"%; s%^address = \":8080\"%address = \":${NIBIRU_PORT}080\"%; s%^address = \"0.0.0.0:9090\"%address = \"0.0.0.0:${NIBIRU_PORT}090\"%; s%^address = \"0.0.0.0:9091\"%address = \"0.0.0.0:${NIBIRU_PORT}091\"%; s%^address = \"0.0.0.0:8545\"%address = \"0.0.0.0:${NIBIRU_PORT}545\"%; s%^ws-address = \"0.0.0.0:8546\"%ws-address = \"0.0.0.0:${NIBIRU_PORT}546\"%" $HOME/.nibid/config/app.toml
# enable prometheus
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.nibid/config/config.toml
# reset
nibid tendermint unsafe-reset-all --home $HOME/.nibid
# create service
sudo tee /etc/systemd/system/nibid.service > /dev/null <<EOF
[Unit]
Description=nibi
After=network-online.target
[Service]
User=$USER
ExecStart=$(which nibid) start --home $HOME/.nibid
Restart=on-failure
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
# start service
sudo systemctl daemon-reload
sudo systemctl enable nibid
sudo systemctl restart nibid
break
;;
"Create Wallet")
nibid keys add $WALLET
echo "============================================================"
echo "Save address and mnemonic"
echo "============================================================"
NIBIRU_WALLET_ADDRESS=$(nibid keys show $WALLET -a)
NIBIRU_VALOPER_ADDRESS=$(nibid keys show $WALLET --bech val -a)
echo 'export NIBIRU_WALLET_ADDRESS='${NIBIRU_WALLET_ADDRESS} >> $HOME/.bash_profile
echo 'export NIBIRU_VALOPER_ADDRESS='${NIBIRU_VALOPER_ADDRESS} >> $HOME/.bash_profile
source $HOME/.bash_profile
break
;;
"Create Validator")
nibid tx staking create-validator \
--amount 2000000unibi \
--from $WALLET \
--commission-max-change-rate "0.01" \
--commission-max-rate "0.2" \
--commission-rate "0.07" \
--min-self-delegation "1" \
--pubkey $(nibid tendermint show-validator) \
--moniker $NODENAME \
--chain-id $NIBIRU_CHAIN_ID
break
;;
"Exit")
exit
;;
*) echo "invalid option $REPLY";;
esac
done
done