-
Notifications
You must be signed in to change notification settings - Fork 0
/
installMultipleMiners.sh
285 lines (246 loc) · 12.2 KB
/
installMultipleMiners.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/bin/bash
# installMultipleMiners.sh
# Created by drMurlly
# 11.02.2024
# The script needs to be run as a root user!
# This script is basically all you need to run multiple miners in Docker containers.
# It'll handle everything for you. If you're familiar with using the terminal,
# you can technically set up multiple matrix masternodes with this script.
# It'll be a smoother experience if you know some basic Ubuntu commands.
########################################################################
# Please adjust the variable.
# How many miners do you want to run? Enter a number between 1 and 30.
# Each miner will need about 50 GB of disk storage and 2 GB of RAM.
# One miner per CPU thread is feasible.
#-------------------- CHANGE THE VARIABLE --------------------#
MAX_MINERJEV=5
#-------------------- CHANGE THE VARIABLE --------------------#
########################################################################
# ------------------------------------------------------------------------------
# Check if the current user is root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root" >&2
else
echo "Running as root, continuing with script..."
sleep 1
fi
# ------------------------------------------------------------------------------
# Delete the working dorectories, in case you need to run installer multiple times.
cd ~ && rm -r Matrix-Mining Masternodes 2>/dev/null
# ------------------------------------------------------------------------------
# Clone the drMurlly's GitHub repository.
cd ~ && git clone https://github.com/drMurlly/Matrix-Mining.git
cd ~/Matrix-Mining/matrix && chmod 755 gman logCleanup nodeConfig.sh
cd ~/Matrix-Mining/scripts && chmod 755 matrixCheck.sh && mv matrixCheck.sh matrixCheck && cp matrixCheck /usr/bin
cd ~/Matrix-Mining/scripts && chmod 755 relaunchMiners.sh
cd ~/Matrix-Mining/scripts && chmod 755 downloadTheFullySyncedChain.sh
# ------------------------------------------------------------------------------
# Download the Docker image from Docker Hub.
docker pull drmurlly/matrix
# ------------------------------------------------------------------------------
# Install all necessary dependencies, Docker, open up the needed ports, and copies matrixCheck to /usr/bin.
apt-get update -y && apt-get upgrade -y
timedatectl set-ntp true
apt install tzdata -y
dpkg-reconfigure tzdata
apt-get install ufw -y rkhunter -y make -y aptitude -y
apt-get install htop -y mc -y nload -y git-all -y
apt-get install auditd -y hwinfo -y pydf -y sysstat -y
sudo apt install cpufrequtils -y
apt install speedtest-cli -y
apt-get install fail2ban -y
systemctl restart fail2ban
apt install docker.io -y
systemctl start docker
systemctl enable docker
ufw default allow outgoing
ufw default deny incoming
ufw allow 50505/tcp
ufw allow 50505/udp
sleep 1 && ufw reload
# ------------------------------------------------------------------------------
# Set up all the necessary folders where you'll need to put your Wallet B credentials.
# You can decide how many miners you want to run. One miner per CPU thread is feasible.
cd ~ && mkdir Masternodes
echo '[
{
"Address":"MAN.xxxYOUR-WALLET-B-ADDRESS",
"Password":"YOUR-WALLET-B-ADDRESS-PASSWORD"
}
]' > ~/Masternodes/signAccount.json
cd ~/Masternodes
for i in $(seq 1 $MAX_MINERJEV); do
mkdir "Miner$i"
cp signAccount.json Miner$i/
mkdir Miner$i/keystore
echo "Created directory Miner$i"
done
rm ~/Masternodes/signAccount.json
cd ~/Matrix-Mining/matrix && cp -r picstore man.json ~/Masternodes/Miner1/
# ------------------------------------------------------------------------------
# Installing the ssh keys to allow to connect to the drMurlly's cloud!
# Download the fully synced matrix blockchain from the drMurlly's cloud.
mkdir ~/.ssh
echo "-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIHbTBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIp1phbaz3ScsCAggA
MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBBHTehUHWhYutzE7KrPE8I1BIIH
EOVphsJha96h5HytLZKCF27q47bmBQyfcPTcQJlkws5qmTlSwG9OauQ7qRvnAqX+
9j4tGGI9P0VLcOo6L2+LPgZC2A+f8QrCobvgQyEuBtnV1vonGsZSolyuWcR82NDn
YTcBXfxK4b8e2eP0E+xTM1HWcsvjwcI6n/GebGFqtTDu34Cgb1o7NYMo2BBHDfm8
KQ9Uc/QOWcBmkiPuShcf1+ILYA121omtxiy2fWdlMEGuseT9utzcW6kOFbZVf3ts
dbKmy8QDR3foBjPProE2p5InjISl9zkNLA6vejQCZB5R9/QeBJKIjkxY1D3uXd7L
8vVsmAjRXOBLflFkZfMgqVjhND89CNBj7hlCZwiIdi1U/Qcj83YfP7sUh46PeIa6
3gUtHD8nd/g8BnYVj0WgU+0qSk4JCXJha8ngGn8ER+/GDhuWYrQ82KtD8A3Vthwt
R/sVFGzOcJm5B5pDthzIs6ErbKt1gOtPjWYZcnleWotxaE0LoJ0nzfAJk9NNUe9l
cnvG1AsABbQ/d/ov8OvBupAn52XZ0SCtFk1b6yPzvRDbYE5yQ4WqXyP+9RJfByX+
xK8XETTAKqgSPidhRLH2hoRH4tgRC/LGs5qdj8/YH1d1DGkusH73bzYZyFFjV4pE
05kyE0pzOwjd/SKE3c8RRR12jWkqxtnX0wOkHbb5K44jq8pR5s/jx9Tu0wf6HAzJ
13Zbj0nch4eWiSLHHZUGqgRtR0Dg5xgclH5W0Xn6yazffGBX3f6Sq7vF/SqybjGG
kd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t6y+JlKWkAl6DOGBdaTAccdd3WcIvOnPNEzo
ud0yCSzkN2SsBAT2035kHXgxjzMYLcUBf1HRn1EMSPvGyTSWufeY+arhyTchEW4f
RiE78CqTK6F9NUV8rNuwkGDByGqotvMX2AW63DjXH79v8II+2gezOPGbQiSv0/hx
aXskXyIWa6HOo3Zy/LfuA+IyioooAJxqve7BQpfxqVDtExycU819XpGbTwv9eCNA
iNvPYkh6h6F80VYCX91PCBDiwNBAoSvvfDjr1uVX1W5FJUqgMnhIqklFytzyqfh1
4bbmHsH1yuO5fGcKtzkMlOZrCQ4C2qbup18NPpJg45pyZP1NRSAeKPDRJfB5Lmh3
tXO5v/V1othYCv9aHU5GjJAFaPY+Ug9kGkUU1v51rUdjd8nBk4Ft5WFK5wo3vqnI
mRice6z3R0qqAs0jSjOqhSUG+1jLF3Mn9nSl4kHLw9mLvTFKgjl8XjrU9fpTEMJL
4xj35LPGbYkDz8SrKo3y0AKXNBxkpsD4j1h6wfrlc6ckbJ6KDS27/IpL1Tc9GxOH
8R9IQM05MTv3JdjJKbt+4ZBiyDbm1IIYFx6K/c4xShi6
-----END ENCRYPTED PRIVATE KEY-----" > ~/.ssh/encrypted_id_rsa
chmod 600 ~/.ssh/encrypted_id_rsa
cd ~/.ssh && openssl rsa -in encrypted_id_rsa -out id_rsa -passin pass:"MATRIXdrMurllyW>2i9w<)p9:]3:k@=&y>7drMurllyMATRIX"
chmod 600 ~/.ssh/id_rsa
clear
echo ""
echo ""
echo "Download the fully synced matrix blockchain from the drMurlly's cloud."
echo "The download can take a while, from several minutes up to an hour, and strongly depends on your internet speed."
echo "If asked, please confirm the connection with yes"
sleep 10
echo ""
rsync -avz --progress -e "ssh -p 48279" matrix1000@162.55.136.22:/home/matrix1000/PublicMiner1/gman ~/Masternodes/Miner1/
sleep 5
# ------------------------------------------------------------------------------
# Copy the blockchain data to all your miners.
echo "Copy the blockchain data to all your miners."
cd ~/Masternodes
for i in $(seq 2 $MAX_MINERJEV); do
cp -r Miner1/gman Miner1/picstore Miner1/man.json Miner$i/
echo "Copied the blockchain data to Miner$i"
done
echo ""
# ------------------------------------------------------------------------------
# Stop and remove the Docker containers, if you run the script multiple times.
sudo docker stop Miner{1..30} 2>/dev/null && sleep 1
sudo docker rm Miner{1..30} 2>/dev/null && sleep 1
# Get the Docker containers up and running.
echo "Get the Docker containers up and running." && sleep 1
cd ~/Masternodes || exit # Ensure we're in the right directory
for dir in Miner*; do
miner_number=$(echo "$dir" | grep -o -E '[0-9]+')
port=$((50000 + miner_number))
sudo docker run --restart unless-stopped -d -e MAN_PORT="$port" -p "$port:$port" -v "/root/Masternodes/$dir:/matrix/chaindata" --name "$dir" drmurlly/matrix
done
echo ""
# ------------------------------------------------------------------------------
# Append aliases to .bashrc
echo "# Matrix Miner Aliasses" >> ~/.bashrc
echo "alias doc='docker ps -a | grep Exit'" >> ~/.bashrc
echo "alias doc1='docker ps -a | grep matrix'" >> ~/.bashrc
echo ""
echo "Aliases added to .bashrc successfully."
sleep 2 && source ~/.bashrc
# ------------------------------------------------------------------------------
echo ""
echo ""
echo "Please wait for 3 min."
echo "The Matrix Docker Container status will be saved in the file: Matrix_Docker_Container_Status.txt."
echo "Your miners are up and running if you didn't receive any errors. It may take up to 5 min to collect the peers."
sleep 180
{
echo ""
date
hostname
echo ""
echo ""
echo "MATRIX DOCKER CONTAINER STATUS"
docker ps -a | grep matrix
echo ""
echo ""
echo "NET PEERS FOR EACH MINER"
for m in $(docker ps | grep nodeConfig | awk {'print $1'}) ; do
docker exec -i $m /bin/bash -c "/matrix/gman attach /matrix/chaindata/gman.ipc -exec net"
done
echo ""
echo ""
echo "DOCKER CONTAINERS INFO"
docker info | head | tail -n6
echo ""
echo "STOPED DOCKER CONTAINERS"
docker ps -a -f status=exited
echo ""
echo ""
echo "HARD WORK BEATS TALENT EVERY TIME
drMurlly from the Blockchain room wish you happy MAN Mining!
Visit the https://stakematrixai.com/ and sign in for the Updates!"
echo ""
} >> ~/Masternodes/Matrix_Docker_Container_Status.txt
echo ""
clear
cat ~/Masternodes/Matrix_Docker_Container_Status.txt
echo ""
# ------------------------------------------------------------------------------
echo ""
echo " ------------------------------------------------------------------------"
echo "After successfully installing, you must place your Wallet B signAccount.json and keystore file in the appropriate place. See screenshots for help."
echo "EXAMPLE for Miner1"
echo "nano /root/Masternodes/Miner1/signAccount.json"
echo ""
echo "Change the address name with your B Wallet. Paste the content from Wallet B Keystore File. Save with Ctrl+s and Exit with Ctrl+x"
echo "cd /root/Masternodes/Miner1/keystore && nano MAN.21aeEZssC2FGjUL3Jv6uTLtAjbCaG"
echo " ------------------------------------------------------------------------"
echo "Help with managing the containers."
echo "cat ~/Masternodes/Matrix_Docker_Container_Status.txt # Check the Matrix Docker Container status"
echo "cd ~/Matrix-Mining # GitHub Clone Dir"
echo "cd ~/Masternodes # Here are located all your miners"
echo " ------------------------------------------------------------------------"
echo ""
echo "docker ps -a -f status=exited # STOPED CONTAINERS"
echo "docker ps -a | grep matrix # RUNNING CONTAINERS"
echo "docker info | head | tail -n6 # DOCKER CONTAINERS INFO"
echo " ------------------------------------------------------------------------"
echo ""
echo "matrixCheck # Check Mining, Syncing, Net_Status or Block_Number status"
echo ""
echo " ------------------------------------------------------------------------"
echo "docker restart Miner{1..30} # Restart all your Docker Containers (Restart Miners)"
echo "docker stop Miner{1..30} # Stop all your Docker Containers (Stop Miners)"
echo "docker rm Miner{1..30} # Delete all your Docker Containers (Stop Miners)"
echo " ------------------------------------------------------------------------"
echo ""
echo "If you get an Error that some Ports are already in use and the Miner is not running,
you need to change the ports manually. The Example command is below."
echo ""
echo "Example Docker command to start the Miner1."
echo "sudo docker run --restart unless-stopped -d -e MAN_PORT=50001 -p 50001:50001 -v /root/Masternodes/Miner1:/matrix/chaindata --name Miner1 drmurlly/matrix"
echo ""
echo "Example Docker command to start the Miner2."
echo "sudo docker run --restart unless-stopped -d -e MAN_PORT=50002 -p 50002:50002 -v /root/Masternodes/Miner2:/matrix/chaindata --name Miner2 drmurlly/matrix"
echo ""
echo ""