-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnode_deploy.sh
More file actions
executable file
·118 lines (87 loc) · 3.37 KB
/
node_deploy.sh
File metadata and controls
executable file
·118 lines (87 loc) · 3.37 KB
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
#!/usr/bin/sh
set -o errexit
#THIS BASH SCRIPT AUTOMATES THE NODE AND VALIDATOR DEPLOYMENT PROCESS
# Request the user's moniker
echo "Enter the public name of your node (your moniker) ?"
read moniker
# Installation of Node, Go & Agoric SDK
curl https://deb.nodesource.com/setup_12.x | sudo bash
# Download the Yarn repository configuration
# See instructions on https://legacy.yarnpkg.com/en/docs/install/
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
#Update machine
sudo apt update
sudo apt upgrade -y
# Install Node.js, Yarn, and build tools
# Install jq for formatting of JSON data
sudo apt install nodejs=12.* yarn build-essential jq -y
# Removing any existing old Go installation before installing
sudo rm -rf /usr/local/go
curl https://dl.google.com/go/go1.15.7.linux-amd64.tar.gz | sudo tar -C/usr/local -zxvf -
# Update environment variables to include go
cat <<'EOF' >>$HOME/.profile
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export GO111MODULE=on
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin
EOF
source $HOME/.profile
cd $HOME
#Agoric installation
git clone https://github.com/Agoric/agoric-sdk -b @agoric/sdk@2.15.1
cd agoric-sdk
# Install and build Agoric Javascript packages
yarn install
yarn build
# Install and build Agoric Cosmos SDK support
(cd packages/cosmic-swingset && make)
# Display the version of Agoric SDK installed
ag-chain-cosmos version --long
#Exiting agoric directory
cd ../../
# First, get the network config for the current network.
curl https://testnet.agoric.net/network-config > chain.json
# Set chain name to the correct value
chainName=`jq -r .chainName < chain.json`
# Confirming value: should be something like agorictest-N.
echo $chainName
# First time initialization of validator
ag-chain-cosmos init --chain-id $chainName $moniker
# Download the genesis file
curl https://testnet.agoric.net/genesis.json > $HOME/.ag-chain-cosmos/config/genesis.json
# Reset the state of your validator.
ag-chain-cosmos unsafe-reset-all
# Setting up validator cofig
# Set peers variable to the correct value
peers=$(jq '.peers | join(",")' < chain.json)
# Set seeds variable to the correct value.
seeds=$(jq '.seeds | join(",")' < chain.json)
# Confirm values, each should be something like "077c58e4b207d02bbbb1b68d6e7e1df08ce18a8a@178.62.245.23:26656,..."
echo $peers
echo $seeds
# Fix `Error: failed to parse log level`
sed -i.bak 's/^log_level/# log_level/' $HOME/.ag-chain-cosmos/config/config.toml
# Replace the seeds and persistent_peers values
sed -i.bak -e "s/^seeds *=.*/seeds = $seeds/; s/^persistent_peers *=.*/persistent_peers = $peers/" $HOME/.ag-chain-cosmos/config/config.toml
# Syncing The Node
# Creating systemd service file to manage Agoric Cosmos Deamon
sudo tee <<EOF >/dev/null /etc/systemd/system/ag-chain-cosmos.service
[Unit]
Description=Agoric Cosmos daemon
After=network-online.target
[Service]
User=$USER
ExecStart=$HOME/go/bin/ag-chain-cosmos start --log_level=warn
Restart=on-failure
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable ag-chain-cosmos
sudo systemctl daemon-reload
sudo systemctl start ag-chain-cosmos
echo "To check on the ag service and status of syncing use commands below:
journalctl -u ag-chain-cosmos.service -f
ag-cosmos-helper status 2>&1 | jq .SyncInfo"