-
Notifications
You must be signed in to change notification settings - Fork 52
/
install.sh
539 lines (494 loc) · 25 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
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
#! /bin/bash
# Version V0.991c 2023-09-11
# Simple Install script for NEW clean Ubuntu 20.04 install, updates
# the system with various tools and things required to run the various
# parts of chia_plot_manager.
# I use this to create new NAS/Plotter servers.
CURRENTDATETIME=`date +"%Y-%m-%d %T"`
red='\033[0;31m'
yellow='\033[0;33m'
green='\033[0;32m'
white='\033[0;37m'
blue='\033[0;34m'
nc='\033[0m'
## Due to the nature of this script, it must be run as root or via sudo/su.
must_run_as_root(){
if [[ $(id -u) -ne 0 ]]; then
echo
echo -e "${red}ERROR${nc}: Must run as root!"
echo "sudo install.sh option"
echo "or su- first."
echo
exit 1
fi
}
## Welcome everyone....
welcome_message_nas() {
echo -e "\n\n * * * * * * * * Welcome to the ${red}P${yellow}l${green}o${white}t ${blue}M${red}a${yellow}n${green}g${white}e${blue}r${nc} Install Script * * * * * * * *\n"
echo -e "${red}WARNING!${nc} - This script assumes you are installing it on a ${yellow}NAS/Harvester${nc}. Some of the items (such as cron entries)"
echo -e "${red}WARNING!${nc} - may not be suitable for all installations. If you are ${yellow}UNSURE${nc} what options to choose"
echo -e "${red}WARNING!${nc} - during the install (crontab, network performance, creating directories), I suggest that you do not"
echo -e "${red}WARNING!${nc} - utilize those options until you understand them completely!."
echo
echo -e "${red}WARNING!${nc} - ${yellow}I have designed this install script for a Fresh, Clean installation of Ubuntu Linux!${nc}"
echo
echo -e "${red}WARNING!${nc} - Please ${yellow}CAREFULLY${nc} read the notes at the end (or run ./install.sh notes) at any time."
echo -e "${red}WARNING!${nc} - There are a ${yellow}LOT${nc} of configuration changes and path updates that need to be done to"
echo -e "${red}WARNING!${nc} - make these scripts your own!\n"
echo -e -n "Should we ${green}CONTINUE${nc}? "
read -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "\n${yellow}GOODBYE${nc}"
exit 1
fi
}
welcome_message_plot() {
echo -e "\n\n * * * * * * * * Welcome to the ${red}P${yellow}l${green}o${white}t ${blue}M${red}a${yellow}n${green}g${white}e${blue}r${nc} Install Script * * * * * * * *\n"
echo -e "${red}WARNING!${nc} - This script assumes you are installing it on a ${yellow}Dedicated Plotter${nc}. Some of the items (such as cron entries)"
echo -e "${red}WARNING!${nc} - may not be suitable for all installations. If you are ${yellow}UNSURE${nc} what options to choose"
echo -e "${red}WARNING!${nc} - during the install (crontab, network performance, creating directories), I suggest that you do not"
echo -e "${red}WARNING!${nc} - utilize those options until you understand them completely!."
echo
echo -e "${red}WARNING!${nc} - ${yellow}I have designed this install script for a Fresh, Clean installation of Ubuntu Linux!${nc}"
echo
echo -e "${red}WARNING!${nc} - Please ${yellow}CAREFULLY${nc} read the notes at the end (or run ./install.sh notes) at any time."
echo -e "${red}WARNING!${nc} - There are a ${yellow}LOT${nc} of configuration changes and path updates that need to be done to"
echo -e "${red}WARNING!${nc} - make these scripts your own!\n"
echo -e -n "Should we ${green}CONTINUE${nc}? "
read -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "\n${yellow}GOODBYE${nc}"
exit 1
fi
}
welcome_message_coin() {
echo -e "\n\n * * * * * * * * Welcome to the ${red}P${yellow}l${green}o${white}t ${blue}M${red}a${yellow}n${green}g${white}e${blue}r${nc} Install Script * * * * * * * *\n"
echo -e "${red}WARNING!${nc} - This script assumes you are installing it on a ${yellow}Full Node${nc}. Some of the items (such as cron entries)"
echo -e "${red}WARNING!${nc} - may not be suitable for all installations. If you are ${yellow}UNSURE${nc} what options to choose"
echo -e "${red}WARNING!${nc} - during the install (crontab, network performance, creating directories), I suggest that you do not"
echo -e "${red}WARNING!${nc} - utilize those options until you understand them completely!."
echo
echo -e "${red}WARNING!${nc} - ${yellow}I have designed this install script for a Fresh, Clean installation of Ubuntu Linux!${nc}"
echo
echo -e "${red}WARNING!${nc} - Please ${yellow}CAREFULLY${nc} read the notes at the end (or run ./install.sh notes) at any time."
echo -e "${red}WARNING!${nc} - There are a ${yellow}LOT${nc} of configuration changes and path updates that need to be done to"
echo -e "${red}WARNING!${nc} - make these scripts your own!\n"
echo -e -n "Should we ${green}CONTINUE${nc}? "
read -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "\n${yellow}GOODBYE${nc}"
exit 1
fi
}
## Creates our entire plot directory structure based on predefined layouts
create_example_directory_structure(){
echo -e -n "\nShould we ${yellow}CREATE${nc} mount points using example directory structure? "
read -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
nl $current_directory/extras/drive_structures/drive_structures
count="$(wc -l $current_directory/extras/drive_structures/drive_structures | cut -f 1 -d' ')"
n=""
while true; do
echo
read -p "Please Select Drive Structure to CREATE: " n
if [ "$n" -eq "$n" ] && [ "$n" -gt 0 ] && [ "$n" -le "$count" ]
then
break
fi
done
structure_selected="$(sed -n "${n}p" $current_directory/extras/drive_structures/drive_structures)"
echo
echo -e -n "You selected ${yellow}$structure_selected${nc}. Is this ${yellow}CORRECT${nc}? "
read -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo -e "We will duplicate ${blue}$structure_selected${nc}"
xargs mkdir -p < $current_directory/extras/drive_structures/$structure_selected
tree -d /mnt
else
create_example_directory_structure
fi
fi
}
### Clean Up Directories
clean_up_nas_directory(){
echo -e "\n\n${green}Cleaning Up Directory Structure & Setting File Permissions.........${nc}\n"
mv $current_directory/chianas/* $current_directory/
mv $current_directory/utilities/auto_drive.py $current_directory/
mv $current_directory/utilities/get_drive_uuid.sh $current_directory/
rm -rf $current_directory/chianas
rm -rf $current_directory/chiaplot
rm -rf $current_directory/coin_monitor
rm -rf $current_directory/auto_drive
rm -rf $current_directory/images
chmod +x $current_directory/*.py
chmod +x $current_directory/*.sh
chmod +x $current_directory/utilities/*.py
chmod +x $current_directory/utilities/*.sh
mkdir -p /root/.config/plot_manager
if test -f "/root/.config/plot_manager/plot_manager.yaml"; then
echo -e "/root/.config/plot_manager/plot_manager.yaml already exists....\n"
echo -e "Launching our ${blue}Configuration File Updater${nc} to see if updates are needed.......\n"
$current_directory/config_file_updater.py
else
cp $current_directory/plot_manager.skel.yaml /root/.config/plot_manager/plot_manager.yaml
cp $current_directory/plot_manager.skel.yaml /root/.config/plot_manager/INSTRUCTIONS.yaml
rm $current_directory/plot_manager.skel.yaml
fi
}
### Clean Up Directories
clean_up_plot_directory(){
echo -e "\n\n${green}Cleaning Up Directory Structure & Setting File Permissions.........${nc}\n"
mv $current_directory/chiaplot/* $current_directory/
cp $current_directory/chianas/config_file_updater.py $current_directory
rm -rf $current_directory/chiaplot
rm -rf $current_directory/chianas
rm -rf $current_directory/coin_monitor
rm -rf $current_directory/auto_drive
rm -rf $current_directory/images
chmod +x $current_directory/*.py
chmod +x $current_directory/*.sh
mkdir -p /root/.config/plot_manager
if test -f "/root/.config/plot_manager/plot_manager.yaml"; then
echo -e "/root/.config/plot_manager/plot_manager.yaml already exists....\n"
echo -e "Launching our ${blue}Configuration File Updater${nc} to see if updates are needed.......\n"
$current_directory/config_file_updater.py
else
cp $current_directory/plot_manager.skel.yaml /root/.config/plot_manager/plot_manager.yaml
cp $current_directory/plot_manager.skel.yaml /root/.config/plot_manager/INSTRUCTIONS.yaml
rm $current_directory/plot_manager.skel.yaml
fi
}
### Clean Up Directories
clean_up_coin_directory(){
echo -e "\n\n${green}Cleaning Up Directory Structure & Setting File Permissions.........${nc}\n"
mv $current_directory/coin_monitor/* $current_directory/
rm -rf $current_directory/chianas
rm -rf $current_directory/chiaplot
rm -rf $current_directory/coin_monitor
rm -rf $current_directory/auto_drive
rm -rf $current_directory/images
chmod +x $current_directory/*.py
chmod +x $current_directory/*.sh
}
## Let's get rid of SNAP, shall we.....
nuke_snap (){
if [ $(dpkg-query -W -f='${Status}' snapd 2>/dev/null | grep -c "ok installed") -eq 1 ];
then
echo -e -n "\nShould we [${yellow}UNINSTALL${nc}] SNAP? "
read -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -e "\n\n${green}Uninstalling SNAP.........${nc}\n"
systemctl stop snapd && systemctl disable snapd
apt purge snapd
rm -rf ~/snap
rm -rf /snap /var/snap /var/lib/snapd /var/cache/snapd /usr/lib/snapd
mv $current_directory/extras/no-snap.pref /etc/apt/preferences.d/
chown root:root /etc/apt/preferences.d/no-snap.pref
echo -e "${green}DONE${nc}\n"
else
echo -e -n "\nSNAP ${yellow}PRESERVED${nc}!"
fi
fi
}
## Here is where we do all of the software updating that we need to do to
update_software_and_system(){
echo -e "\n\n${green}Updating System Software and Installing Required Packages.........${nc}\n"
apt update && apt upgrade -y # Let's do the basic update of our software before we do anything else
apt install locate vim wget smartmontools tree unzip net-tools tmux python3-pip pv nmap ncat sysstat postfix mailutils duf -y
if [ $(dpkg-query -W -f='${Status}' openssh-server 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
apt install openssh-server -y
systemctl enable openssh
systemctl start openssh
fi
pip3 install -r $current_directory/chianas/requirements.txt
apt autoremove -y
echo -e "${green}DONE${nc}\n"
}
## Figure out exactly what directory we are in so we can make decisions...
get_current_directory(){
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
current_directory="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
}
## Figure out exactly what directory we are in so we can make decisions...
get_current_directory_nas_plot(){
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
current_directory="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
if [ $current_directory != '/root/plot_manager' ]; then
echo -e "\n ${red}* * * * *${white} IMPORTANT ${red}* * * * *${nc}${white} IMPORTANT ${red}* * * * *${nc}${white} IMPORTANT ${red}* * * * *${nc}"
echo -e "${green}All scripts assume that they have been installed at ${white}/root/plot_manager${green}"
echo -e "and are configured as such. If you are changing the install directory,"
echo -e "please review all scripts for the proper paths or they ${red}will${green} fail${nc}.\n\n"
else
echo
fi
}
## Figure out exactly what directory we are in so we can make decisions...
get_current_directory_coin(){
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
current_directory="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
if [ $current_directory != '/home/chia/coin_manager' ]; then
echo -e "\n ${red}* * * * *${white} IMPORTANT ${red}* * * * *${nc}${white} IMPORTANT ${red}* * * * *${nc}${white} IMPORTANT ${red}* * * * *${nc}"
echo -e "${green}These scripts assume that they have been installed at ${white}/home/chia/coin_manager${green}"
echo -e "and are configured as such. If you are changing the install directory,"
echo -e "please review all scripts for the proper paths or they ${red}will${green} fail${nc}.\n\n"
else
echo
fi
}
## Update our crontab with the necessary entries
update_crontab_nas(){
get_current_directory
echo -e "This will update your root crontab to add the following entries If you need something"
echo -e "different, remember to make the necessary changes after the installation has completed."
echo -e ""
echo -e "PATH=$current_directory:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
echo -e "01 00 * * * cd $current_directory && /usr/bin/python3 $current_directory/drive_manager.py -ud >/dev/null 2>&1"
echo -e "02 00 * * * cd $current_directory && /usr/bin/python3 $current_directory/drive_manager.py -dr >/dev/null 2>&1"
echo -e "*/1 * * * * cd $current_directory && /usr/bin/python3 $current_directory/drive_manager.py >/dev/null 2>&1"
echo -e "*/2 * * * * cd $current_directory && /usr/bin/python3 $current_directory/move_local_plots.py >/dev/null 2>&1"
echo -e -n "\nShould we ${yellow}UPDATE${nc} Crontab with these entries? "
read -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
(crontab -l ; echo "PATH=$current_directory:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")| crontab -
(crontab -l ; echo "01 00 * * * cd $current_directory && /usr/bin/python3 $current_directory/drive_manager.py -ud >/dev/null 2>&1")| crontab -
(crontab -l ; echo "02 00 * * * cd $current_directory && /usr/bin/python3 $current_directory/drive_manager.py -dr >/dev/null 2>&1")| crontab -
(crontab -l ; echo "*/1 * * * * cd $current_directory && /usr/bin/python3 $current_directory/drive_manager.py >/dev/null 2>&1")| crontab -
(crontab -l ; echo "*/2 * * * * cd $current_directory && /usr/bin/python3 $current_directory/move_local_plots.py -ud >/dev/null 2>&1")| crontab -
echo -e "\nCrontab has been ${yellow}UPDATED${nc}!\n"
else
echo -e "\nCrontab has ${red}NOT${nc} been ${yellow}UPDATED${nc}!\n"
fi
}
## Update our crontab with the necessary entries
update_crontab_plot(){
get_current_directory
echo -e "This will update your root crontab to add the following entries If you need something"
echo -e "different, remember to make the necessary changes after the installation has completed."
echo -e ""
echo -e "PATH=$current_directory:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
echo -e "*/10 * * * * cd $current_directory && /usr/bin/python3 $current_directory/plot_manager.py >/dev/null 2>&1"
echo -e -n "\nShould we ${yellow}UPDATE${nc} Crontab with these entries? "
read -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
(crontab -l ; echo "PATH=$current_directory:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")| crontab -
(crontab -l ; echo "*/10 * * * * cd $current_directory && /usr/bin/python3 $current_directory/plot_manager.py >/dev/null 2>&1")| crontab -
echo -e "\nCrontab has been ${yellow}UPDATED${nc}!\n"
else
echo -e "\nCrontab has ${red}NOT${nc} been ${yellow}UPDATED${nc}!\n"
fi
}
## Update our crontab with the necessary entries
update_crontab_coin(){
get_current_directory
echo -e "This will update your root crontab to add the following entries If you need something"
echo -e "different, remember to make the necessary changes after the installation has completed."
echo -e ""
echo -e "PATH=$current_directory:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
echo -e "*/1 * * * * /usr/bin/python3 $current_directory/coin_monitor.py >/dev/null 2>&1"
echo -e -n "\nShould we ${yellow}UPDATE${nc} Crontab with these entries? "
read -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
(crontab -l ; echo "PATH=$current_directory:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")| crontab -
(crontab -l ; echo "*/1 * * * * /usr/bin/python3 $current_directory/coin_monitor.py >/dev/null 2>&1")| crontab -
echo -e "\nCrontab has been ${yellow}UPDATED${nc}!\n"
else
echo -e "\nCrontab has ${red}NOT${nc} been ${yellow}UPDATED${nc}!\n"
fi
}
## Add entries into sysctl to improve network performance
improve_network_performance(){
must_run_as_root
echo -e "\nNetwork Performance settings that >>> ${blue}I${nc} <<< use on my 10Gbe connected"
echo -e "plotters, harvesters, and farmers. Your performance may vary from mine!\n"
echo -e -n "\nShould we ${yellow}UPDATE${nc} Network Performance Configuration? "
read -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "vm.swappiness=1" >> /etc/sysctl.conf
echo "net.core.wmem_max=134217728" >> /etc/sysctl.conf
echo "net.ipv4.tcp_wmem=2097152 16777216 33554432" >> /etc/sysctl.conf
echo "net.core.rmem_max=134217728" >> /etc/sysctl.conf
echo "net.ipv4.tcp_rmem=2097152 16777216 33554432" >> /etc/sysctl.conf
echo "net.ipv4.tcp_window_scaling = 1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_timestamps=1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_no_metrics_save=1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_low_latency=0" >> /etc/sysctl.conf
echo "net.ipv4.tcp_mtu_probing=1" >> /etc/sysctl.conf
echo "net.ipv4.tcp_sack = 0" >> /etc/sysctl.conf
echo "net.ipv4.tcp_dsack = 0" >> /etc/sysctl.conf
echo "net.ipv4.tcp_fack = 0" >> /etc/sysctl.conf
echo "net.ipv4.tcp_slow_start_after_idle = 0 " >> /etc/sysctl.conf
echo "net.ipv4.ipfrag_high_threshold = 8388608" >> /etc/sysctl.conf
echo "net.core.netdev_max_backlog = 30000" >> /etc/sysctl.conf
sysctl -e -p /etc/sysctl.conf
echo -e "${green}DONE${nc}\n"
else
echo -e "${green}DONE${nc} - We will ${red}NOT${nc} update performance settings.\n"
fi
}
## Set CPU scaling governor to Performance
set_cpu_performance(){
echo -e -n "\nShould we set our CPU Scaling Governor to ${yellow}PERFORMANCE${nc}? "
read -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "performance" > $file; done
echo -e "${yellow}PERFORMANCE${nc} mode set for all cores!\n"
echo -e -n "\nAdd to ${yellow}Crontab${nc} for persistence across reboots? "
read -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
(crontab -l ; echo "@reboot /root/set_cpu_to_performance.sh")| crontab -
echo -e "\n${yellow}@reboot /root/set_cpu_to_performance.sh${nc} added to root crontab"
mv $current_directory/extras/set_cpu_to_performance.sh /root/
chmod +x /root/set_cpu_to_performance.sh
echo -e "${red}IMPORTANT${nc}: Recommend ${yellow}rebooting${nc} to ensure proper operation!"
else
echo -e "${yellow}set_cpu_to_performance.sh${nc} was ${red}NOT${nc} added to crontab"
fi
else
echo -e "CPU Scaling Governor ${yellow}NOT${nc} adjusted.\n"
fi
}
create_check_network_io_script(){
echo -e "\nCreating ${green}$current_directory/check_network_io.sh${nc}....."
cat <<EOF >>$current_directory/check_network_io.sh
#! /bin/bash
# Script automatically created by install script on: $CURRENTDATETIME"
network_interface=\$1
check_network_traffic(){
echo -e "Checking for network traffic on \$network_interface"
if [[ -f $current_directory/network_stats.io ]]; then
echo -e "check_network_io.sh: Found old stats file, deleting...."
rm $current_directory/network_stats.io
/usr/bin/sar -n DEV 1 3 | egrep \$network_interface > $current_directory/network_stats.io
sleep 1
else
echo -e "check_network_io.sh: Did not find old stats file...."
/usr/bin/sar -n DEV 1 3 | egrep \$network_interface > $current_directory/network_stats.io
sleep 1
fi
if [[ -f $current_directory/network_stats.io ]]; then
return 0
else
return 1
fi
}
until check_network_traffic ; do : ; done
EOF
}
create_send_plot_script(){
cat <<EOF >>$current_directory/send_plot.sh
#!/bin/bash
# Script that we call to send our plots to the selected NAS. Created by the install script
# in order to grab the current working directory. If you have installed you script in a location
# other than $current_directory on you NAS, you will need to update this script to match that
# directory location!
ssh root@\$3 "nohup $current_directory/receive_plot.sh \$2 > foo.out 2> foo.err < /dev/null &"
sudo /usr/bin/pv "\$1" | sudo /usr/bin/ncat --send-only \$3
exit
EOF
}
## Share some final notes...
final_notes(){
get_current_directory
echo -e "\n\nThank you for choosing to try ${green}plot_manager${nc}, I hope it works well for you. If you"
echo -e "Have any trouble or issues, please feel free to reach me on my github page.\n"
echo -e "Before you go, please remember to check your settings to make sure they"
echo -e "agree with your configuration, otherwise you will have issues with the script(s)."
echo -e "By default, the file paths assume installation at /root/plot_manager\n\n"
echo -e "Please edit ${yellow}/root/.config/plot_manager/plot_manager.yaml${nc} and verify all"
echo -e "of the settings. Failure to do so will prevent the script from running properly.\n"
echo -e "To view this again at any time run ${yellow}$current_directory/install.sh notes${nc}\n"
}
thank_you(){
echo -e "\n\nInstall Process Complete - Thank You and have a ${red}G${yellow}R${white}E${green}A${blue}T${nc} Day!\n\n"
}
## Print out help when needed
help (){
echo -e "\nWelcome to ${green}Chia Plot Manager${nc} and associated utilities!\n"
echo -e "Options:"
echo -e " ${yellow}nas${nc} Starts the install process for a NAS/Harvester."
echo -e " ${yellow}plot${nc} Starts the install process for a dedicated Plotter."
echo -e " ${yellow}coin${nc} Starts the install process for the Coin Monitor on a Full Node."
echo -e " ${yellow}auto_drive${nc} Starts the install process for a stand alone version of Auto_Drive"
echo -e " ${yellow}network${nc} Only install network performance updates and exits."
echo -e " ${yellow}notes${nc} Shows after-installation notes."
echo -e " ${yellow}help${nc} Shows this help message.\n"
echo -e "For additional help, please open an issue on my github page.\n"
}
## Here is where we start our install....
start_install_nas(){
must_run_as_root
welcome_message_nas
get_current_directory_nas_plot
nuke_snap
update_software_and_system
create_example_directory_structure
create_check_network_io_script
improve_network_performance
set_cpu_performance
update_crontab_nas
clean_up_nas_directory
final_notes
thank_you
}
start_install_plot(){
must_run_as_root
welcome_message_plot
get_current_directory_nas_plot
nuke_snap
update_software_and_system
create_check_network_io_script
create_send_plot_script
improve_network_performance
set_cpu_performance
update_crontab_plot
clean_up_plot_directory
final_notes
thank_you
}
start_install_coin(){
must_run_as_root
welcome_message_coin
get_current_directory_coin
nuke_snap
update_software_and_system
improve_network_performance
set_cpu_performance
update_crontab_coin
clean_up_coin_directory
final_notes
thank_you
}
## And we're off....
case "$1" in
nas) start_install_nas ;;
plot) start_install_plot ;;
coin) start_install_coin ;;
help) help ;;
network) improve_network_performance ;;
notes) final_notes ;;
*) echo -e "\n${yellow}Usage${nc}: $0 [ nas | plot | coin | network | notes | help ]\n" >&2
exit 1
;;
esac