forked from XK4MiLX/zelnode
-
Notifications
You must be signed in to change notification settings - Fork 29
/
multitoolbox.sh
1047 lines (991 loc) · 40.9 KB
/
multitoolbox.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/bash
#disable bash history
set +o history
if ! [[ -z $1 ]]; then
if [[ $BRANCH_ALREADY_REFERENCED != '1' ]]; then
export ROOT_BRANCH="$1"
export BRANCH_ALREADY_REFERENCED='1'
bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/multitoolbox.sh) $ROOT_BRANCH $2
unset ROOT_BRANCH
unset BRANCH_ALREADY_REFERENCED
set -o history
exit
fi
else
export ROOT_BRANCH='master'
fi
source /dev/stdin <<< "$(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/flux_common.sh)"
if [[ -d /home/$USER/.zelcash ]]; then
CONFIG_DIR='.zelcash'
CONFIG_FILE='zelcash.conf'
else
CONFIG_DIR='.flux'
CONFIG_FILE='flux.conf'
fi
FLUX_DIR='zelflux'
FLUX_APPS_DIR='ZelApps'
COIN_NAME='zelcash'
dversion="v7.8"
PM2_INSTALL="0"
zelflux_setting_import="0"
OS_FLAGE="$2"
function config_veryfity(){
if [[ -f /home/$USER/.flux/flux.conf ]]; then
echo -e "${ARROW} ${YELLOW}Checking config file...${NC}"
insightexplorer=$(cat /home/$USER/.flux/flux.conf | grep 'insightexplorer=1' | wc -l)
if [[ "$insightexplorer" == "1" ]]; then
echo -e "${ARROW} ${CYAN}Insightexplorer enabled..............[${CHECK_MARK}${CYAN}]${NC}"
echo ""
else
echo -e "${WORNING} ${CYAN}Insightexplorer disabled.............[${X_MARK}${CYAN}]${NC}"
echo -e "${WORNING} ${CYAN}Use option 2 for node re-install${NC}"
echo -e ""
exit
fi
fi
}
function config_file() {
if [[ -f /home/$USER/install_conf.json ]]; then
import_settings=$(cat /home/$USER/install_conf.json | jq -r '.import_settings')
bootstrap_url=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_url')
bootstrap_zip_del=$(cat /home/$USER/install_conf.json | jq -r '.bootstrap_zip_del')
use_old_chain=$(cat /home/$USER/install_conf.json | jq -r '.use_old_chain')
prvkey=$(cat /home/$USER/install_conf.json | jq -r '.prvkey')
outpoint=$(cat /home/$USER/install_conf.json | jq -r '.outpoint')
index=$(cat /home/$USER/install_conf.json | jq -r '.index')
zel_id=$(cat /home/$USER/install_conf.json | jq -r '.zelid')
kda_address=$(cat /home/$USER/install_conf.json | jq -r '.kda_address')
upnp_port=$(cat /home/$USER/install_conf.json | jq -r '.upnp_port')
gateway_ip=$(cat /home/$USER/install_conf.json | jq -r '.gateway_ip')
upnp_enabled=$(cat /home/$USER/install_conf.json | jq -r '.upnp_enabled')
thunder=$(cat /home/$USER/install_conf.json | jq -r '.thunder')
echo -e "${ARROW} ${YELLOW}Install config summary:"
if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]];then
echo -e "${PIN}${CYAN}Import settings from install_conf.json...........................[${CHECK_MARK}${CYAN}]${NC}"
else
if [[ "$import_settings" == "1" ]]; then
echo -e "${PIN}${CYAN}Import settings from exist config files..........................[${CHECK_MARK}${CYAN}]${NC}"
fi
fi
if [[ "$use_old_chain" == "1" ]]; then
echo -e "${PIN}${CYAN}During re-installation old chain will be used....................[${CHECK_MARK}${CYAN}]${NC}"
else
if [[ "$bootstrap_url" == "" || "$bootstrap_url" == "0" ]]; then
echo -e "${PIN}${CYAN}Use Flux Bootstrap from source build in scripts..................[${CHECK_MARK}${CYAN}]${NC}"
else
echo -e "${PIN}${CYAN}Use Flux Bootstrap from own source...............................[${CHECK_MARK}${CYAN}]${NC}"
fi
if [[ "$bootstrap_zip_del" == "1" ]]; then
echo -e "${PIN}${CYAN}Remove Flux Bootstrap archive file...............................[${CHECK_MARK}${CYAN}]${NC}"
else
echo -e "${PIN}${CYAN}Leave Flux Bootstrap archive file................................[${CHECK_MARK}${CYAN}]${NC}"
fi
fi
if [[ ( "$discord" != "" && "$discord" != "0" ) || "$telegram_alert" == '1' ]]; then
echo -e "${PIN}${CYAN}Enable watchdog notification.....................................[${CHECK_MARK}${CYAN}]${NC}"
else
echo -e "${PIN}${CYAN}Disable watchdog notification....................................[${CHECK_MARK}${CYAN}]${NC}"
fi
if [[ ! -z $gateway_ip && ! -z $upnp_port ]] && [[ "$upnp_enabled" == "true" ]] ; then
echo -e "${PIN}${CYAN}Enable UPnP configuration........................................[${CHECK_MARK}${CYAN}]${NC}"
fi
fi
}
function install_flux() {
echo -e "${GREEN}Module: Re-install FluxOS${NC}"
echo -e "${YELLOW}================================================================${NC}"
if [[ "$USER" == "root" || "$USER" == "ubuntu" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the user account.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
if pm2 -v > /dev/null 2>&1; then
pm2 del zelflux > /dev/null 2>&1
pm2 del flux > /dev/null 2>&1
pm2 save > /dev/null 2>&1
fi
echo -e "${ARROW} ${CYAN}Removing syncthing...${NC}"
sudo pkill -9 syncthing > /dev/null 2>&1
sudo apt-get remove --purge syncthing -y > /dev/null 2>&1
sudo apt-get autoremove -y > /dev/null 2>&1
docker_check=$(docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" | wc -l)
resource_check=$(df | egrep 'flux' | awk '{ print $1}' | wc -l)
mongod_check=$(mongoexport -d localzelapps -c zelappsinformation --jsonArray --pretty --quiet | jq -r .[].name | head -n1)
if [[ "$mongod_check" != "" && "$mongod_check" != "null" ]]; then
echo -e "${ARROW} ${CYAN}Detected Flux MongoDB local apps collection ...${NC}"
echo -e "${ARROW} ${CYAN}Cleaning MongoDB Flux local apps collection...${NC}"
echo "db.zelappsinformation.drop()" | mongo localzelapps > /dev/null 2>&1
fi
if [[ $docker_check != 0 ]]; then
echo -e "${ARROW} ${CYAN}Detected running docker container...${NC}"
echo -e "${ARROW} ${CYAN}Removing containers...${NC}"
sudo aa-remove-unknown > /dev/null 2>&1 && sudo service docker restart > /dev/null 2>&1
docker container ls -a | egrep 'zelcash|flux' | grep -Eo "^[0-9a-z]{8,}\b" |
while read line; do
sudo docker stop $line > /dev/null 2>&1 && sleep 1
sudo docker rm $line > /dev/null 2>&1 && sleep 1
done
fi
if [[ $resource_check != 0 ]]; then
echo -e "${ARROW} ${CYAN}Detected locked resource...${NC}"
echo -e "${ARROW} ${CYAN}Unmounting locked Flux resource${NC}"
df | egrep 'flux' | awk '{ print $1}' |
while read line; do
sudo umount -l $line
done
fi
if [[ -f /home/$USER/$FLUX_DIR/config/userconfig.js ]]; then
echo -e "${ARROW} ${CYAN}Import settings...${NC}"
ZELID=$(grep -w zelid /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*zelid: .//' | sed -e 's/.\{2\}$//')
WANIP=$(grep -w ipaddress /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*ipaddress: .//' | sed -e 's/.\{2\}$//')
echo -e "${PIN}${CYAN}Zel ID = ${GREEN}$ZELID${NC}"
KDA_A=$(grep -w kadena /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*kadena: .//' | sed -e 's/.\{2\}$//')
if [[ "$KDA_A" != "" ]]; then
echo -e "${PIN}${CYAN}Kadena address = ${GREEN}$KDA_A${NC}"
fi
echo -e "${PIN}${CYAN}IP = ${GREEN}$WANIP${NC}"
upnp_port=$(grep -w apiport /home/$USER/$FLUX_DIR/config/userconfig.js | egrep -o '[0-9]+')
if [[ "$upnp_port" != "" ]]; then
echo -e "${PIN}${CYAN}API port = ${GREEN}$upnp_port${NC}"
fi
router_ip=$(grep -w routerIP /home/$USER/$FLUX_DIR/config/userconfig.js | sed -e 's/.*routerIP: .//' | sed -e 's/.\{2\}$//')
if [[ "$router_ip" != "" ]]; then
echo -e "${PIN}${CYAN}Router IP = ${GREEN}$router_ip${NC}"
fi
ImportBlockedPorts
if [[ "$blockedPortsList" != "" ]]; then
echo -e "${PIN}${CYAN}BlockedPorts: [$display]${NC}"
fi
ImportBlockedRepository
if [[ "$blockedRepositoryList" != "" ]]; then
echo -e "${PIN}${CYAN}BlockedRepositories: [$display]${NC}"
fi
echo -e ""
echo -e "${ARROW} ${CYAN}Removing any instances of FluxOS....${NC}"
sudo rm -rf $FLUX_DIR > /dev/null 2>&1 && sleep 1
if [[ "$ZELID" != "" && "$WANIP" != "" && "$KDA_A" != "" ]]; then
zelflux_setting_import="1"
fi
fi
if [ -d /home/$USER/$FLUX_DIR ]; then
echo -e "${ARROW} ${CYAN}Removing any instances of FluxOS....${NC}"
sudo rm -rf $FLUX_DIR > /dev/null 2>&1 && sleep 1
fi
echo -e "${ARROW} ${CYAN}FluxOS downloading...${NC}"
git clone https://github.com/RunOnFlux/flux.git zelflux > /dev/null 2>&1 && sleep 1
if [[ -d /home/$USER/$FLUX_DIR ]]; then
if [[ -f /home/$USER/$FLUX_DIR/package.json ]]; then
current_ver=$(jq -r '.version' /home/$USER/$FLUX_DIR/package.json)
else
string_limit_x_mark "FluxOS was not downloaded, run script again..........................................."
echo
exit
fi
string_limit_check_mark "FluxOS v$current_ver downloaded..........................................." "FluxOS ${GREEN}v$current_ver${CYAN} downloaded..........................................."
else
string_limit_x_mark "FluxOS was not downloaded, run script again..........................................."
echo
exit
fi
if [[ "$zelflux_setting_import" == "0" ]]; then
get_ip "install"
while true
do
ZELID="$(whiptail --title "MULTITOOLBOX" --inputbox "Enter your ZEL ID from ZelCore (Apps -> Zel ID (CLICK QR CODE)) " 8 72 3>&1 1>&2 2>&3)"
if [ $(printf "%s" "$ZELID" | wc -c) -eq "34" ] || [ $(printf "%s" "$ZELID" | wc -c) -eq "33" ] || [ $(grep -Eo "^0x[a-fA-F0-9]{40}$" <<< "$ZELID") ]; then
string_limit_check_mark "Zel ID is valid..........................................."
break
else
string_limit_x_mark "Zel ID is not valid try again..........................................."
sleep 2
fi
done
while true
do
KDA_A=$(whiptail --inputbox "Node tier eligible to receive KDA rewards, what's your KDA address? Nothing else will be required on FluxOS regarding KDA." 8 85 3>&1 1>&2 2>&3)
if [[ "$KDA_A" != "" && "$KDA_A" != *kadena* && "$KDA_A" = *k:* ]]; then
echo -e "${ARROW} ${CYAN}Kadena address is valid.................[${CHECK_MARK}${CYAN}]${NC}"
KDA_A="kadena:$KDA_A?chainid=0"
sleep 2
break
else
echo -e "${ARROW} ${CYAN}Kadena address is not valid.............[${X_MARK}${CYAN}]${NC}"
sleep 2
fi
done
fi
fluxos_conf_create
if [[ -f /home/$USER/$FLUX_DIR/config/userconfig.js ]]; then
if [[ "$upnp_port" != "" ]]; then
config_builder "apiport" "$upnp_port" "API Port" "fluxos"
fi
if [[ "$router_ip" != "" ]]; then
config_builder "routerIP" "$router_ip" "Router IP" "fluxos"
fi
if [[ "$blockedPortsList" != "" ]]; then
RemoveLine "blockedPorts"
buildBlockedPortsList " blockedPorts" "$blockedPortsList" "Blocked ports list created successfully!" "fluxos"
fi
if [[ "$blockedRepositoryList" != "" ]]; then
RemoveLine "blockedRepositories"
buildBlockedRepositoryList " blockedRepositories" "$blockedRepositoryList" "Blocked repositories list created successfully!" "fluxos"
fi
string_limit_check_mark "FluxOS configuration successfull..........................................."
else
string_limit_x_mark "FluxOS installation failed, missing config file..........................................."
echo
exit
fi
if pm2 -v > /dev/null 2>&1; then
rm restart_zelflux.sh > /dev/null 2>&1
pm2 del flux > /dev/null 2>&1
pm2 del zelflux > /dev/null 2>&1
pm2 save > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Starting FluxOS....${NC}"
echo -e "${ARROW} ${CYAN}FluxOS loading will take 2-3min....${NC}"
echo -e ""
pm2 start /home/$USER/$FLUX_DIR/start.sh --max-memory-restart 1500M --restart-delay 30000 --max-restarts 40 --name flux --time > /dev/null 2>&1
pm2 save > /dev/null 2>&1
pm2 list
else
pm2_install
if [[ "$PM2_INSTALL" == "1" ]]; then
echo -e "${ARROW} ${CYAN}Starting FluxOS....${NC}"
echo -e "${ARROW} ${CYAN}FluxOS loading will take 2-3min....${NC}"
echo
pm2 list
fi
fi
}
function create_config() {
echo -e "${GREEN}Module: Create FluxNode installation config file...${NC}"
echo -e "${YELLOW}================================================================${NC}"
if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the user account.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
if jq --version > /dev/null 2>&1; then
sleep 0.2
else
echo -e "${ARROW} ${YELLOW}Installing JQ....${NC}"
sudo apt install jq -y > /dev/null 2>&1
if jq --version > /dev/null 2>&1; then
#echo -e "${ARROW} ${CYAN}Nodejs version: ${GREEN}$(node -v)${CYAN} installed${NC}"
string_limit_check_mark "JQ $(jq --version) installed................................." "JQ ${GREEN}$(jq --version)${CYAN} installed................................."
echo
else
#echo -e "${ARROW} ${CYAN}Nodejs was not installed${NC}"
string_limit_x_mark "JQ was not installed................................."
echo
exit
fi
fi
CHOICE=$(whiptail --title "Create FluxNode installation config" --menu "Make your choice" 15 65 8 \
"1)" "Manualy - fill questions list" \
"2)" "Auto - import exists settings" 3>&2 2>&1 1>&3 )
case $CHOICE in
"1)")
manual_build
;;
"2)")
config_smart_create
;;
esac
}
function install_watchdog() {
if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the user account.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
echo -e "${GREEN}Module: Install watchdog for FluxNode${NC}"
echo -e "${YELLOW}================================================================${NC}"
if ! pm2 -v > /dev/null 2>&1; then
pm2_install
if [[ "$PM2_INSTALL" == "0" ]]; then
exit
fi
echo -e ""
fi
echo -e "${ARROW} ${CYAN}Cleaning...${NC}"
pm2 del watchdog > /dev/null 2>&1
pm2 save > /dev/null 2>&1
sudo rm -rf /home/$USER/watchdog > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Downloading...${NC}"
cd && git clone https://github.com/RunOnFlux/fluxnode-watchdog.git watchdog > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Installing git hooks....${NC}"
wget https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/$ROOT_BRANCH/post-merge > /dev/null 2>&1
mv post-merge /home/$USER/watchdog/.git/hooks/post-merge
sudo chmod +x /home/$USER/watchdog/.git/hooks/post-merge
echo -e "${ARROW} ${CYAN}Installing watchdog module....${NC}"
cd watchdog && npm install > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Creating config file....${NC}"
if whiptail --yesno "Would you like enable FluxOS auto update?" 8 60; then
flux_update='1'
sleep 1
else
flux_update='0'
sleep 1
fi
if whiptail --yesno "Would you like enable Flux daemon auto update?" 8 60; then
daemon_update='1'
sleep 1
else
daemon_update='0'
sleep 1
fi
if whiptail --yesno "Would you like enable Flux benchmark auto update?" 8 60; then
bench_update='1'
sleep 1
else
bench_update='0'
sleep 1
fi
#if whiptail --yesno "Would you like enable fix action (restart daemon, benchmark, mongodb)?" 8 75; then
fix_action='1'
#sleep 1
#else
#fix_action='0'
##sleep 1
#fi
telegram_alert=0;
discord=0;
if whiptail --yesno "Would you like enable alert notification?" 8 60; then
sleep 1
whiptail --msgbox "Info: to select/deselect item use 'space' ...to switch to OK/Cancel use 'tab' " 10 60
sleep 1
CHOICES=$(whiptail --title "Choose options: " --separate-output --checklist "Choose options: " 10 45 5 \
"1" "Discord notification " ON \
"2" "Telegram notification " OFF 3>&1 1>&2 2>&3 )
if [[ -z "$CHOICES" ]]; then
echo -e "${ARROW} ${CYAN}No option was selected...Alert notification disabled! ${NC}"
sleep 1
discord=0;
ping=0;
telegram_alert=0;
telegram_bot_token=0;
telegram_chat_id=0;
node_label=0;
else
for CHOICE in $CHOICES; do
case "$CHOICE" in
"1")
discord=$(whiptail --inputbox "Enter your discord server webhook url" 8 65 3>&1 1>&2 2>&3)
sleep 1
if whiptail --yesno "Would you like enable nick ping on discord?" 8 60; then
while true
do
ping=$(whiptail --inputbox "Enter your discord user id" 8 60 3>&1 1>&2 2>&3)
if [[ $ping == ?(-)+([0-9]) ]]; then
string_limit_check_mark "UserID is valid..........................................."
break
else
string_limit_x_mark "UserID is not valid try again............................."
sleep 1
fi
done
sleep 1
else
ping=0;
sleep 1
fi
;;
"2")
telegram_alert=1;
while true
do
telegram_bot_token=$(whiptail --inputbox "Enter telegram bot token from BotFather" 8 65 3>&1 1>&2 2>&3)
if [[ $(grep ':' <<< "$telegram_bot_token") != "" ]]; then
string_limit_check_mark "Bot token is valid..........................................."
break
else
string_limit_x_mark "Bot token is not valid try again............................."
sleep 1
fi
done
sleep 1
while true
do
telegram_chat_id=$(whiptail --inputbox "Enter your chat id from GetIDs Bot" 8 60 3>&1 1>&2 2>&3)
if [[ $telegram_chat_id == ?(-)+([0-9]) ]]; then
string_limit_check_mark "Chat ID is valid..........................................."
break
else
string_limit_x_mark "Chat ID is not valid try again............................."
sleep 1
fi
done
sleep 1
;;
esac
done
fi
while true
do
node_label=$(whiptail --inputbox "Enter name of your node (alias)" 8 65 3>&1 1>&2 2>&3)
if [[ "$node_label" != "" && "$node_label" != "0" ]]; then
string_limit_check_mark "Node name is valid..........................................."
break
else
string_limit_x_mark "Node name is not valid try again............................."
sleep 1
fi
done
sleep 1
else
node_label=0;
discord=0;
ping=0;
telegram_alert=0;
telegram_bot_token=0;
telegram_chat_id=0;
sleep 1
fi
if [[ $discord == 0 ]]; then
ping=0;
fi
if [[ $telegram_alert == 0 ]]; then
telegram_bot_token=0;
telegram_chat_id=0;
fi
if [[ -f /home/$USER/$CONFIG_DIR/$CONFIG_FILE ]]; then
index_from_file=$(grep -w zelnodeindex /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeindex=//')
tx_from_file=$(grep -w zelnodeoutpoint /home/$USER/$CONFIG_DIR/$CONFIG_FILE | sed -e 's/zelnodeoutpoint=//')
stak_info=$(curl -s -m 5 https://explorer.runonflux.io/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2> /dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
if [[ "$stak_info" == "" ]]; then
stak_info=$(curl -s -m 5 https://explorer.runonflux.io/api/tx/$tx_from_file | jq -r ".vout[$index_from_file] | .value,.n,.scriptPubKey.addresses[0],.spentTxId" 2> /dev/null | paste - - - - | awk '{printf "%0.f %d %s %s\n",$1,$2,$3,$4}' | grep 'null' | egrep -o '1000|12500|40000')
fi
fi
if [[ $stak_info == ?(-)+([0-9]) ]]; then
case $stak_info in
"1000") eps_limit=240 ;;
"12500") eps_limit=640 ;;
"40000") eps_limit=1520 ;;
esac
else
eps_limit=0;
fi
watchdog_conf_create
echo -e "${ARROW} ${CYAN}Starting watchdog...${NC}"
pm2 start /home/$USER/watchdog/watchdog.js --name watchdog --watch /home/$USER/watchdog --ignore-watch '"./**/*.git" "./**/*node_modules" "./**/*watchdog_error.log" "./**/*config.js"' --watch-delay 20 > /dev/null 2>&1
pm2 save > /dev/null 2>&1
if [[ -f /home/$USER/watchdog/watchdog.js ]]; then
current_ver=$(jq -r '.version' /home/$USER/watchdog/package.json)
string_limit_check_mark "Watchdog v$current_ver installed..........................................." "Watchdog ${GREEN}v$current_ver${CYAN} installed..........................................."
else
string_limit_x_mark "Watchdog was not installed..........................................."
fi
echo -e ""
}
function flux_daemon_bootstrap() {
echo -e "${GREEN}Module: Restore Flux blockchain from bootstrap${NC}"
echo -e "${YELLOW}================================================================${NC}"
if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the user account.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
cd
echo -e "${NC}"
config_veryfity
bootstrap_new
}
function install_node(){
echo -e "${GREEN}Module: Install FluxNode${NC}"
echo -e "${YELLOW}================================================================${NC}"
if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the user account.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then
echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}"
echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation"
echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
echo
exit
fi
if [[ "$OS_FLAGE" == "" ]]; then
os_check
fi
if sudo docker run hello-world > /dev/null 2>&1; then
echo -e ""
else
echo -e "${WORNING}${CYAN}Docker is not working correct or is not installed.${NC}"
exit
fi
bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/${ROOT_BRANCH}/install_pro.sh)
}
function install_docker(){
echo -e "${GREEN}Module: Install Docker${NC}"
echo -e "${YELLOW}================================================================${NC}"
if [[ "$USER" != "root" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the root account use command 'sudo su -'.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
if [[ $(lsb_release -d) != *Debian* && $(lsb_release -d) != *Ubuntu* ]]; then
echo -e "${WORNING} ${CYAN}ERROR: ${RED}OS version $(lsb_release -si) not supported${NC}"
echo -e "${CYNA}Ubuntu 20.04 LTS is the recommended OS version .. please re-image and retry installation"
echo -e "${WORNING} ${CYAN}Installation stopped...${NC}"
echo
exit
fi
if [[ "$OS_FLAGE" == "" ]]; then
os_check
fi
if [[ -z "$usernew" ]]; then
usernew="$(whiptail --title "MULTITOOLBOX $dversion" --inputbox "Enter your username" 8 72 3>&1 1>&2 2>&3)"
usernew=$(awk '{print tolower($0)}' <<< "$usernew")
else
echo -e "${PIN}${CYAN} Import docker user '$usernew' from environment variable............[${CHECK_MARK}${CYAN}]${NC}"
fi
echo -e "${ARROW} ${CYAN}New User: ${GREEN}${usernew}${NC}"
adduser --gecos "" "$usernew"
usermod -aG sudo "$usernew" > /dev/null 2>&1
echo -e "${ARROW} ${YELLOW}Update and upgrade system...${NC}"
apt update -y && apt upgrade -y
if ! ufw version > /dev/null 2>&1; then
echo -e "${ARROW} ${YELLOW}Installing ufw firewall..${NC}"
sudo apt-get install -y ufw > /dev/null 2>&1
fi
cron_check=$(systemctl status cron 2> /dev/null | grep 'active' | wc -l)
if [[ "$cron_check" == "0" ]]; then
echo -e "${ARROW} ${YELLOW}Installing crontab...${NC}"
sudo apt-get install -y cron > /dev/null 2>&1
fi
echo -e "${ARROW} ${YELLOW}Installing docker...${NC}"
echo -e "${ARROW} ${CYAN}Architecture: ${GREEN}$(dpkg --print-architecture)${NC}"
if [[ -f /usr/share/keyrings/docker-archive-keyring.gpg ]]; then
sudo rm /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
fi
if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
sudo rm /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
fi
if [[ $(lsb_release -d) = *Debian* ]]; then
sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1
sudo apt-get update -y > /dev/null 2>&1
sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1
sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1
#curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - > /dev/null 2>&1
#sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" > /dev/null 2>&1
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
sudo apt-get update -y > /dev/null 2>&1
sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1
else
sudo apt-get remove docker docker-engine docker.io containerd runc -y > /dev/null 2>&1
sudo apt-get -y install apt-transport-https ca-certificates > /dev/null 2>&1
sudo apt-get -y install curl gnupg-agent software-properties-common > /dev/null 2>&1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null 2>&1
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 2>&1
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - > /dev/null 2>&1
#sudo add-apt-repository -y "deb [arch=amd64,arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" > /dev/null 2>&1
sudo apt-get update -y > /dev/null 2>&1
sudo apt-get install docker-ce docker-ce-cli containerd.io -y > /dev/null 2>&1
fi
echo -e "${ARROW} ${YELLOW}Adding $usernew to docker group...${NC}"
adduser "$usernew" docker
echo -e "${NC}"
echo -e "${YELLOW}=====================================================${NC}"
echo -e "${YELLOW}Running through some checks...${NC}"
echo -e "${YELLOW}=====================================================${NC}"
if sudo docker run hello-world > /dev/null 2>&1; then
echo -e "${CHECK_MARK} ${CYAN}Docker is installed${NC}"
else
echo -e "${X_MARK} ${CYAN}Docker did not installed${NC}"
fi
if [[ $(getent group docker | grep "$usernew") ]]; then
echo -e "${CHECK_MARK} ${CYAN}User $usernew is member of 'docker'${NC}"
else
echo -e "${X_MARK} ${CYAN}User $usernew is not member of 'docker'${NC}"
fi
echo -e "${YELLOW}=====================================================${NC}"
echo -e "${NC}"
read -p "Would you like switch to user account Y/N?" -n 1 -r
echo -e "${NC}"
if [[ $REPLY =~ ^[Yy]$ ]]; then
su - $usernew
fi
}
function install_watchtower(){
echo -e "${GREEN}Module: Install flux_watchtower for docker images autoupdate${NC}"
echo -e "${YELLOW}================================================================${NC}"
if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the user account.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
echo -e ""
echo -e "${ARROW} ${CYAN}Checking if flux_watchtower is installed....${NC}"
apps_check=$(docker ps | grep "flux_watchtower")
if [[ "$apps_check" != "" ]]; then
echo -e "${ARROW} ${CYAN}Stopping flux_watchtower...${NC}"
docker stop flux_watchtower > /dev/null 2>&1
sleep 2
echo -e "${ARROW} ${CYAN}Removing flux_watchtower...${NC}"
docker rm flux_watchtower > /dev/null 2>&1
fi
echo -e "${ARROW} ${CYAN}Downloading containrrr/watchtower image...${NC}"
docker pull containrrr/watchtower:latest > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Starting containrrr/watchtower...${NC}"
random=$(shuf -i 7500-35000 -n 1)
echo -e "${ARROW} ${CYAN}Interval: ${GREEN} $random sec.${NC}"
apps_id=$(docker run -d \
--restart unless-stopped \
--name flux_watchtower \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower \
--cleanup --interval $random 2> /dev/null)
if [[ $apps_id =~ ^[[:alnum:]]+$ ]]; then
echo -e "${ARROW} ${CYAN}flux_watchtower installed successful, id: ${GREEN}$apps_id${NC}"
else
echo -e "${ARROW} ${CYAN}flux_watchtower installion failed...${NC}"
fi
}
function mongod_db_fix() {
echo -e "${GREEN}Module: MongoDB FiX action${NC}"
echo -e "${YELLOW}================================================================${NC}"
if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the user account.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
CHOICE=$(
whiptail --title "MongoDB FiX action" --menu "Make your choice" 15 65 8 \
"1)" "Soft repair - MongoDB database repair" \
"2)" "Hard repair - MongoDB re-install" 3>&2 2>&1 1>&3
)
case $CHOICE in
"1)")
echo -e ""
echo -e "${ARROW} ${YELLOW}Soft repair starting... ${NC}"
echo -e "${ARROW} ${CYAN}Stopping mongod service ${NC}"
sudo systemctl stop mongod
echo -e "${ARROW} ${CYAN}Fix for corrupted DB ${NC}"
sudo -u mongodb mongod --dbpath /var/lib/mongodb --repair > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Fix for bad privilege ${NC}"
sudo chown -R mongodb:mongodb /var/lib/mongodb > /dev/null 2>&1
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Starting mongod service ${NC}"
sudo systemctl start mongod
if mongod --version > /dev/null 2>&1; then
string_limit_check_mark "MongoDB $(mongod --version | grep 'db version' | sed 's/db version.//') installed................................." "MongoDB ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed................................."
echo -e "${ARROW} ${CYAN}Service status:${SEA} $(sudo systemctl status mongod | grep -w 'Active' | sed -e 's/^[ \t]*//')${NC}"
fi
echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}"
sudo systemctl restart zelcash > /dev/null 2>&1
pm2 restart flux > /dev/null 2>&1
sleep 5
echo -e ""
;;
"2)")
echo -e ""
echo -e "${ARROW} ${YELLOW}Hard repair starting... ${NC}"
echo -e "${ARROW} ${CYAN}Stopping mongod service...${NC}"
sudo systemctl stop mongod
#sudo rm -rf /home/$USER/mongoDB_backup.gz > /dev/null 2>&1
#echo -e "${ARROW} ${CYAN}Backuping Database... ${NC}"
#mongodump --archive=/home/$USER/mongoDB_backup.gz > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Removing MongoDB... ${NC}"
sudo apt-get remove -f mongodb-org* -y > /dev/null 2>&1
sudo apt-get purge --allow-change-held-packages mongodb-org* -y > /dev/null 2>&1
sudo apt autoremove -y > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Removing Database... ${NC}"
sudo rm -r /var/log/mongodb > /dev/null 2>&1
sudo rm -r /var/lib/mongodb > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Installing MongoDB... ${NC}"
avx_check=$(cat /proc/cpuinfo | grep -o avx | head -n1)
os_version=$(lsb_release -rs | tr -d '.')
architecture=$(dpkg --print-architecture)
if [[ $(lsb_release -d) = *Debian* ]]; then
os_name="Debian"
fi
if [[ $(lsb_release -d) = *Ubuntu* ]]; then
os_name="Ubuntu"
fi
#Ubuntu MongoDB 4.4
if [[ "$avx_check" == "" && "$os_name" == "Ubuntu" && "$architecture" == "amd64" && "$os_version" -le "2010" ]] || [[ "$os_name" == "Ubuntu" && "$architecture" == "arm64" && "$os_version" -le "2010" ]]; then
install_mongod="4.4"
fi
#Debian MongoDB 4.4
if [[ "$avx_check" == "" && "$os_name" == "Debian" && "$architecture" == "amd64" && "$os_version" -le "9" ]] || [[ "$os_name" == "Debian" && "$architecture" == "arm64" && "$os_version" -le "9" ]]; then
install_mongod="4.4"
fi
if [[ "$install_mongod" == "4.4" ]]; then
sudo apt update -y > /dev/null 2>&1
sudo apt install -y mongodb-org=4.4.18 mongodb-org-server=4.4.18 mongodb-org-shell=4.4.18 mongodb-org-mongos=4.4.18 mongodb-org-tools=4.4.18 > /dev/null 2>&1 && sleep 2
echo "mongodb-org hold" | sudo dpkg --set-selections > /dev/null 2>&1 && sleep 2
echo "mongodb-org-server hold" | sudo dpkg --set-selections > /dev/null 2>&1
echo "mongodb-org-shell hold" | sudo dpkg --set-selections > /dev/null 2>&1
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections > /dev/null 2>&1
echo "mongodb-org-tools hold" | sudo dpkg --set-selections > /dev/null 2>&1
else
sudo apt update -y > /dev/null 2>&1
DEBIAN_FRONTEND=noninteractive sudo apt-get --yes install mongodb-org > /dev/null 2>&1
fi
sudo mkdir -p /var/log/mongodb > /dev/null 2>&1
sudo mkdir -p /var/lib/mongodb > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Settings privilege... ${NC}"
sudo chown -R mongodb:mongodb /var/log/mongodb > /dev/null 2>&1
sudo chown -R mongodb:mongodb /var/lib/mongodb > /dev/null 2>&1
sudo chown mongodb:mongodb /tmp/mongodb-27017.sock > /dev/null 2>&1
fluxos_clean
#echo -e "${ARROW} ${CYAN}Restoring Database... ${NC}"
#mongorestore --drop --archive=/home/$USER/mongoDB_backup.gz > /dev/null 2>&1
echo -e "${ARROW} ${CYAN}Starting mongod service... ${NC}"
sudo systemctl enable mongod
sudo systemctl start mongod
if mongod --version > /dev/null 2>&1; then
string_limit_check_mark "MongoDB $(mongod --version | grep 'db version' | sed 's/db version.//') installed................................." "MongoDB ${GREEN}$(mongod --version | grep 'db version' | sed 's/db version.//')${CYAN} installed................................."
echo -e "${ARROW} ${CYAN}Service status:${SEA} $(sudo systemctl status mongod | grep -w 'Active' | sed -e 's/^[ \t]*//')${NC}"
else
string_limit_x_mark "MongoDB was not installed................................."
fi
echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}"
sudo systemctl restart zelcash > /dev/null 2>&1
pm2 restart flux > /dev/null 2>&1
sleep 5
echo -e ""
;;
esac
}
function node_reconfiguration() {
reset=""
if [[ -f /home/$USER/install_conf.json ]]; then
import_config_file "silent"
get_ip
if [[ -d /home/$USER/zelflux ]]; then
if [[ "$KDA_A" != "" && "$ZELID" != "" ]]; then
echo -e "${ARROW} ${CYAN}Creating FluxOS config file...${NC}"
sudo rm -rf /home/$USER/zelflux/config/userconfig.js > /dev/null 2>&1
fluxos_conf_create
reset=0
fi
fi
if [[ -d /home/$USER/.flux ]]; then
if [[ "$prvkey" != "" && "$outpoint" != "" && "$index" != "" ]]; then
zelnodeprivkey="$prvkey"
zelnodeoutpoint="$outpoint"
zelnodeindex="$index"
echo -e "${ARROW} ${CYAN}Creating Daemon config file...${NC}"
sudo rm -rf /home/$USER/.flux/flux.conf > /dev/null 2>&1
flux_daemon_conf_create
reset=0
fi
fi
if [[ -d /home/$USER/watchdog ]]; then
echo -e "${ARROW} ${CYAN}Creating Watchdog config file...${NC}"
sudo rm -rf /home/$USER/watchdog/config.js > /dev/null 2>&1
fix_action='1'
watchdog_conf_create
reset=0
fi
if [[ -d /home/$USER/.flux ]]; then
if [[ ! -z "$upnp_port" && ! -z "$gateway_ip" ]]; then
reset=1
upnp_enable
fi
fi
if [[ "$reset" == "0" ]]; then
echo -e "${ARROW} ${CYAN}Restarting FluxOS and Benchmark...${NC}"
sudo systemctl restart zelcash > /dev/null 2>&1
pm2 restart flux > /dev/null 2>&1
sleep 10
fi
else
echo -e "${ARROW} ${CYAN}Install config file not exist, operation aborted...${NC}"
echo -e ""
fi
}
if ! figlet -v > /dev/null 2>&1; then
sudo apt-get update -y > /dev/null 2>&1
sudo apt-get install -y figlet > /dev/null 2>&1
fi
if ! pv -V > /dev/null 2>&1; then
sudo apt-get install -y pv > /dev/null 2>&1
fi
if ! gzip -V > /dev/null 2>&1; then
sudo apt-get install -y gzip > /dev/null 2>&1
fi
if ! zip -v > /dev/null 2>&1; then
sudo apt-get install -y zip > /dev/null 2>&1
fi
if ! whiptail -v > /dev/null 2>&1; then
sudo apt-get install -y whiptail > /dev/null 2>&1
fi
if [[ $(cat /etc/bash.bashrc | grep 'multitoolbox' | wc -l) == "0" ]]; then
echo "alias multitoolbox='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)'" | sudo tee -a /etc/bash.bashrc
echo "alias multitoolbox_testnet='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox_testnet.sh)'" | sudo tee -a /etc/bash.bashrc
alias multitoolbox='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox.sh)'
alias multitoolbox_testnet='bash -i <(curl -s https://raw.githubusercontent.com/RunOnFlux/fluxnode-multitool/master/multitoolbox_testnet.sh)'
source /etc/bash.bashrc
fi
if ! wget --version > /dev/null 2>&1 ; then
sudo apt install -y wget > /dev/null 2>&1 && sleep 2
fi
clear
sleep 1
echo -e "${BLUE}"
figlet -f slant "Multitoolbox"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${GREEN}Version: $dversion${NC}"
echo -e "${GREEN}Branch: $ROOT_BRANCH${NC}"
echo -e "${GREEN}OS: Ubuntu 20/22/23, Debian 10/11/12 (if hardware requirements are met)${NC}"
echo -e "${GREEN}Created by: X4MiLX from Flux's team${NC}"
echo -e "${GREEN}Special thanks to dk808, CryptoWrench, jriggs28 && TechDufus${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${CYAN}1 - Install Docker${NC}"
echo -e "${CYAN}2 - Install FluxNode${NC}"
echo -e "${CYAN}3 - FluxNode analyzer and fixer${NC}"
echo -e "${CYAN}4 - Install watchdog for FluxNode${NC}"
echo -e "${CYAN}5 - Restore Flux blockchain from bootstrap${NC}"
echo -e "${CYAN}6 - Create FluxNode installation config file${NC}"
echo -e "${CYAN}7 - Re-install FluxOS${NC}"
echo -e "${CYAN}8 - Flux Daemon Reconfiguration${NC}"
echo -e "${CYAN}9 - Create Flux daemon service${NC}"
echo -e "${CYAN}10 - Create Self-hosting cron ip service ${NC}"
echo -e "${CYAN}11 - FluxOS config management ${NC}"
echo -e "${CYAN}12 - Install fluxwatchtower for docker images autoupdate${NC}"
echo -e "${CYAN}13 - MongoDB FiX action${NC}"
echo -e "${CYAN}14 - Multinode configuration with UPNP communication (Needs Router with UPNP support)${NC}"
echo -e "${CYAN}15 - Node reconfiguration from install config${NC}"
echo -e "${CYAN}16 - Hardware benchmark${NC}"
echo -e "${YELLOW}================================================================${NC}"
read -rp "Pick an option and hit ENTER: "
case "$REPLY" in
1)
clear
sleep 1
install_docker
;;
2)
clear
sleep 1
install_node
;;
3)
clear
sleep 1
analyzer_and_fixer
;;
4)
clear
sleep 1
install_watchdog
;;
5)
clear
sleep 1
flux_daemon_bootstrap
;;
6)
clear
sleep 1
create_config
;;
7)
clear
sleep 1
install_flux
;;
8)
clear
sleep 1
daemon_reconfiguration
;;
9)
clear
sleep 1
echo -e "${GREEN}Module: Flux Daemon service creator${NC}"
echo -e "${YELLOW}================================================================${NC}"
if [[ "$USER" == "root" || "$USER" == "ubuntu" || "$USER" == "admin" ]]; then
echo -e "${CYAN}You are currently logged in as ${GREEN}$USER${NC}"
echo -e "${CYAN}Please switch to the user account.${NC}"
echo -e "${YELLOW}================================================================${NC}"
echo -e "${NC}"
exit
fi
create_service_scripts
create_service "install"
echo -e ""
;;
10)
clear
sleep 1
selfhosting_creator
;;
11)
clear
sleep 1
fluxos_reconfiguration
echo -e ""
;;
12)
clear
sleep 1
install_watchtower