forked from strangelove-ventures/ics-testnets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hero-init.sh
executable file
·87 lines (72 loc) · 3.57 KB
/
hero-init.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
#!/bin/bash
# Set up a hero service to join the hero-1 chain.
# Configuration
# You should only have to modify the values in this block
PRIV_VALIDATOR_KEY_FILE=~/priv_validator_key.json
NODE_KEY_FILE=~/node_key.json
NODE_HOME=~/.hero
NODE_MONIKER=hero
# ***
CHAIN_BINARY_URL='https://github.com/hyphacoop/ics-testnets/raw/main/game-of-chains-2022/hero/herod'
CHAIN_BINARY='herod'
CHAIN_ID=hero-1
PERSISTENT_PEERS="[email protected]:26656,[email protected]:26656"
# Install go 1.19.2
echo "Installing go..."
rm go1.19.2.linux-amd64.tar.gz
wget https://go.dev/dl/go1.19.2.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.19.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
# Install chain binary
echo "Installing hero..."
mkdir -p $HOME/go/bin
# Download Linux amd64,
wget $CHAIN_BINARY_URL -O $HOME/go/bin/$CHAIN_BINARY
chmod +x $HOME/go/bin/$CHAIN_BINARY
# or install from source
# echo "Installing build-essential..."
# sudo apt install build-essential -y
# rm -rf hero
# git clone https://github.com/strangelove-ventures/hero.git
# cd hero
# git checkout tags/v0.0.1
# make install
export PATH=$PATH:$HOME/go/bin
# Initialize home directory
echo "Initializing $NODE_HOME..."
rm -rf $NODE_HOME
$CHAIN_BINARY init $NODE_MONIKER --chain-id $CHAIN_ID --home $NODE_HOME
# Replace keys
echo "Replacing keys and genesis file..."
cp $PRIV_VALIDATOR_KEY_FILE $NODE_HOME/config/priv_validator_key.json
cp $NODE_KEY_FILE $NODE_HOME/config/node_key.json
# Reset state
$CHAIN_BINARY tendermint unsafe-reset-all --home $NODE_HOME
sudo rm /etc/systemd/system/$NODE_MONIKER.service
sudo touch /etc/systemd/system/$NODE_MONIKER.service
echo "[Unit]" | sudo tee /etc/systemd/system/$NODE_MONIKER.service
echo "Description=Hero service" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "After=network-online.target" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "[Service]" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "User=$USER" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "ExecStart=$HOME/go/bin/$CHAIN_BINARY start --x-crisis-skip-assert-invariants --home $NODE_HOME --p2p.persistent_peers $PERSISTENT_PEERS" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "Restart=always" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "RestartSec=3" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "LimitNOFILE=4096" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "[Install]" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
echo "WantedBy=multi-user.target" | sudo tee /etc/systemd/system/$NODE_MONIKER.service -a
# Start service
echo "Starting $NODE_MONIKER.service..."
sudo systemctl daemon-reload
# Add go and gaiad to the path
echo "Setting up paths for go..."
echo "export PATH=$PATH:/usr/local/go/bin" >> .profile
echo "***********************"
echo "After you have updated the genesis file, start the hero service:"
echo "sudo systemctl enable $NODE_MONIKER.service"
echo "sudo systemctl start $NODE_MONIKER.service"
echo "And follow the log with:"
echo "journalctl -fu $NODE_MONIKER.service"
echo "***********************"