-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathinstall.sh
227 lines (178 loc) · 5.43 KB
/
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/bash
set -x # Enable displaying all commands
echo "Welcome to the installation!"
# Update and upgrade the package list
sudo apt-get update && sudo apt-get upgrade -y
# Install npm, rsync, git, redis-server, nginx, and fail2ban
sudo apt-get install npm rsync git ipset redis-server nginx fail2ban -y
# Configure Fail2Ban for SSH
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo sed -i '/^\[sshd\]$/a enabled = true\nmaxretry = 3\nfindtime = 600\nbantime = 3600' /etc/fail2ban/jail.local
# Restart Fail2Ban to apply changes
sudo systemctl restart fail2ban
# Run journalctl vacuum
sudo journalctl --vacuum-size=500M
sudo ipset create blacklist hash:ip
sudo systemctl enable nginx
sudo systemctl start nginx
sudo rm -f /etc/nginx/sites-available/default
sudo rm -f /etc/nginx/sites-enabled/default
sudo apt-get install python3-certbot-nginx
# Install Node.js Version 14.x
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
# Download and install Go 1.21.0
wget https://golang.org/dl/go1.21.0.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
# Create a symbolic link for the Go binary
sudo ln -s /usr/local/go/bin/go /usr/local/bin/go
# Get the local IP address of the Linux system
ip_address=$(hostname -I | cut -d' ' -f1)
# Build the Go application
go build
# Create modified content with IP address
modified_content=$(cat <<EOF
/* jshint node: true */
module.exports = function (environment) {
var ENV = {
modulePrefix: 'open-etc-pool',
environment: environment,
rootURL: '/',
locationType: 'hash',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}
},
APP: {
// API host and port
ApiUrl: '//$ip_address/',
// HTTP mining endpoint
HttpHost: '$ip_address',
HttpPort: 8888,
// Stratum mining endpoint
StratumHost: '$ip_address',
StratumPort: 8008,
// The ETC network
Unit: 'ETC',
Mining: 'SOLO',
// Fee and payout details
PoolFee: '1.0%',
PayoutThreshold: '0.5 ETC',
BlockReward: 2.56,
// For network hashrate (change for your favourite fork)
BlockTime: 14.4,
highcharts: {
main: {
enabled: true,
height: 200,
type: 'spline',
color: '',
labelColor: '#909090',
lineColor: '#404850',
tickColor: '#404850',
gridLineColor: '#404850',
gridLineWidthX: 1,
gridLineWidthY: 1,
backgroundColor: 'transparent',
title: '',
ytitle: '',
interval: 180000,
chartInterval: 900000
},
account: {
enabled: true,
height: 300,
type: 'spline',
color: ['', ''],
title: '',
ytitle: '',
interval: 180000,
chartInterval: 900000,
paymentInterval: 30000
}
}
}
};
if (environment === 'development') {
/* Override ApiUrl just for development, while you are customizing
frontend markup and css theme on your workstation.
*/
ENV.APP.ApiUrl = 'http://localhost:8080/'
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
// ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
// ENV.APP.LOG_VIEW_LOOKUPS = true;
}
if (environment === 'test') {
// Testem prefers this...
ENV.locationType = 'none';
// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;
ENV.APP.rootElement = '#ember-testing';
}
if (environment === 'production') {
}
return ENV;
};
EOF
)
# Write modified content to environment.js
echo "$modified_content" > www/config/environment.js
# Change into the www directory
cd www
# Install ember-cli and bower globally
sudo npm install -g [email protected]
sudo npm install -g bower
# Change ownership of npm and config directories
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
# Install npm and bower dependencies
npm install
bower install
# Install ember-truth-helpers
ember install ember-truth-helpers
# Install jdenticon
npm install [email protected]
# Run the build.sh script within the www directory
bash build.sh
# Change back to the main directory
cd ..
# Nginx configuration
nginx_config=$(cat <<EOF
upstream api {
server 127.0.0.1:8080;
}
server {
listen *:80;
listen [::]:80;
root /var/www/etc2pool;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location /api {
proxy_pass http://api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
EOF
)
# Path to the pool configuration file
pool_config_path="/etc/nginx/sites-available/pool"
# Write the Nginx configuration to the pool configuration file
echo "$nginx_config" | sudo tee "$pool_config_path" > /dev/null
# Create a symbolic link in the sites-enabled directory
sudo ln -s "$pool_config_path" "/etc/nginx/sites-enabled/"
# Restart Nginx to apply the changes
sudo systemctl restart nginx
set +x # Disable displaying commands
echo "Installation completed!"