-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnode-installer.sh
5233 lines (4502 loc) · 289 KB
/
node-installer.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
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
VRSN="v.4.7.2"
BUILD="20241031_061031"
VAR_DOMAIN=''
VAR_HOST=''
VAR_DIR=''
VAR_CERT=0
VAR_NETWORK=0
VAR_NODE=0
VAR_CONF_RESET=0
# IOTA-HORNET
VAR_IOTA_HORNET_VERSION='2.0.2'
VAR_IOTA_HORNET_UPDATE=1
VAR_IOTA_INX_INDEXER_VERSION='1.0'
VAR_IOTA_INX_MQTT_VERSION='1.0'
VAR_IOTA_INX_PARTICIPATION_VERSION='1.0'
VAR_IOTA_INX_SPAMMER_VERSION='1.0'
VAR_IOTA_INX_POI_VERSION='1.0'
VAR_IOTA_INX_DASHBOARD_VERSION='1.0'
# IOTA-WASP
VAR_IOTA_WASP_VERSION='1.5.1'
VAR_IOTA_WASP_UPDATE=1
VAR_IOTA_WASP_DASHBOARD_VERSION='0.1.9'
VAR_IOTA_WASP_CLI_VERSION='1.5.1'
VAR_IOTA_EVM_ADDR='iota1pzt3mstq6khgc3tl0mwuzk3eqddkryqnpdxmk4nr25re2466uxwm28qqxu5'
# SHIMMER-HORNET
VAR_SHIMMER_HORNET_VERSION='2.0.2'
VAR_SHIMMER_HORNET_UPDATE=1
VAR_SHIMMER_INX_INDEXER_VERSION='1.0'
VAR_SHIMMER_INX_MQTT_VERSION='1.0'
VAR_SHIMMER_INX_PARTICIPATION_VERSION='1.0'
VAR_SHIMMER_INX_SPAMMER_VERSION='1.0'
VAR_SHIMMER_INX_POI_VERSION='1.0'
VAR_SHIMMER_INX_DASHBOARD_VERSION='1.0'
# SHIMMER-WASP
VAR_SHIMMER_WASP_VERSION='1.5.1'
VAR_SHIMMER_WASP_UPDATE=1
VAR_SHIMMER_WASP_DASHBOARD_VERSION='0.1.9'
VAR_SHIMMER_WASP_CLI_VERSION='1.5.1'
VAR_SHIMMER_EVM_ADDR='smr1prxvwqvwf7nru5q5xvh5thwg54zsm2y4wfnk6yk56hj3exxkg92mx20wl3s'
# PLUGINS
VAR_SHIMMER_INX_CHRONICLE_VERSION='1.0.0-rc.4'
VAR_SHIMMER_INX_CHRONICLE_UPDATE=1
VAR_CRON_URL='cd /home && bash -ic "dlt.green'
VAR_CRON_TITLE_1='# DLT.GREEN Node-Installer-Docker: Start all Nodes'
VAR_CRON_TIME_1_1='@reboot sleep '
VAR_CRON_TIME_1_2='60; '
VAR_CRON_JOB_1=' -m s'
VAR_CRON_END_1=' -t 0"'
VAR_CRON_TITLE_2='# DLT.GREEN Node-Installer-Docker: System Maintenance'
VAR_CRON_JOB_2m=' -m 0'
VAR_CRON_JOB_2u=' -m u'
VAR_CRON_END_2=' -t 0 -r 1"'
NODES="iota-hornet iota-wasp shimmer-hornet shimmer-wasp nova-iotacore shimmer-plugins/inx-chronicle"
lg='\033[1m'
or='\e[1;33m'
ca='\e[1;96m'
rd='\e[1;91m'
gn='\e[1;92m'
gr='\e[1;90m'
fl='\033[1m'
xx='\033[0m'
opt_time=10
opt_check=1
opt_level='info'
while getopts "m:t:r:c:l:" option
do
case $option in
c)
case $OPTARG in
0|1) opt_check="$OPTARG" ;;
*) echo "$rd""Invalid Argument for Option -c {0|1}""$xx"
if [ -f "node-installer.sh" ]; then sudo rm node-installer.sh -f; fi
exit ;;
esac
;;
m)
case $OPTARG in
0|1|2|5|6|21|s|u|d) opt_mode="$OPTARG" ;;
*) echo "$rd""Invalid Argument for Option -m {0|1|2|5|6|21|d|s}""$xx"
if [ -f "node-installer.sh" ]; then sudo rm node-installer.sh -f; fi
exit ;;
esac
;;
t)
case $OPTARG in
0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20) opt_time="$OPTARG" ;;
*) echo "$rd""Invalid Argument for Option -t {0-20}""$xx"
if [ -f "node-installer.sh" ]; then sudo rm node-installer.sh -f; fi
exit ;;
esac
;;
r)
case $OPTARG in
0|1) opt_reboot="$OPTARG" ;;
*) echo "$rd""Invalid Argument for Option -r {0|1}""$xx"
if [ -f "node-installer.sh" ]; then sudo rm node-installer.sh -f; fi
exit ;;
esac
;;
l)
case $OPTARG in
e) opt_level='err!' ;;
w) opt_level='warn' ;;
i) opt_level='info' ;;
*) echo "$rd""Invalid Argument for Option -l {i|w|e}""$xx"
if [ -f "node-installer.sh" ]; then sudo rm node-installer.sh -f; fi
exit ;;
esac
;;
\?) echo "$rd""Invalid Option""$xx"
if [ -f "node-installer.sh" ]; then sudo rm node-installer.sh -f; fi
exit ;;
esac
done
echo "$xx"
DEBIAN_FRONTEND=noninteractive apt-get install sudo -y -qq >/dev/null 2>&1
DEBIAN_FRONTEND=noninteractive sudo apt-get install curl -y -qq >/dev/null 2>&1
InstallerHash=$(curl -L https://github.com/dlt-green/node-installer-docker/releases/download/$VRSN/checksum.txt) >/dev/null 2>&1
IotaHornetHash='4bec10daf4d7e2a628ef9369381f85df24d953dbeb5284092b333c71b7f6452a'
IotaHornetPackage="https://github.com/dlt-green/node-installer-docker/releases/download/$VRSN/iota-hornet.tar.gz"
IotaWaspHash='863bb8240c323afd0f243f5c9841cbcb3d194e0182fbec7584d72326bbf058bb'
IotaWaspPackage="https://github.com/dlt-green/node-installer-docker/releases/download/$VRSN/iota-wasp.tar.gz"
ShimmerHornetHash='82d00ee7398763c3aa200253548a28785cdff68cace3aee0057b1573aa4d3ca0'
ShimmerHornetPackage="https://github.com/dlt-green/node-installer-docker/releases/download/$VRSN/shimmer-hornet.tar.gz"
ShimmerWaspHash='54212c5568a64ff59d107a191e7053e608428fcb89fac5180e308bf77765586b'
ShimmerWaspPackage="https://github.com/dlt-green/node-installer-docker/releases/download/$VRSN/shimmer-wasp.tar.gz"
ShimmerChronicleHash='aae3789b98540dd0e8537f3b960a54b2ec9c3772aab7c3c457edc3baffb3862e'
ShimmerChroniclePackage="https://github.com/dlt-green/node-installer-docker/releases/download/$VRSN/shimmer-chronicle.tar.gz"
if [ "$VRSN" = 'dev-latest' ]; then VRSN=$BUILD; fi
clear
if [ -f "node-installer.sh" ]; then
fgrep -q "alias dlt.green=" ~/.bash_aliases >/dev/null 2>&1 || (echo "" >> ~/.bash_aliases && echo "# DLT.GREEN Node-Installer-Docker" >> ~/.bash_aliases && echo "alias dlt.green=" >> ~/.bash_aliases)
if [ -f ~/.bash_aliases ]; then sed -i 's/alias dlt.green=.*/alias dlt.green="sudo wget https:\/\/github.com\/dlt-green\/node-installer-docker\/releases\/latest\/download\/node-installer.sh \&\& sudo sh node-installer.sh"/g' ~/.bash_aliases; fi
if [ -z "$(cat ~/.bashrc | grep bash_aliases)" ]; then echo 'if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases; fi' >> ~/.bashrc; fi
if [ "$(shasum -a 256 './node-installer.sh' | cut -d ' ' -f 1)" != "$InstallerHash" ]; then
echo "$rd"; echo 'Checking Hash of Installer failed...'
echo 'Installer may have been corrupted or tampered during downloading!'
echo "Installation aborted for your Security, downloaded Installer has been deleted!"
sudo rm node-installer.sh -f
echo "$xx"; exit;
fi
sudo rm node-installer.sh -f
fi
if [ "$(id -u)" -ne 0 ]; then echo "$rd" && echo 'Please run DLT.GREEN Automatic Node-Installer with sudo or as root' && echo "$xx"; exit; fi
CheckDistribution() {
tmp="$(cat /etc/issue | cut -d ' ' -f 1)"
case $tmp in
'Ubuntu') VAR_DISTRIBUTION='Ubuntu' ;;
'Debian') VAR_DISTRIBUTION='Debian' ;;
'Siemens') VAR_DISTRIBUTION='Debian' ;;
*) echo "$rd"; echo "Distribution $tmp is not supported!"; echo "$xx"; exit ;;
esac
}
CheckIota() {
if [ -s "/var/lib/iota-hornet/.env" ]; then VAR_NETWORK=1; fi
if [ -s "/var/lib/iota-wasp/.env" ]; then VAR_NETWORK=1; fi
}
CheckShimmer() {
if [ -s "/var/lib/shimmer-hornet/.env" ]; then VAR_NETWORK=2; fi
if [ -s "/var/lib/shimmer-wasp/.env" ]; then VAR_NETWORK=2; fi
if [ -s "/var/lib/nova-iotacore/.env" ]; then VAR_NETWORK=2; fi
}
CheckAutostart() {
if ! [ "$(crontab -l | grep -v ^'#' | grep "$VAR_CRON_URL" | grep "$VAR_CRON_JOB_1" | grep "$VAR_CRON_TIME_1_1")" ]
then
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE-INSTALLER WITH DOCKER $VAR_VRN ║"
echo "║ ║"
echo "║$rd _ _____ _____ _____ _ _ _____ ___ ___ _ _ $xx║"
echo "║$rd / \ |_ _||_ _|| ____|| \ | ||_ _||_ _|/ _ \ | \ | | $xx║"
echo "║$rd / _ \ | | | | | _| | \| | | | | || | | || \| | $xx║"
echo "║$rd / ___ \ | | | | | |___ | |\ | | | | || |_| || |\ | $xx║"
echo "║$rd /_/ \_\|_| |_| |_____||_| \_| |_| |___|\___/ |_| \_| $xx║"
echo "║ ║"
echo "║ ║"
echo "║$rd !!! Autostart for all Nodes not enabled !!! $xx║"
echo "║ ║"
echo "║ in the Moment you must restart your Nodes manually after reboot ║"
echo "║ ║"
echo "║ press [S] to skip, [X] to enable Autostart, [Q] to quit ║"
echo "║ ║"
echo "║ GNU General Public License v3.0 ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] for [X]... [P] to pause / [S] to skip"; echo "$xx"
case $W in
s|S) ;;
q|Q) clear; exit ;;
*) clear
echo "$ca"
echo 'Enable Autostart for all Nodes...'
echo "$xx"
sleep 3
if [ "$(crontab -l 2>&1 | grep 'no crontab')" ]; then
export EDITOR='nano' && echo "# crontab" | crontab -
fi
if ! [ "$(crontab -l | grep "$VAR_CRON_URL" | grep "$VAR_CRON_JOB_1")" ]; then
(echo "$(crontab -l 2>&1 | grep -e '')" && echo "" && echo "$VAR_CRON_TITLE_1" && echo "$VAR_CRON_TIME_1_1""$VAR_CRON_TIME_1_2""$VAR_CRON_URL""$VAR_CRON_JOB_1""$VAR_CRON_END_1") | crontab -
fi
if [ "$(crontab -l | grep "$VAR_CRON_URL" | grep "$VAR_CRON_JOB_1" | grep "$VAR_CRON_TIME_1_1")" ]; then
echo "$gn""Autostart for all Nodes enabled""$xx"
fi
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] to continue... Press [P] to pause / [C] to cancel"; echo "$xx"
;;
esac
fi
}
CheckFirewall() {
if [ $(LC_ALL=en_GB.UTF-8 LC_LANG=en_GB.UTF-8 ufw status | grep 'Status:' | cut -d ' ' -f 2) != 'active' ]
then
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE-INSTALLER WITH DOCKER $VAR_VRN ║"
echo "║ ║"
echo "║$rd _ _____ _____ _____ _ _ _____ ___ ___ _ _ $xx║"
echo "║$rd / \ |_ _||_ _|| ____|| \ | ||_ _||_ _|/ _ \ | \ | | $xx║"
echo "║$rd / _ \ | | | | | _| | \| | | | | || | | || \| | $xx║"
echo "║$rd / ___ \ | | | | | |___ | |\ | | | | || |_| || |\ | $xx║"
echo "║$rd /_/ \_\|_| |_| |_____||_| \_| |_| |___|\___/ |_| \_| $xx║"
echo "║ ║"
echo "║ ║"
echo "║$rd !!! Firewall UFW not enabled !!! $xx║"
echo "║ ║"
echo "║ your default or custom SSH Port will be set ║"
echo "║ ║"
echo "║ press [S] to skip, [X] to enable the Firewall, [Q] to quit ║"
echo "║ ║"
echo "║ GNU General Public License v3.0 ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] for [X]... [P] to pause / [S] to skip"; echo "$xx"
case $W in
s|S) ;;
q|Q) clear; exit ;;
*) clear
echo "$ca"
echo 'Enable UFW Firewall...'
echo "$xx"
sleep 3
if [ -z "$(cat /etc/ssh/sshd_config | grep -v '^#' | grep "^Port"| cut -d ' ' -f 2)" ]
then
VAR_SSH_PORT=22
echo "Set default SSH-Port... $VAR_SSH_PORT/tcp"
else
VAR_SSH_PORT=$(cat /etc/ssh/sshd_config | grep -v '^#' | grep "^Port"| cut -d ' ' -f 2)
echo "Set custom SSH-Port... $VAR_SSH_PORT/tcp"
fi
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] to continue... Press [P] to pause / [C] to cancel"; echo "$xx"
echo ufw allow "$VAR_SSH_PORT/tcp" && ufw allow "$VAR_SSH_PORT/tcp"
sudo ufw --force enable
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] to continue... Press [P] to pause / [C] to cancel"; echo "$xx"
;;
esac
fi
}
DeleteFirewallPort() {
while true; do n=$(ufw status numbered | grep "$1" | head -n 1 | awk -F"[][]" '{print $2}');[ "$n" != "" ] || break; yes | ufw delete "$n"; done;
}
PromptMessage() {
WAIT=$(echo "$1"*10 | bc)
STTY=$(stty -g)
printf "$2"
echo ""
stty intr '^C' -icanon min 0 time "$WAIT" ignbrk -brkint -ixon isig;read -p '> ' W
stty "$STTY"
if [ "$W" = 'P' ] || [ "$W" = 'p' ]; then
echo "$or"
echo "Action paused by user..."
echo "$fl"; echo 'Press [Enter] to continue... Press [C] to cancel';read -p '> ' W
fi
if [ "$W" = 'C' ] || [ "$W" = 'c' ]; then
echo "$rd"
echo "Action canceled by user..."
sleep 3
echo "$xx"
clear
VAR_NETWORK=0; VAR_NODE=0; VAR_DIR=''
DashboardHelper
fi
echo "$gn"
echo "Continue..."
sleep 3
echo "$xx"
}
NotifyMessage() {
NotifyLevel="$1"
NotifyAlias=$(cat ~/.bash_aliases | grep "alias dlt.green-msg" | cut -d '=' -f 2 | cut -d '"' -f 2 2>/dev/null)
NotifyDomain=$(echo "$2" | tr -d " ")
send=1
if [ "$opt_level" = "err!" ]; then
case $NotifyLevel in
info) send=0; priority='X-Priority: 2'; tags='✅' ;;
warn) send=0; priority='X-Priority: 4'; tags='⚠️' ;;
err!) send=1; priority='X-Priority: 5'; tags='❌' ;;
*) send=1 ;;
esac
fi
if [ "$opt_level" = "warn" ]; then
case $NotifyLevel in
info) send=0; priority='X-Priority: 2'; tags='✅' ;;
warn) send=1; priority='X-Priority: 4'; tags='⚠️' ;;
err!) send=1; priority='X-Priority: 5'; tags='❌️' ;;
*) send=1 ;;
esac
fi
if [ "$opt_level" = "info" ]; then
case $NotifyLevel in
info) send=1; priority='X-Priority: 2'; tags='✅' ;;
warn) send=1; priority='X-Priority: 4'; tags='⚠️' ;;
err!) send=1; priority='X-Priority: 5'; tags='❌️' ;;
*) send=1 ;;
esac
fi
if [ "$send" = 1 ]; then
if ! [ "$NotifyAlias" ]; then echo "$or""Send notification not enabled...""$xx"; else
NotifyResult=$($NotifyAlias """$3 """ -H """Title: $tags $NotifyDomain""" -H """$priority""" -H """Tags: dlt.green""" 2>/dev/null | jq -r '.time')
if [ -n "$NotifyResult" ]; then echo "$gn""Send notification successfully...""$xx"; else echo "$rd""Send notification failed...""$xx"; fi
fi
fi
sleep 3
}
FormatToBytes() {
unset bytes;
if [ -n "$1" ]; then
unit=$(echo "$1" | sed -e 's/[^a-zA-Z_]//g' | tr '[:lower:]' '[:upper:]');
value=$(echo "$1" | sed -e "s/$unit//g" | sed "s/,/./g");
case $unit in
KB) bytes=$(echo "$value*1024" | bc);;
MB) bytes=$(echo "$value*1024*1024" | bc);;
GB) bytes=$(echo "$value*1024*1024*1024" | bc);;
TB) bytes=$(echo "$value*1024*1024*1024*1024" | bc);;
PB) bytes=$(echo "$value*1024*1024*1024*1024*1024" | bc);;
*) bytes=$value;;
esac
else
bytes=0;
fi
}
FormatFromBytes() {
unset fbytes;
if [ -n "$1" ]; then
fbytes=$(echo "$1" | cut -d '.' -f 1);
fbytes=$(numfmt --to iec --format "%8f" "$fbytes")B;
fbytes=$(echo "$fbytes" | sed 's/ *$//g' | sed 's/ //g');
fi
}
CheckDomain() {
if [ "$(dig +short "$1")" != "$(curl -s 'https://ipinfo.io/ip')" ]
then
echo ""
echo "$rd""Attention! Verification of your Domain $VAR_HOST failed! Installation aborted!""$xx"
echo "$rd""Maybe you entered a wrong Domain or the DNS is not reachable yet?""$xx"
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] to continue... Press [P] to pause / [C] to cancel"; echo "$xx"
SubMenuMaintenance
else
echo "$gn""Verification of your Domain $VAR_HOST successful""$xx"
fi
}
CheckCertificate() {
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ Check Let's Encrypt Certificate ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo ""
if [ -f "/etc/letsencrypt/live/$VAR_HOST/fullchain.pem" ]
then
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE-INSTALLER WITH DOCKER $VAR_VRN ║"
echo "║""$ca""$VAR_DOMAIN""$xx""║"
echo "║ ║"
echo "║ 1. Use global Certificate ║"
echo "║ X. Use Let's Encrypt Certificate (recommended) ║"
echo "║ ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "$gn""You can receive a free Let's Encrypt Certificate for this Node [X]"
echo "All other Nodes on this Server will automatically use this Certificate""$xx"
echo "$rd""Alternatively, you can also use your own Certificate [1]""$xx"
echo ""
echo "select menu item: "
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] to continue... Press [P] to pause / [C] to cancel"; echo "$xx"
case $W in
1) VAR_CERT=1
rm -rf /var/lib/"$VAR_DIR"/data/letsencrypt/* ;;
*) VAR_CERT=0
rm -rf /var/lib/"$VAR_DIR"/data/letsencrypt/* ;;
esac
else
echo "$xx""No global Let's Encrypt Certificate found, generate a new one... "
VAR_CERT=0
rm -rf /var/lib/"$VAR_DIR"/data/letsencrypt/*
fi
}
CheckConfiguration() {
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ Check *.env Configuration ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo ""
if [ -f "/var/lib/$VAR_DIR/.env" ]
then
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE-INSTALLER WITH DOCKER $VAR_VRN ║"
echo "║""$ca""$VAR_DOMAIN""$xx""║"
echo "║ ║"
echo "║ 1. Reset Configuration (*.env) ║"
echo "║ X. Use existing Configuration (*.env) ║"
echo "║ ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "select menu item: "
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] for [X]... Press [P] to pause / [C] to cancel"; echo "$xx"
case $W in
1) echo "$rd""Reset Configuration... ""$xx"
VAR_CONF_RESET=1 ;;
*) echo "$ca""Use existing Configuration... ""$xx"
VAR_CONF_RESET=0 ;;
esac
else
echo "New Configuration... "
VAR_CONF_RESET=1
fi
}
CheckNodeHealthy() {
VAR_NodeHealthy=false
case $VAR_NODE in
1) VAR_API="api/core/v2/info"; OBJ=".status.isHealthy" ;;
2) VAR_API="info"; OBJ=".Version" ;;
3) VAR_API="info"; OBJ=".tangleTime.synced" ;;
5) VAR_API="api/core/v2/info"; OBJ=".status.isHealthy" ;;
51) VAR_API="api/core/v3/info"; OBJ=".status.isHealthy" ;;
6) VAR_API="v1/node/version"; OBJ=".version" ;;
*) ;;
esac
VAR_NodeHealthy=$(curl https://"${VAR_DOMAIN}":"${VAR_PORT}"/"${VAR_API}" --http1.1 -m 3 -s -X GET -H 'Content-Type: application/json' | jq "${OBJ}" 2>/dev/null)
if [ -z "$VAR_NodeHealthy" ]; then VAR_NodeHealthy=false; fi
}
CheckEventsIota() {
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE-INSTALLER WITH DOCKER $VAR_VRN ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo "$ca"
echo "Verify Event Results..."
echo "$xx"
VAR_DIR='iota-hornet'
cd /var/lib/$VAR_DIR >/dev/null 2>&1 || Dashboard;
VAR_RESTAPI_SALT=$(cat .env 2>/dev/null | grep RESTAPI_SALT | cut -d '=' -f 2);
if [ -z "$VAR_RESTAPI_SALT" ]; then echo "$rd""IOTA-Hornet: No Salt found!""$xx"
else
echo "Event IDs can be found at:"
echo 'https://github.com/iotaledger/participation-events'
echo 'https://github.com/iota-community/governance-participation-events'
echo "Event Data will be saved locally under '/var/lib/iota-hornet/verify-events'"
echo ''
echo "Set the Event ID for verifying ($ca""keep empty to verify all Events of your Node""$xx):"
read -r -p '> ' EVENTS
echo ''
ADDR=$(cat .env 2>/dev/null | grep HORNET_HOST | cut -d '=' -f 2)':'$(cat .env 2>/dev/null | grep HORNET_HTTPS_PORT | cut -d '=' -f 2)
TOKEN=$(docker compose run --rm hornet tool jwt-api --salt "$VAR_RESTAPI_SALT" | awk '{ print $5 }')
echo "$ca""Address: ""$xx""$ADDR"" ($ca""JWT-Token for API Access randomly generated""$xx)"
echo ''
sleep 5
if [ -z "$EVENTS" ]; then
EVENTS=$(curl https://"${ADDR}"/api/participation/v1/events --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.eventIds'); fi
for EVENT_ID in $(echo "$EVENTS" | tr -d '"[] ' | sed 's/,/ /g'); do
echo "───────────────────────────────────────────────────────────────────────────────"
EVENT_NAME=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}" --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.name')
EVENT_SYMBOL=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}" --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.payload.symbol')
EVENT_STATUS=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}"/status --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.status')
EVENT_CHECKSUM=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}"/status --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.checksum')
EVENT_MILESTONE=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}"/status --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.milestoneIndex')
EVENT_QUESTIONS=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}"/status --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.questions')
echo "$ca""Name: ""$xx""$EVENT_NAME"
echo "$ca""Status: ""$xx""$EVENT_STATUS""$ca"" Milestone index: ""$xx""$EVENT_MILESTONE"
if [ "$EVENT_STATUS" = "ended" ]; then
if [ ! -d /var/lib/$VAR_DIR/verify-events ]; then mkdir /var/lib/$VAR_DIR/verify-events || Dashboard; fi
cd /var/lib/$VAR_DIR/verify-events || Dashboard
$(curl https://"${ADDR}"/api/participation/v1/admin/events/"${EVENT_ID}"/rewards --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq '.data' > "${EVENT_ID}")
echo ""
echo "$xx""Event ID: ""$EVENT_ID"
if [ $(jq '.totalRewards' "${EVENT_ID}") = 'null' ]; then
if [ "$EVENT_SYMBOL" = 'null' ]; then
echo "$gn""Checksum: ""$EVENT_CHECKSUM""$xx"
if [ -n "$EVENT_QUESTIONS" ]; then echo "$EVENT_QUESTIONS" > "${EVENT_ID}"; fi
else
echo "$rd""Checksum: ""Authentication Error!""$xx"
fi
else
echo "$gn""Checksum: ""$(jq -r '.checksum' "${EVENT_ID}")"
fi
EVENT_REWARDS="$(jq '.totalRewards' "${EVENT_ID}" 2>/dev/null)"
else
echo ""
echo "$xx""Event ID: ""$EVENT_ID"
echo "$rd""Checksum: ""Event not found or not over yet!""$xx"
EVENT_REWARDS='not available'
fi
echo ""
echo "$ca""Total rewards: ""$xx""$EVENT_REWARDS""$ca"" Symbol: ""$xx""$EVENT_SYMBOL"
echo "───────────────────────────────────────────────────────────────────────────────"
done
fi
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] for [X]... Press [P] to pause / [C] to cancel"; echo "$xx"
Dashboard
}
CheckEventsShimmer() {
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE-INSTALLER WITH DOCKER $VAR_VRN ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo "$ca"
echo "Verify Event Results..."
echo "$xx"
VAR_DIR='shimmer-hornet'
cd /var/lib/$VAR_DIR >/dev/null 2>&1 || Dashboard;
VAR_RESTAPI_SALT=$(cat .env 2>/dev/null | grep RESTAPI_SALT | cut -d '=' -f 2);
if [ -z "$VAR_RESTAPI_SALT" ]; then echo "$rd""Shimmer-Hornet: No Salt found!""$xx"
else
echo "Event IDs can be found at:"
echo 'https://github.com/iotaledger/participation-events'
echo 'https://github.com/iota-community/governance-participation-events'
echo "Event Data will be saved locally under '/var/lib/shimmer-hornet/verify-events'"
echo ''
echo "Set the Event ID for verifying ($ca""keep empty to verify all Events of your Node""$xx):"
read -r -p '> ' EVENTS
echo ''
ADDR=$(cat .env 2>/dev/null | grep HORNET_HOST | cut -d '=' -f 2)':'$(cat .env 2>/dev/null | grep HORNET_HTTPS_PORT | cut -d '=' -f 2)
TOKEN=$(docker compose run --rm hornet tool jwt-api --salt "$VAR_RESTAPI_SALT" | awk '{ print $5 }')
echo "$ca""Address: ""$xx""$ADDR"" ($ca""JWT-Token for API Access randomly generated""$xx)"
echo ''
sleep 5
if [ -z "$EVENTS" ]; then
EVENTS=$(curl https://"${ADDR}"/api/participation/v1/events --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.eventIds'); fi
for EVENT_ID in $(echo "$EVENTS" | tr -d '"[] ' | sed 's/,/ /g'); do
echo "───────────────────────────────────────────────────────────────────────────────"
EVENT_NAME=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}" --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.name')
EVENT_SYMBOL=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}" --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.payload.symbol')
EVENT_STATUS=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}"/status --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.status')
EVENT_CHECKSUM=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}"/status --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.checksum')
EVENT_MILESTONE=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}"/status --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.milestoneIndex')
EVENT_QUESTIONS=$(curl https://"${ADDR}"/api/participation/v1/events/"${EVENT_ID}"/status --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq -r '.questions')
echo "$ca""Name: ""$xx""$EVENT_NAME"
echo "$ca""Status: ""$xx""$EVENT_STATUS""$ca"" Milestone index: ""$xx""$EVENT_MILESTONE"
if [ "$EVENT_STATUS" = "ended" ]; then
if [ ! -d /var/lib/$VAR_DIR/verify-events ]; then mkdir /var/lib/$VAR_DIR/verify-events || Dashboard; fi
cd /var/lib/$VAR_DIR/verify-events || Dashboard
$(curl https://"${ADDR}"/api/participation/v1/admin/events/"${EVENT_ID}"/rewards --http1.1 -s -X GET -H 'Content-Type: application/json' \
-H "Authorization: Bearer ${TOKEN}" | jq '.data' > "${EVENT_ID}")
echo ""
echo "$xx""Event ID: ""$EVENT_ID"
if [ $(jq '.totalRewards' "${EVENT_ID}") = 'null' ]; then
if [ "$EVENT_SYMBOL" = 'null' ]; then
echo "$gn""Checksum: ""$EVENT_CHECKSUM""$xx"
if [ -n "$EVENT_QUESTIONS" ]; then echo "$EVENT_QUESTIONS" > "${EVENT_ID}"; fi
else
echo "$rd""Checksum: ""Authentication Error!""$xx"
fi
else
echo "$gn""Checksum: ""$(jq -r '.checksum' "${EVENT_ID}")"
fi
EVENT_REWARDS="$(jq '.totalRewards' "${EVENT_ID}" 2>/dev/null)"
else
echo ""
echo "$xx""Event ID: ""$EVENT_ID"
echo "$rd""Checksum: ""Event not found or not over yet!""$xx"
EVENT_REWARDS='not available'
fi
echo ""
echo "$ca""Total rewards: ""$xx""$EVENT_REWARDS""$ca"" Symbol: ""$xx""$EVENT_SYMBOL"
echo "───────────────────────────────────────────────────────────────────────────────"
done
fi
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] for [X]... Press [P] to pause / [C] to cancel"; echo "$xx"
Dashboard
}
CheckNodeUpdates() {
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE UPDATE ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] to continue... Press [P] to pause / [C] to cancel"; echo "$xx"
VAR_NETWORK=0; VAR_NODE=0; VAR_DIR=''
INST_VRSN_LIST=$(curl https://api.github.com/repos/dlt-green/node-installer-docker/git/refs/tags | jq -r .[].ref | cut -d / -f 3 | tail -10 | sort -r) >/dev/null 2>&1
for NODE in $NODES; do
if [ -f "/var/lib/$NODE/.env" ]; then
if [ -d "/var/lib/$NODE" ]; then
cd "/var/lib/$NODE" || exit
if [ -f "/var/lib/$NODE/docker-compose.yml" ]; then
if [ "$NODE" = 'iota-hornet' ]; then NODE_VRSN_INST=$(cat .env | grep HORNET_VERSION | cut -d = -f 2); NODE_VRSN_LATEST=$VAR_IOTA_HORNET_VERSION; VAR_NODE=1; fi
if [ "$NODE" = 'iota-wasp' ]; then NODE_VRSN_INST=$(cat .env | grep WASP_VERSION | cut -d = -f 2); NODE_VRSN_LATEST=$VAR_IOTA_WASP_VERSION; VAR_NODE=2; fi
if [ "$NODE" = 'shimmer-hornet' ]; then NODE_VRSN_INST=$(cat .env | grep HORNET_VERSION | cut -d = -f 2); NODE_VRSN_LATEST=$VAR_SHIMMER_HORNET_VERSION; VAR_NODE=5; fi
if [ "$NODE" = 'shimmer-wasp' ]; then NODE_VRSN_INST=$(cat .env | grep WASP_VERSION | cut -d = -f 2); NODE_VRSN_LATEST=$VAR_SHIMMER_WASP_VERSION; VAR_NODE=6; fi
if [ "$NODE" = 'shimmer-plugins/inx-chronicle' ]; then NODE_VRSN_INST=$(cat .env | grep INX_CHRONICLE_VERSION | cut -d = -f 2); NODE_VRSN_LATEST=$VAR_SHIMMER_INX_CHRONICLE_VERSION; VAR_NODE=21; fi
for INSTALLER_VRSN in $INST_VRSN_LIST; do
if [ "$NODE" = 'iota-hornet' ]; then
NODE_VRSN_TMP=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN"/node-installer.sh | grep "^VAR_IOTA_HORNET_VERSION" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$NODE" = 'iota-wasp' ]; then
NODE_VRSN_TMP=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN"/node-installer.sh | grep "^VAR_IOTA_WASP_VERSION" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$NODE" = 'shimmer-hornet' ]; then
NODE_VRSN_TMP=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN"/node-installer.sh | grep "^VAR_SHIMMER_HORNET_VERSION" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$NODE" = 'shimmer-wasp' ]; then
NODE_VRSN_TMP=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN"/node-installer.sh | grep "^VAR_SHIMMER_WASP_VERSION" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$NODE" = 'shimmer-plugins/inx-chronicle' ]; then
NODE_VRSN_TMP=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN"/node-installer.sh | grep "^VAR_SHIMMER_INX_CHRONICLE_VERSION" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$NODE_VRSN_TMP" = "$NODE_VRSN_INST" ]; then NODE_VRSN_LATEST="$NODE_VRSN_TMP"; fi
if [ "$NODE_VRSN_INST" = "$NODE_VRSN_LATEST" ]; then NodeUpdate "$INSTALLER_VRSN" "$NODE" "$VAR_NODE"; break; fi
done
fi
fi
fi
done
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] to continue... Press [P] to pause / [C] to cancel"; echo "$xx"
if ! [ "$opt_mode" ]; then DashboardHelper; fi
}
NodeUpdate() {
INST_VRSN_LIST_TMP=$(curl https://api.github.com/repos/dlt-green/node-installer-docker/git/refs/tags | jq -r .[].ref | cut -d / -f 3 | tail -10) >/dev/null 2>&1
upt=0
for INSTALLER_VRSN_TMP in $INST_VRSN_LIST_TMP; do
if [ "$upt" -eq 1 ]; then upt=$(echo "($upt+1)" | bc); fi
if [ "$upt" -eq 2 ]; then
if [ "$2" = 'iota-hornet' ]; then
NODE_VRSN_UPDATE=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN_TMP"/node-installer.sh | grep "^VAR_IOTA_HORNET_UPDATE" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$2" = 'iota-wasp' ]; then
NODE_VRSN_UPDATE=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN_TMP"/node-installer.sh | grep "^VAR_IOTA_WASP_UPDATE" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$2" = 'shimmer-hornet' ]; then
NODE_VRSN_UPDATE=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN_TMP"/node-installer.sh | grep "^VAR_SHIMMER_HORNET_UPDATE" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$2" = 'shimmer-wasp' ]; then
NODE_VRSN_UPDATE=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN_TMP"/node-installer.sh | grep "^VAR_SHIMMER_WASP_UPDATE" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$2" = 'shimmer-plugins/inx-chronicle' ]; then
NODE_VRSN_UPDATE=$(curl -Ls https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN_TMP"/node-installer.sh | grep "^VAR_SHIMMER_INX_CHRONICLE_UPDATE" | cut -d = -f 2 | sed "s|'||g") >/dev/null 2>&1
fi
if [ "$NODE_VRSN_UPDATE" = '1' ]; then
echo "$ca""DLT.GREEN release $INSTALLER_VRSN_TMP: Update $2... (unattended)" "$xx"
UPDATE=$(cd /home && sudo wget https://github.com/dlt-green/node-installer-docker/releases/download/"$INSTALLER_VRSN_TMP"/node-installer.sh && sh node-installer.sh -m $3 -t 0 -r 0) >/dev/null 2>&1
else
echo "$rd""DLT.GREEN release $INSTALLER_VRSN_TMP: Update $2... (attended)" "$xx"
if [ "$opt_mode" ]; then
VAR_STATUS="$2: update available (attended)"
NotifyMessage "warn" "$VAR_DOMAIN" "$VAR_STATUS"
break;
fi
fi
fi
if [ "$INSTALLER_VRSN_TMP" = "$1" ]; then upt=$(echo "($upt+1)" | bc); fi
done
}
DebugInfo() {
clear
echo ""
echo "$ca""=== System Information ===""$xx"
echo "Operating System: $(lsb_release -d | cut -f 2)"
echo "Kernel Version: $(uname -r)"
echo "Date and Time: $(date)"
echo "$ca""=== CPU ===""$xx"
echo "Model: $(grep 'model name' /proc/cpuinfo | head -n 1 | cut -d ':' -f 2 | sed 's/^[ \t]*//')"
echo "Number of Processor Cores: $(grep -c processor /proc/cpuinfo)"
echo "$ca""=== Memory ===""$xx"
echo "Installed RAM: $(free -h | awk '/Mem/{print $2}')"
echo "$ca""=== Storage ===""$xx"
df -h --output=size,used,avail / | awk 'NR==2 {printf "Total: %s, Used: %s, Free: %s\n", $1, $2, $3}'
echo "$ca""=== Docker ===""$xx"
docker --version
echo "$ca""=== Nodes/Plugins ===""$xx"
for NODE in $NODES; do
if [ -d "/var/lib/$NODE" ]; then
cd "/var/lib/$NODE" || exit
if [ -f .env ]; then
HOST=$(cat .env 2>/dev/null | grep _HOST | cut -d '=' -f 2)
VAR_STATUS="$(docker inspect "$(echo "$NODE" | sed 's/\//./g')" | jq -r '.[] .State .Health .Status')" 2>/dev/null
if [ -z "$VAR_STATUS" ]; then VAR_STATUS="error"; fi
if [ "$VAR_STATUS" = 'healthy' ]; then VAR_STATUS="$gn"$VAR_STATUS"$xx"; else VAR_STATUS="$rd"$VAR_STATUS"$xx"; fi
echo "$NODE"": $VAR_STATUS"
echo "$(cat .env 2>/dev/null | grep 'VERSION\|PRUN' | sed 's/\([A-Z]\)/\L\1/g')"
if [ "$(cat .env 2>/dev/null | grep SSL_CONFIG | cut -d '=' -f 2)" = 'certs' ]; then
TMP="certificate: ""global"
if [ -d "/etc/letsencrypt/live/$HOST" ]; then cd "/etc/letsencrypt/live/$HOST" || exit; fi
if [ -s "fullchain.pem" ]; then TMP=$TMP" | cert [""$gn""ok""$xx""]"; else TMP=$TMP" | cert [""$rd""error""$xx""]"; fi
if [ -s "privkey.pem" ]; then TMP=$TMP" | key [""$gn""ok""$xx""]"; else TMP=$TMP" | key [""$rd""error""$xx""]"; fi
echo "$TMP"
if [ -s "fullchain.pem" ]; then
echo "valid until: ""$(openssl x509 -in "fullchain".pem -noout -enddate | cut -d '=' -f 2)"
else echo "valid until: ""$rd""error""$xx"; fi
else
TMP="certificate: ""let's encrypt"
if [ -d "/var/lib/$NODE/data/letsencrypt" ]; then cd "/var/lib/$NODE/data/letsencrypt" || exit; fi
cat acme.json | jq -r '.myresolver .Certificates[]? | select(.domain.main=="'"$HOST"'") | .certificate' | base64 -d > "$HOST.crt"
cat acme.json | jq -r '.myresolver .Certificates[]? | select(.domain.main=="'"$HOST"'") | .key' | base64 -d > "$HOST.key"
if [ -s "$HOST.crt" ]; then TMP=$TMP" | cert [""$gn""ok""$xx""]"; else TMP=$TMP" | cert [""$rd""error""$xx""]"; fi
if [ -s "$HOST.key" ]; then TMP=$TMP" | key [""$gn""ok""$xx""]"; else TMP=$TMP" | key [""$rd""error""$xx""]"; fi
echo "$TMP"
if [ -s "$HOST.crt" ]; then
echo "valid until: ""$(openssl x509 -in "$HOST".crt -noout -enddate | cut -d '=' -f 2)"
else echo "valid until: ""$rd""error""$xx"; fi
fi
fi
echo ""
fi
done
echo "$ca""=== DLT.GREEN Installer ===""$xx"
echo "Version: $VRSN"
echo "Build: $BUILD"
# echo "$ca""=== Time Synchronization ===""$xx"
# if [ -f /etc/systemd/timesyncd.conf ]; then
#
# sudo systemctl restart systemd-timesyncd.service >/dev/null
#
# if [ -n "$(LC_ALL=en_GB.UTF-8 LC_LANG=en_GB.UTF-8 timedatectl status | grep 'System clock synchronized: yes')" ]; then
# echo "time: ""$gn""synchronized""$xx"
# else
# echo "time: ""$or""not synchronized""$xx"
# fi
# else
# echo "time: ""$rd""error synchronization!""$xx"
# fi
echo "$ca""=== APT Up-to-date Check ===""$xx"
apt update > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "APT: ""$gn""up-to-date""$xx"
else
echo "APT: ""$rd""not up-to-date""$xx"
fi
}
SetCertificateGlobal() {
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE-INSTALLER WITH DOCKER $VAR_VRN ║"
echo "║""$ca""$VAR_DOMAIN""$xx""║"
echo "║ ║"
echo "║ 1. Use Certificate only for this Node ║"
echo "║ X. Update Certificate for all Nodes (recommended) ║"
echo "║ ║"
echo "╚═════════════════════════════════════════════════════════════════════════════╝"
echo ""
echo "$gn""If you [X] update the Certificate for all Nodes (recommended),"
echo "every Node on your Server will use this Certificate after restarting it""$xx"
echo ""
echo "select menu item: "
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] for [X]... Press [P] to pause / [C] to cancel"; echo "$xx"
case $W in
1) ;;
*)
echo "$ca"'Update Certificate for all Nodes...'"$xx"
sleep 15
mkdir -p "/etc/letsencrypt/live/$VAR_HOST" || exit
cd "/var/lib/$VAR_DIR/data/letsencrypt" || exit
cat acme.json | jq -r '.myresolver .Certificates[]? | select(.domain.main=="'"$VAR_HOST"'") | .certificate' | base64 -d > "$VAR_HOST.crt"
cat acme.json | jq -r '.myresolver .Certificates[]? | select(.domain.main=="'"$VAR_HOST"'") | .key' | base64 -d > "$VAR_HOST.key"
if [ -s "/var/lib/$VAR_DIR/data/letsencrypt/$VAR_HOST.crt" ]; then
rm -rf "/etc/letsencrypt/live/$VAR_HOST/*"
cp "/var/lib/$VAR_DIR/data/letsencrypt/$VAR_HOST.crt" "/etc/letsencrypt/live/$VAR_HOST/fullchain.pem"
fi
if [ -s "/var/lib/$VAR_DIR/data/letsencrypt/$VAR_HOST.key" ]; then
cp "/var/lib/$VAR_DIR/data/letsencrypt/$VAR_HOST.key" "/etc/letsencrypt/live/$VAR_HOST/privkey.pem"
echo "$gn""Global Certificate is now updated for all Nodes""$xx"
else
echo "$rd""There was an Error on getting a Let's Encrypt Certificate!""$xx"
echo "$gn""A default Certificate is now generated only for this Node""$xx"
fi
echo "$fl"; PromptMessage "$opt_time" "Press [Enter] / wait ["$opt_time"s] for [X]... Press [P] to pause / [C] to cancel"; echo "$xx"
;;
esac
}
Dashboard() {
VAR_DOMAIN=''
VAR_NODE=1; VAR_NodeHealthy=false; VAR_PORT="9999"
if [ -f "/var/lib/iota-hornet/.env" ]; then
VAR_DOMAIN=$(cat /var/lib/iota-hornet/.env | grep _HOST | cut -d '=' -f 2)
VAR_PORT=$(cat "/var/lib/iota-hornet/.env" | grep HTTPS_PORT | cut -d '=' -f 2)
VAR_IOTA_HORNET_NETWORK=$(cat "/var/lib/iota-hornet/.env" | grep HORNET_NETWORK | cut -d '=' -f 2)
if [ -z "$VAR_PORT" ]; then VAR_PORT="9999"; fi; CheckNodeHealthy
else
VAR_IOTA_HORNET_NETWORK='mainnet'
fi
if $VAR_NodeHealthy; then ih=$gn; elif [ -d /var/lib/iota-hornet ]; then ih=$rd; else ih=$gr; fi
VAR_NODE=2; VAR_NodeHealthy=false; VAR_PORT="9999"
if [ -f "/var/lib/iota-wasp/.env" ]; then
VAR_DOMAIN=$(cat /var/lib/iota-wasp/.env | grep _HOST | cut -d '=' -f 2)
VAR_PORT=$(cat "/var/lib/iota-wasp/.env" | grep API_PORT | cut -d '=' -f 2)
if [ -z "$VAR_PORT" ]; then VAR_PORT="9999"; fi; CheckNodeHealthy
fi
if ! [ "$VAR_NodeHealthy" = "false" ]; then iw=$gn; elif [ -d /var/lib/iota-wasp ]; then iw=$rd; else iw=$gr; fi
VAR_NODE=3; if [ -f "/var/lib/iota-wasp/data/config/wasp-cli/wasp-cli.json" ]; then ic=$gn; elif [ -d /var/lib/iota-wasp ]; then ic=$or; else ic=$gr; fi
VAR_NODE=5; VAR_NodeHealthy=false; VAR_PORT="9999"
if [ -f "/var/lib/shimmer-hornet/.env" ]; then
VAR_DOMAIN=$(cat /var/lib/shimmer-hornet/.env | grep _HOST | cut -d '=' -f 2)
VAR_PORT=$(cat "/var/lib/shimmer-hornet/.env" | grep HTTPS_PORT | cut -d '=' -f 2)
VAR_SHIMMER_HORNET_NETWORK=$(cat "/var/lib/shimmer-hornet/.env" | grep HORNET_NETWORK | cut -d '=' -f 2)
if [ -z "$VAR_PORT" ]; then VAR_PORT="9999"; fi; CheckNodeHealthy
else
VAR_SHIMMER_HORNET_NETWORK='mainnet'
fi
if $VAR_NodeHealthy; then sh=$gn; elif [ -d /var/lib/shimmer-hornet ]; then sh=$rd; else sh=$gr; fi
VAR_NODE=51; VAR_NodeHealthy=false; VAR_PORT="9999"
if [ -f "/var/lib/nova-iotacore/.env" ]; then
CheckNodeHealthy
fi
if $VAR_NodeHealthy; then no=$gn; elif [ -d /var/lib/nova-iotacore ]; then no=$rd; else no=$gr; fi
VAR_NODE=6; VAR_NodeHealthy=false; VAR_PORT="9999"
if [ -f "/var/lib/shimmer-wasp/.env" ]; then
VAR_DOMAIN=$(cat /var/lib/shimmer-wasp/.env | grep _HOST | cut -d '=' -f 2)
VAR_PORT=$(cat "/var/lib/shimmer-wasp/.env" | grep API_PORT | cut -d '=' -f 2)
if [ -z "$VAR_PORT" ]; then VAR_PORT="9999"; fi; CheckNodeHealthy
fi
if ! [ "$VAR_NodeHealthy" = "false" ]; then sw=$gn; elif [ -d /var/lib/shimmer-wasp ]; then sw=$rd; else sw=$gr; fi
VAR_NODE=7; if [ -f "/var/lib/shimmer-wasp/data/config/wasp-cli/wasp-cli.json" ]; then sc=$gn; elif [ -d /var/lib/shimmer-wasp ]; then sc=$or; else sc=$gr; fi
VAR_NODE=0
if [ "$(crontab -l | grep -v ^'#' | grep "$VAR_CRON_URL" | grep "$VAR_CRON_JOB_1" | grep "$VAR_CRON_TIME_1_1")" ]; then cja=$gn; else cja=$rd; fi
if [ "$(crontab -l | grep -v ^'#' | grep "$VAR_CRON_URL" | grep "$VAR_CRON_JOB_2m")" ] || [ "$(crontab -l | grep "$VAR_CRON_URL" | grep "$VAR_CRON_JOB_2u")" ]; then cjb=$gn; else cjb=$rd; fi
if [ "$opt_mode" ]; then VAR_STATUS="installer: $VRSN"; NotifyMessage "info" "$VAR_DOMAIN" "$VAR_STATUS"; fi
PositionCenter "$VAR_DOMAIN"
VAR_DOMAIN=$text
ix=$gr
if [ "$(docker container inspect -f '{{.State.Status}}' shimmer-plugins'.inx-chronicle' 2>/dev/null)" = 'running' ]; then
if [ ix != "$rd" ]; then ix=$gn; fi
elif [ -d /var/lib/shimmer-plugins/inx-chronicle ]; then ix=$rd; else ix=$gr; fi
clear
echo ""
echo "╔═════════════════════════════════════════════════════════════════════════════╗"
echo "║ DLT.GREEN AUTOMATIC NODE-INSTALLER WITH DOCKER $VAR_VRN ║"
echo "║""$ca""$VAR_DOMAIN""$xx""║"
echo "║ ║"
echo "║ ┌──────────────────┬ IOTA Stardust ┬──────────────────┐ ║"