-
Notifications
You must be signed in to change notification settings - Fork 0
/
0g-cosmovisor-install.sh
158 lines (133 loc) · 5.64 KB
/
0g-cosmovisor-install.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
#!/bin/bash
LOGO="https://raw.githubusercontent.com/BlackIceNodeRunner/BlackIceGuides/main/logo.sh"
source <(curl -s $LOGO)
bold=$(tput bold)
normal=$(tput sgr0)
clear
logo
set -e
read -p "Enter 0G_MONIKER name:" 0G_MONIKER
export 0G_MONIKER=$0G_MONIKER
0G_PORT=26
read -p "Enter 0G_WALLET name:" 0G_WALLET
export 0G_WALLET=$0G_WALLET
0G_CHAIN_ID="zgtendermint_16600-2"
#SEEDs and PEERs
PEERS="[email protected]:24556,[email protected]:26656,[email protected]:12656,[email protected]:26656,[email protected]:13456,[email protected]:12656,[email protected]:12656,[email protected]:12656,[email protected]:21156,[email protected]:12656,[email protected]:56656,[email protected]:26656,[email protected]:12656,[email protected]:56656,[email protected]:26656"
SEEDS="[email protected]:26656,[email protected]:26656,[email protected]:26656,[email protected]:26656"
#Set Vars
echo "export 0G_MONIKER=$0G_MONIKER" >> $HOME/.bash_profile
echo "export 0G_PORT=$0G_PORT" >> $HOME/.bash_profile
echo "export 0G_WALLET=$0G_WALLET" >> $HOME/.bash_profile
echo "export 0G_CHAIN_ID=$0G_CHAIN_ID" >> $HOME/.bash_profile
header() {
echo -e "\033[92m "
echo "${bold}=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=${normal}"
echo "${bold}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-${normal}"
echo -e " $1"
echo "${bold}=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=${normal}"
echo "${bold}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-${normal}"
echo " \033[0m"
sleep 2
}
#GO LANG install
go_install() {
cd $HOME &&
ver="1.22.4"
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
}
# Install Cosmovisor
cosmovisor_install() {
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
}
# Downloading 0G Labs
0g_download() {
git clone -b v0.2.5 https://github.com/0glabs/0g-chain.git
cd 0g-chain
make install
0gchaind version
}
# Configing node
node_config() {
cd $HOME
0gchaind init $0G_MONIKER --chain-id $OG_CHAIN_ID
0gchaind config chain-id $OG_CHAIN_ID
0gchaind config node tcp://localhost:${OG_PORT}657
0gchaind config keyring-backend os
sleep 2
sudo rm $HOME/.0gchain/config/genesis.json
wget https://github.com/0glabs/0g-chain/releases/download/v0.2.3/genesis.json -O $HOME/.0gchain/config/genesis.json
}
header "GoLang-Instal"
go_install
sleep 5
clear
logo
header "Cheking GO version"
go version
sleep 5
clear
logo
header "Donwloading and installing 0G Labs"
cosmovisor_install
0g_download
sleep 5
clear
logo
header "Doing some Magic things"
node_config
sed -i.bak -e "s/^seeds *=.*/seeds = \"${SEEDS}\"/" $HOME/.0gchain/config/config.toml
sed -i -e "s|^persistent_peers *=.*|persistent_peers = \"$PEERS\"|" $HOME/.0gchain/config/config.toml
sed -i.bak -e "s%:26658%:${OG_PORT}658%g;
s%:26657%:${OG_PORT}657%g;
s%:6060%:${OG_PORT}060%g;
s%:26656%:${OG_PORT}656%g;
s%^external_address = \"\"%external_address = \"$(wget -qO- eth0.me):${OG_PORT}656\"%;
s%:26660%:${OG_PORT}660%g" $HOME/.0gchain/config/config.toml
sed -i "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"0ua0gi\"/" $HOME/.0gchain/config/app.toml
sed -i -e "s/prometheus = false/prometheus = true/" $HOME/.0gchain/config/config.toml
# Cosmoviser folders
mkdir -p $HOME/.0gchain/cosmovisor/genesis/bin
mkdir -p $HOME/.0gchain/cosmovisor/upgrades
mkdir -p $HOME/.0gchain/cosmovisor/backup
cp $HOME/go/bin/0gchaind $HOME/.0gchain/cosmovisor/genesis/bin
COSMOVISER_HOME=$(which cosmovisor)
0G_HOME=$(find $HOME -type d -name ".0gchain")
COSMOVISER_BACKUP=$(find $HOME/.0gchain/cosmovisor -type d -name "backup")
echo "export DAEMON_NAME=0gchaind" >> $HOME/.bash_profile
echo "export DAEMON_HOME=$(find $HOME -type d -name ".0gchain")" >> $HOME/.bash_profile
echo "export DAEMON_DATA_BACKUP_DIR=$(find $HOME/.0gchain/cosmovisor -type d -name "backup")" >> $HOME/.bash_profile
source $HOME/.bash_profile
# Creating service file
sudo tee /etc/systemd/system/0gchaind.service > /dev/null <<EOF
[Unit]
Description=Cosmovisor 0G Node by BlackIceNodeRunner
After=network.target
[Service]
User=$USER
Type=simple
ExecStart=$COSMOVISER_HOME run start --log_output_console
Restart=on-failure
LimitNOFILE=65535
Environment="DAEMON_NAME=0gchaind"
Environment="DAEMON_HOME=0G_HOME"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=true"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="DAEMON_DATA_BACKUP_DIR=COSMOVISER_BACKUP"
Environment="UNSAFE_SKIP_BACKUP=true"
[Install]
WantedBy=multi-user.target
EOF
clear
logo
sleep 2
# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable 0gchaind
sudo systemctl restart 0gchaind
sudo systemctl status 0gchaind