forked from Chainflow/solana-mission-control
-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_script.sh
139 lines (91 loc) · 3.33 KB
/
install_script.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
#!/bin/bash
set -e
cd $HOME
echo "------ checking for go, if it's not installed then it will be installed here -----"
command_exists () {
type "$1" &> /dev/null ;
}
if command_exists go ; then
echo "Golang is already installed"
else
echo "------- Install dependencies -------"
sudo apt update
sudo apt install build-essential jq -y
wget https://dl.google.com/go/go1.16.3.linux-amd64.tar.gz
tar -xvf go1.16.3.linux-amd64.tar.gz
sudo mv go /usr/local
echo "------ Update bashrc ---------------"
export GOPATH=$HOME/go
export GOROOT=/usr/local/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:/usr/local/go/bin:$GOBIN
echo "" >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export GOROOT=/usr/local/go' >> ~/.bashrc
echo 'export GOBIN=$GOPATH/bin' >> ~/.bashrc
echo 'export PATH=$PATH:/usr/local/go/bin:$GOBIN' >> ~/.bashrc
source ~/.bashrc
mkdir -p "$GOBIN"
fi
cd $HOME
echo "----------- Installing grafana -----------"
sudo apt-get install -y adduser libfontconfig1
wget https://dl.grafana.com/oss/release/grafana_7.5.2_amd64.deb
sudo dpkg -i grafana_7.5.2_amd64.deb
echo "------ Starting grafana server using systemd --------"
sudo -S systemctl daemon-reload
sudo -S systemctl start grafana-server
cd $HOME
echo "----------- Installing prometheus -----------"
wget https://github.com/prometheus/prometheus/releases/download/v2.22.1/prometheus-2.22.1.linux-amd64.tar.gz
tar -xvf prometheus-2.22.1.linux-amd64.tar.gz
cp prometheus-2.22.1.linux-amd64/prometheus $HOME/go/bin
cp prometheus-2.22.1.linux-amd64/prometheus.yml $HOME
echo "------- Edit prometheus.yml --------------"
echo "
- job_name: 'solana'
static_configs:
- targets: ['localhost:1234']
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']" >> "$HOME/prometheus.yml"
echo "------- Setup prometheus system service -------"
echo "[Unit]
Description=Prometheus
After=network-online.target
[Service]
Type=simple
ExecStart=$HOME/go/bin/prometheus --config.file=$HOME/prometheus.yml
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target" | sudo tee "/lib/systemd/system/prometheus.service"
echo "------ Start prometheus -----------"
sudo systemctl daemon-reload
sudo systemctl enable prometheus.service
sudo systemctl start prometheus.service
echo "-------- Installing node exporter -----------"
cd $HOME
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz
tar -xvf node_exporter-1.2.2.linux-amd64.tar.gz
sudo cp node_exporter-1.2.2.linux-amd64/node_exporter $HOME/go/bin
echo "---------- Setup Prometheus Node exporter service -----------"
echo "[Unit]
Description=Node_exporter
After=network-online.target
[Service]
Type=simple
ExecStart=$HOME/go/bin/node_exporter
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target" | sudo tee "/lib/systemd/system/node_exporter.service"
echo "----------- Start node exporter ------------"
sudo systemctl daemon-reload
sudo systemctl enable node_exporter.service
sudo systemctl start node_exporter.service
echo "---- Cleaning .dep .tar.gz files of grafana, prometheus and node exporter --------"
rm grafana_7.5.2_amd64.deb node_exporter-1.2.2.linux-amd64.tar.gz prometheus-2.22.1.linux-amd64.tar.gz
echo "** Done with prerequisite installtion **"