-
Notifications
You must be signed in to change notification settings - Fork 2
/
diginode.sh
executable file
·6135 lines (5051 loc) · 269 KB
/
diginode.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
#
# Name: DigiNode Dashboard v0.10.3
#
# Purpose: Monitor and manage the status of you DigiByte Node and DigiAsset Node.
#
# Compatibility: Supports x86_86 or arm64 hardware with Ubuntu or Debian 64-bit distros.
# Other distros may not work at present. Please help test so that support can be added.
# A Raspberry Pi 4 8Gb running Raspberry Pi OS Lite 64-bit is recommended.
#
# Author: Olly Stedall [ Bluesky: @olly.st / Twitter: @saltedlolly ]
#
# Website: https://diginode.tools
#
# Support: Telegram - https://t.me/DigiNodeTools
# Bluesky - https://bsky.app/profile/digibyte.help
# X - https://twitter.com/diginodetools
#
# Get Started: curl -sSL setup.diginode.tools | bash
#
# Alternatively clone the repo to your home folder:
#
# cd ~
# git clone https://github.com/DigiNode-Tools/diginode-tools/
# chmod +x ~/diginode-tools/diginode.sh
#
# To run DigiNode Dashboard:
#
# ~/diginode-tools/diginode.sh
#
# -----------------------------------------------------------------------------------------------------
#####################################################
##### IMPORTANT INFORMATION #########################
#####################################################
# Please note that this script requires the diginode-setup.sh script to be with it
# in the same folder when it runs. Tne setup script contains functions and variables
# used by this one.
#
# Both DigiNode Setup and Dashboard scripts make use of a settings file
# located at: ~/.digibyte/diginode.settings
#
# It want to make changes to folder locations etc. please edit this file.
# (e.g. To move your DigiByte data folder to an external drive.)
#
# Note: The default location of the diginode.settings file can be changed at the top of
# the setup script, but this is not recommended.
######################################################
######### VARIABLES ##################################
######################################################
# For better maintainability, we store as much information that can change in variables
# This allows us to make a change in one place that can propagate to all instances of the variable
# These variables should all be GLOBAL variables, written in CAPS
# Local variables will be in lowercase and will exist only within functions
# This variable stores the version number of this release of 'DigiNode Tools'.
# Whenever there is a new release, this number gets updated to match the release number on GitHub.
# The version number should be three numbers seperated by a period
# Do not change this number or the mechanism for installing updates may no longer work.
DGNT_VER_LOCAL=0.10.3
# Last Updated: 2024-06-09
# This is the command people will enter to run the install script.
DGNT_SETUP_OFFICIAL_CMD="curl -sSL setup.diginode.tools | bash"
########################################################
#### UPDATE THESE VALUES FROM DIGINODE SETUP FIRST #####
########################################################
# These colour and text formatting variables are included in both scripts since they are required before diginode-setup.sh is sourced into this one.
# Changes to these variables should be first made in the setup script and then copied here, to help ensure the settings remain identical in both scripts.
# Set these values so we can still run in color
COL_NC='\e[0m' # No Color
COL_LIGHT_GREEN='\e[1;32m'
COL_LIGHT_RED='\e[1;31m'
COL_LIGHT_CYAN='\e[1;96m'
COL_BOLD_WHITE='\e[1;37m'
COL_LIGHT_YEL='\e[1;33m'
TICK=" [${COL_LIGHT_GREEN}✓${COL_NC}]"
CROSS=" [${COL_LIGHT_RED}✗${COL_NC}]"
WARN=" [${COL_LIGHT_RED}!${COL_NC}]"
INFO=" [${COL_BOLD_WHITE}i${COL_NC}]"
SKIP=" [${COL_BOLD_WHITE}-${COL_NC}]"
INDENT=" "
# shellcheck disable=SC2034
DONE="${COL_LIGHT_GREEN} done!${COL_NC}"
OVER="\\r\\033[K"
## Set ANSI code variables for colors and formatting
txtred=$(tput setaf 1) # Red
txtgrn=$(tput setaf 2) # Green
txtylw=$(tput setaf 3) # Yellow
txtblu=$(tput setaf 4) # Blue
txtpur=$(tput setaf 5) # Purple
txtcyn=$(tput setaf 6) # Cyan
txtwht=$(tput setaf 7) # White
txtbred=$(tput setaf 9) # Bright Red
txtbgrn=$(tput setaf 10) # Bright Green
txtbylw=$(tput setaf 11) # Bright Yellow
txtbblu=$(tput setaf 12) # Bright Blue
txtbpur=$(tput setaf 13) # Bright Purple
txtbcyn=$(tput setaf 14) # Bright Cyan
txtbwht=$(tput setaf 15) # Bright White
txtrst=$(tput sgr0) # Text reset.
# tput setab [1-7] : Set a background colour using ANSI escape
# tput setb [1-7] : Set a background colour
# tput setaf [1-7] : Set a foreground colour using ANSI escape
# tput setf [1-7] : Set a foreground colour
txtbld=$(tput bold) # Set bold mode
# tput dim : turn on half-bright mode
# tput smul : begin underline mode
# tput rmul : exit underline mode
# tput rev : Turn on reverse mode
# tput smso : Enter standout mode (bold on rxvt)
# tput rmso : Exit standout mode
# Dashboard colors
dbcol_bwht="\e[97m" # Bright White
dbcol_bred="\e[91m" # Bright Red
dbcol_bylw="\e[93m" # Bright Yellow
dbcol_bgrn="\e[92m" # Bright Green
dbcol_bblu="\e[94m" # Bright Blue
#########
dbcol_bld="\e[1m" # Bold Text
dbcol_rst="\e[0m" # Text Reset
#########
dbcol_bld_bwht="\e[1;37m" # Bold Bright White Text
######## Undocumented Flags. Shhh ########
# These are undocumented flags;
VERBOSE_MODE=false # Set this to true to get more verbose feedback. Very useful for debugging.
UNINSTALL=false
LOCATE_DIGIBYTE=false
DISPLAY_HELP=false
EDIT_DGBCONF=false
EDIT_DGNTSET=false
VIEW_DGBLOG=false
VIEW_DGB2LOG=false
VIEW_DGBLOGMN=false
VIEW_DGBLOGTN=false
VIEW_DGBLOGRT=false
VIEW_DGBLOGSN=false
DGBCORE_RESTART=false
DGBCORE_STOP=false
DGB2CORE_RESTART=false
DGB2CORE_STOP=false
DGBPEERS=false
DGB2PEERS=false
VIEW_RPC_CREDENTIALS=false
UNKNOWN_FLAG=false
REENABLE_PORT_TEST=false
# Check arguments for the undocumented flags
# --dgndev (-d) will use and install the develop branch of DigiNode Tools (used during development)
for var in "$@"; do
case "$var" in
"--uninstall" ) UNINSTALL=true;;
"--verbose" ) VERBOSE_MODE=true;;
"--verboseoff" ) VERBOSE_MODE=false;;
"--locatedgb" ) LOCATE_DIGIBYTE=true;;
"--help" ) DISPLAY_HELP=true;;
"-h" ) DISPLAY_HELP=true;;
"--dgbconf" ) EDIT_DGBCONF=true;;
"--settings" ) EDIT_DGNTSET=true;;
"--dgblog" ) VIEW_DGBLOG=true;;
"--dgb2log" ) VIEW_DGB2LOG=true;;
"--dgblogmn" ) VIEW_DGBLOGMN=true;;
"--dgblogtn" ) VIEW_DGBLOGTN=true;;
"--dgblogrt" ) VIEW_DGBLOGRT=true;;
"--dgblogsn" ) VIEW_DGBLOGSN=true;;
"--dgbrestart" ) DGBCORE_RESTART=true;;
"--dgbstop" ) DGBCORE_STOP=true;;
"--dgb2restart" ) DGB2CORE_RESTART=true;;
"--dgb2stop" ) DGB2CORE_STOP=true;;
"--dgbpeers" ) DGBPEERS=true;;
"--dgb2peers" ) DGB2PEERS=true;;
"--rpc" ) VIEW_RPC_CREDENTIALS=true;;
"--porttest" ) REENABLE_PORT_TEST=true;;
# If an unknown flag is used...
*) UNKNOWN_FLAG=true;;
esac
done
######################################################
######### FUNCTIONS ##################################
######################################################
# Run a command via a launch flag
flag_commands() {
if [ $UNKNOWN_FLAG = true ] || \
[ $EDIT_DGBCONF = true ] || \
[ $EDIT_DGNTSET = true ] || \
[ $VIEW_DGBLOG = true ] || \
[ $VIEW_DGB2LOG = true ] || \
[ $VIEW_DGBLOGMN = true ] || \
[ $VIEW_DGBLOGTN = true ] || \
[ $VIEW_DGBLOGRT = true ] || \
[ $VIEW_DGBLOGSN = true ] || \
[ $DGBCORE_RESTART = true ] || \
[ $DGBCORE_STOP = true ] || \
[ $DGB2CORE_RESTART = true ] || \
[ $DGB2CORE_STOP = true ] || \
[ $DGB2CORE_STOP = true ] || \
[ $DGBPEERS = true ] || \
[ $DGB2PEERS = true ] || \
[ $VIEW_RPC_CREDENTIALS = true ] || \
[ $REENABLE_PORT_TEST = true ]; then
printf "\\n"
get_script_location # Find which folder this script is running in (in case this is an unnoficial DigiNode)
import_setup_functions # Import diginode-setup.sh file because it contains functions we need
# If this is an unknown flag, warn and quit
if [ $UNKNOWN_FLAG = true ]; then #
printf "%b ERROR: Unrecognised flag used: $var\\n" "${WARN}"
printf "\\n"
printf "%b For help, enter:\\n" "${INDENT}"
printf "\\n"
printf "%b$ %bdiginode --help%b\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "\\n"
exit
fi
# Work out which DigiByte log file to display based on which chain is in use
if [ $VIEW_DGBLOG = true ]; then # --dgblog
diginode_tools_import_settings silent
query_digibyte_chain
if [ "$DGB_NETWORK_CURRENT" = "TESTNET" ]; then
VIEW_DGBLOGTN=true
elif [ "$DGB_NETWORK_CURRENT" = "REGTEST" ]; then
VIEW_DGBLOGRT=true
elif [ "$DGB_NETWORK_CURRENT" = "SIGNET" ]; then
VIEW_DGBLOGSN=true
elif [ "$DGB_NETWORK_CURRENT" = "MAINNET" ]; then
VIEW_DGBLOGMN=true
fi
fi
if [ $EDIT_DGBCONF = true ]; then # --dgbconf
diginode_tools_import_settings silent
set_text_editor
if test -f $DGB_CONF_FILE; then
exec $TEXTEDITOR $DGB_CONF_FILE
else
printf "%bError: digibyte.conf file does not exist\\n\\n" "${INDENT}"
exit 1
fi
elif [ $EDIT_DGNTSET = true ]; then # --settings
diginode_tools_import_settings silent
set_text_editor
if test -f $DGNT_SETTINGS_FILE ; then
exec $TEXTEDITOR $DGNT_SETTINGS_FILE
else
printf "%bError: diginode.settings file does not exist\\n\\n" "${INDENT}"
fi
elif [ $VIEW_DGBLOGMN = true ]; then # --dgblogmn
if [ "$DGB_SETTINGS_LOCATION" = "" ]; then
diginode_tools_import_settings silent
fi
if test -f $DGB_SETTINGS_LOCATION/debug.log ; then
echo " ====================================="
echo " DigiByte Core MAINNET debug.log"
echo " ====================================="
echo ""
echo " Displaying the last 50 lines from mainnet log file. Press Ctrl-C to Stop."
echo ""
exec tail -n50 -f $DGB_SETTINGS_LOCATION/debug.log
else
printf "%bError: DigiByte Core MAINNET log file does not exist\\n\\n" "${INDENT}"
exit 1
fi
elif [ $VIEW_DGBLOGTN = true ] || [ $VIEW_DGB2LOG = true ]; then # --dgblogtn
if [ "$DGB_SETTINGS_LOCATION" = "" ]; then
diginode_tools_import_settings silent
fi
if test -f $DGB_SETTINGS_LOCATION/testnet4/debug.log ; then
echo " ====================================="
echo " DigiByte Core TESTNET debug.log"
echo " ====================================="
echo ""
echo " Displaying the last 50 lines from testnet log file. Press Ctrl-C to Stop."
echo ""
exec tail -n50 -f $DGB_SETTINGS_LOCATION/testnet4/debug.log
else
printf "%bError: DigiByte Core TESTNET log file does not exist\\n\\n" "${INDENT}"
exit 1
fi
elif [ $VIEW_DGBLOGRT = true ]; then # --dgblogrt
if [ "$DGB_SETTINGS_LOCATION" = "" ]; then
diginode_tools_import_settings silent
fi
if test -f $DGB_SETTINGS_LOCATION/regtest/debug.log ; then
echo " ====================================="
echo " DigiByte Core REGTEST debug.log"
echo " ====================================="
echo ""
echo " Displaying the last 50 lines from regtest log file. Press Ctrl-C to Stop."
echo ""
exec tail -n50 -f $DGB_SETTINGS_LOCATION/regtest/debug.log
else
printf "%bError: DigiByte Core REGTEST log file does not exist\\n\\n" "${INDENT}"
exit 1
fi
elif [ $VIEW_DGBLOGSN = true ]; then # --dgblogrt
if [ "$DGB_SETTINGS_LOCATION" = "" ]; then
diginode_tools_import_settings silent
fi
if test -f $DGB_SETTINGS_LOCATION/signet/debug.log ; then
echo " ====================================="
echo " DigiByte Core SIGNET debug.log"
echo " ====================================="
echo ""
echo " Displaying the last 50 lines from signet log file. Press Ctrl-C to Stop."
echo ""
exec tail -n50 -f $DGB_SETTINGS_LOCATION/signet/debug.log
else
printf "%bError: DigiByte Core SIGNET log file does not exist\\n\\n" "${INDENT}"
exit 1
fi
elif [ $DGBCORE_RESTART = true ]; then # --dgbrestart
local str="Restarting digibyted service"
printf "%b %s..." "${INFO}" "${str}"
# If systemctl exists,
if $(command -v systemctl >/dev/null 2>&1); then
sudo systemctl restart digibyted &> /dev/null
else
# Otherwise, fall back to the service command
sudo service digibyted restart &> /dev/null
fi
printf "%b%b %s...\\n\\n" "${OVER}" "${TICK}" "${str}"
exit
elif [ $DGBCORE_STOP = true ]; then # --stopdgb
local str="Stopping digibyted service"
printf "%b %s..." "${INFO}" "${str}"
# If systemctl exists,
if $(command -v systemctl >/dev/null 2>&1); then
sudo systemctl stop digibyted &> /dev/null
else
# Otherwise, fall back to the service command
sudo service digibyted stop &> /dev/null
fi
printf "%b%b %s...\\n\\n" "${OVER}" "${TICK}" "${str}"
exit
elif [ $DGB2CORE_RESTART = true ]; then # --dgbrestart
diginode_tools_import_settings silent
if [ "$DGB_DUAL_NODE" = "YES" ]; then
local str="Restarting digibyted-testnet service"
printf "%b %s..." "${INFO}" "${str}"
# If systemctl exists,
if $(command -v systemctl >/dev/null 2>&1); then
sudo systemctl restart digibyted-testnet &> /dev/null
else
# Otherwise, fall back to the service command
sudo service digibyted-testnet restart &> /dev/null
fi
printf "%b%b %s...\\n\\n" "${OVER}" "${TICK}" "${str}"
else
printf "%bError: DigiByte Dual Node not installed.\\n\\n" "${INDENT}"
fi
exit
elif [ $DGB2CORE_STOP = true ]; then # --stopdgb
diginode_tools_import_settings silent
if [ "$DGB_DUAL_NODE" = "YES" ]; then
local str="Stopping digibyted-testnet service"
printf "%b %s..." "${INFO}" "${str}"
# If systemctl exists,
if $(command -v systemctl >/dev/null 2>&1); then
sudo systemctl stop digibyted-testnet &> /dev/null
else
# Otherwise, fall back to the service command
sudo service digibyted-testnet stop &> /dev/null
fi
printf "%b%b %s...\\n\\n" "${OVER}" "${TICK}" "${str}"
else
printf "%bError: DigiByte Dual Node not installed.\\n\\n" "${INDENT}"
fi
exit
elif [ $DGBPEERS = true ]; then # --dgbpeers
diginode_tools_import_settings silent
query_digibyte_chain
if check_service_active "digibyted"; then
printf "DigiByte $DGB_NETWORK_CURRENT Peers:\\n\\n"
printf "IP4 Peers:\\n"
ip4peers=$(digibyte-cli getpeerinfo | jq -r '.[] | {ip: .addr} | select(.ip | test("^[0-9]") and (test("\\.onion$") | not)) | .ip' | sort)
if [ -z "$ip4peers" ]; then
echo "none"
else
echo "$ip4peers"
fi
printf "\\n"
printf "IP6 Peers:\\n"
ip6peers=$(digibyte-cli getpeerinfo | jq -r '.[] | {ip: .addr, port: .port} | "\(.ip):\(.port)"' | sed 's/:null$//' | grep --color=never -E '^\[' | sort)
if [ -z "$ip6peers" ]; then
echo "none"
else
echo "$ip6peers"
fi
printf "\\n"
printf "Onion Peers:\\n"
onionpeers=$(digibyte-cli getpeerinfo | jq -r '.[] | {ip: .addr, port: .port} | "\(.ip):\(.port)"' | sed 's/:null$//' | grep '\.onion$' | sort)
if [ -z "$onionpeers" ]; then
echo "none"
else
echo "$onionpeers"
fi
printf "\\n"
exit
else
printf "%b %bERROR: DigiByte $DGB_NETWORK_CURRENT Node is not running.%b\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "\\n"
exit 1
fi
elif [ $DGB2PEERS = true ]; then # --dgb2peers
if check_service_active "digibyted-testnet"; then
printf "DigiByte TESTNET Node Peers:\\n\\n"
printf "IP4 Peers:\\n"
ip4peers=$(digibyte-cli getpeerinfo | jq -r '.[] | {ip: .addr} | select(.ip | test("^[0-9]") and (test("\\.onion$") | not)) | .ip' | sort)
if [ -z "$ip4peers" ]; then
echo "none"
else
echo "$ip4peers"
fi
printf "\\n"
printf "IP6 Peers:\\n"
ip6peers=$(digibyte-cli -testnet getpeerinfo | jq -r '.[] | {ip: .addr, port: .port} | "\(.ip):\(.port)"' | sed 's/:null$//' | grep --color=never -E '^\[' | sort)
if [ -z "$ip6peers" ]; then
echo "none"
else
echo "$ip6peers"
fi
printf "\\n"
printf "Onion Peers:\\n"
onionpeers=$(digibyte-cli -testnet getpeerinfo | jq -r '.[] | {ip: .addr, port: .port} | "\(.ip):\(.port)"' | sed 's/:null$//' | grep '\.onion$' | sort)
if [ -z "$onionpeers" ]; then
echo "none"
else
echo "$onionpeers"
fi
printf "\\n"
exit
else
printf "%b %bERROR: DigiByte TESTNET Node is not running.%b\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "\\n"
exit 1
fi
elif [ $VIEW_RPC_CREDENTIALS = true ]; then # --rpc
diginode_tools_import_settings silent
scrape_digibyte_conf
query_digibyte_chain
query_digibyte_rpc
printf "DigiByte Core RPC Credentials:\\n\\n"
printf " RPC User: $RPC_USER\\n\\n"
printf " RPC Password: $RPC_PASSWORD\\n\\n"
if [ "$DGB_DUAL_NODE" = "YES" ]; then
printf " RPC Ports: $RPC_PORT (%s) $RPC2_PORT (Testnet)\\n\\n" "$(echo "${DGB_NETWORK_CURRENT,,}" | sed 's/./\U&/1')"
else
printf " RPC Ports: $RPC_PORT (%s)\\n\\n" "$(echo "${DGB_NETWORK_CURRENT,,}" | sed 's/./\U&/1')"
fi
exit
elif [ $REENABLE_PORT_TEST = true ]; then # --porttest
diginode_tools_import_settings silent
printf "%b Re-enabling DigiByte Core MAINNET Port Test...\n" "${INFO}"
DGB_MAINNET_PORT_TEST_ENABLED="YES"
sed -i -e "/^DGB_MAINNET_PORT_TEST_ENABLED=/s|.*|DGB_MAINNET_PORT_TEST_ENABLED=\"$DGB_MAINNET_PORT_TEST_ENABLED\"|" $DGNT_SETTINGS_FILE
DGB_MAINNET_PORT_FWD_STATUS=""
sed -i -e "/^DGB_MAINNET_PORT_FWD_STATUS=/s|.*|DGB_MAINNET_PORT_FWD_STATUS=\"$DGB_MAINNET_PORT_FWD_STATUS\"|" $DGNT_SETTINGS_FILE
DGB_MAINNET_PORT_TEST_PASS_DATE=""
sed -i -e "/^DGB_MAINNET_PORT_TEST_PASS_DATE=/s|.*|DGB_MAINNET_PORT_TEST_PASS_DATE=\"$DGB_MAINNET_PORT_TEST_PASS_DATE\"|" $DGNT_SETTINGS_FILE
DGB_MAINNET_PORT_TEST_EXTERNAL_IP=""
sed -i -e "/^DGB_MAINNET_PORT_TEST_EXTERNAL_IP=/s|.*|DGB_MAINNET_PORT_TEST_EXTERNAL_IP=\"$DGB_MAINNET_PORT_TEST_EXTERNAL_IP\"|" $DGNT_SETTINGS_FILE
DGB_MAINNET_PORT_NUMBER_SAVED=""
sed -i -e "/^DGB_MAINNET_PORT_NUMBER_SAVED=/s|.*|DGB_MAINNET_PORT_NUMBER_SAVED=\"$DGB_MAINNET_PORT_NUMBER_SAVED\"|" $DGNT_SETTINGS_FILE
printf "%b Re-enabling DigiByte Core TESTNET Port Test...\n" "${INFO}"
DGB_TESTNET_PORT_TEST_ENABLED="YES"
sed -i -e "/^DGB_TESTNET_PORT_TEST_ENABLED=/s|.*|DGB_TESTNET_PORT_TEST_ENABLED=\"$DGB_TESTNET_PORT_TEST_ENABLED\"|" $DGNT_SETTINGS_FILE
DGB_TESTNET_PORT_FWD_STATUS=""
sed -i -e "/^DGB_TESTNET_PORT_FWD_STATUS=/s|.*|DGB_TESTNET_PORT_FWD_STATUS=\"$DGB_TESTNET_PORT_FWD_STATUS\"|" $DGNT_SETTINGS_FILE
DGB_TESTNET_PORT_TEST_PASS_DATE=""
sed -i -e "/^DGB_TESTNET_PORT_TEST_PASS_DATE=/s|.*|DGB_TESTNET_PORT_TEST_PASS_DATE=\"$DGB_TESTNET_PORT_TEST_PASS_DATE\"|" $DGNT_SETTINGS_FILE
DGB_TESTNET_PORT_TEST_EXTERNAL_IP=""
sed -i -e "/^DGB_TESTNET_PORT_TEST_EXTERNAL_IP=/s|.*|DGB_TESTNET_PORT_TEST_EXTERNAL_IP=\"$DGB_TESTNET_PORT_TEST_EXTERNAL_IP\"|" $DGNT_SETTINGS_FILE
DGB_TESTNET_PORT_NUMBER_SAVED=""
sed -i -e "/^DGB_TESTNET_PORT_NUMBER_SAVED=/s|.*|DGB_TESTNET_PORT_NUMBER_SAVED=\"$DGB_TESTNET_PORT_NUMBER_SAVED\"|" $DGNT_SETTINGS_FILE
printf "%b Re-enabling IPFS Port Test...\n" "${INFO}"
IPFS_PORT_TEST_ENABLED="YES"
sed -i -e "/^IPFS_PORT_TEST_ENABLED=/s|.*|IPFS_PORT_TEST_ENABLED=\"$IPFS_PORT_TEST_ENABLED\"|" $DGNT_SETTINGS_FILE
IPFS_PORT_FWD_STATUS=""
sed -i -e "/^IPFS_PORT_FWD_STATUS=/s|.*|IPFS_PORT_FWD_STATUS=\"$IPFS_PORT_FWD_STATUS\"|" $DGNT_SETTINGS_FILE
IPFS_PORT_TEST_PASS_DATE=""
sed -i -e "/^IPFS_PORT_TEST_PASS_DATE=/s|.*|IPFS_PORT_TEST_PASS_DATE=\"$IPFS_PORT_TEST_PASS_DATE\"|" $DGNT_SETTINGS_FILE
IPFS_PORT_TEST_EXTERNAL_IP=""
sed -i -e "/^IPFS_PORT_TEST_EXTERNAL_IP=/s|.*|IPFS_PORT_TEST_EXTERNAL_IP=\"$IPFS_PORT_TEST_EXTERNAL_IP\"|" $DGNT_SETTINGS_FILE
IPFS_PORT_NUMBER_SAVED=""
sed -i -e "/^IPFS_PORT_NUMBER_SAVED=/s|.*|IPFS_PORT_NUMBER_SAVED=\"$IPFS_PORT_NUMBER_SAVED\"|" $DGNT_SETTINGS_FILE
sleep 2
fi
fi
}
# Display DigiNode Setup help screen if the --help or -h flags was used
display_help() {
if [ "$DISPLAY_HELP" = true ]; then
echo ""
get_script_location # Find which folder this script is running in (in case this is an unnoficial DigiNode)
import_setup_functions # Import diginode-setup.sh file because it contains functions we need
diginode_tools_import_settings silent
query_digibyte_chain
# Is Dual Node detected?
if [ -f "$DGB2_SYSTEMD_SERVICE_FILE" ] || [ -f "$DGB2_UPSTART_SERVICE_FILE" ]; then
DGB_DUAL_NODE="YES"
else
DGB_DUAL_NODE="NO"
fi
echo ""
echo " ╔════════════════════════════════════════════════════════╗"
echo " ║ ║"
echo " ║ ${txtbld}D I G I N O D E C L I${txtrst} ║ "
echo " ║ ║"
echo " ║ Manage your DigiNode from the Command Line ║"
echo " ║ ║"
echo " ╚════════════════════════════════════════════════════════╝"
echo ""
printf "%b%b--help%b or %b-h%b - Display this help screen.\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--verbose%b - Enable verbose mode in DigiNode Dashboard.\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "\\n"
if [ "$DGB_DUAL_NODE" = "YES" ]; then
printf "%b%b--dgbrestart%b - Restart primary DigiByte Node ($DGB_NETWORK_CURRENT).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--dgbstop%b - Stop primary DigiByte Node ($DGB_NETWORK_CURRENT).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--dgbpeers%b - List peers for primary DigiByte Node ($DGB_NETWORK_CURRENT).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
else
printf "%b%b--dgbrestart%b - Restart DigiByte Node ($DGB_NETWORK_CURRENT).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--dgbstop%b - Stop DigiByte Node ($DGB_NETWORK_CURRENT).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--dgbpeers%b - List peers for DigiByte Node ($DGB_NETWORK_CURRENT).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
fi
if [ "$DGB_DUAL_NODE" = "YES" ]; then
printf "%b%b--dgb2restart%b - Restart secondary DigiByte Node (TESTNET).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--dgb2stop%b - Stop secondary DigiByte Node (TESTNET).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--dgb2peers%b - List peers for secondary DigiByte Node (TESTNET).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
fi
printf "\\n"
printf "%b%b--dgbconf%b - Edit digibyte.conf file.\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--settings%b - Edit diginode.settings file.\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--rpc%b - View DigiByte Core RPC credentials.\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "%b%b--porttest%b - Re-enable the port tests.\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "\\n"
if [ "$DGB_DUAL_NODE" = "YES" ]; then
printf "%b%b--dgblog%b - View log file for primary DigiByte Node ($DGB_NETWORK_CURRENT).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
else
printf "%b%b--dgblog%b - View log file for DigiByte Node ($DGB_NETWORK_CURRENT).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
fi
if [ "$DGB_DUAL_NODE" = "YES" ]; then
printf "%b%b--dgb2log%b - View log file for secondary DigiByte Node (TESTNET).\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
fi
printf "%b (Note: You can also view each log file using: --dgblogmn (Mainnet),\\n" "${INDENT}"
printf "%b --dgblogtn (Testnet), --dgblogrt (Regtest) & --dgblogsn (Signet).)\\n" "${INDENT}"
printf "\\n"
printf " Usage: %bdiginode --flag%b (Replace --flag with the desired flag.)\\n" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "\\n"
exit
fi
}
# Find where this script is running from, so we can make sure the diginode-setup.sh script is with it
get_script_location() {
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
DGNT_LOCATION_NOW="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
DGNT_SETUP_SCRIPT_NOW=$DGNT_LOCATION_NOW/diginode-setup.sh
if [ "$VERBOSE_MODE" = true ]; then
printf "%b Monitor Script Location: $DGNT_LOCATION_NOW\\n" "${INFO}"
printf "%b Setup Script Location (presumed): $DGNT_SETUP_SCRIPT_NOW\\n" "${INFO}"
fi
}
# PULL IN THE CONTENTS OF THE SETUP SCRIPT BECAUSE IT HAS FUNCTIONS WE WANT TO USE
import_setup_functions() {
# BEFORE INPORTING THE FUNCTIONS FROM diginode-setup.sh, SET VARIABLE SO IT DOESN'T ACTUAL RUN THE SETUP SCRIPT
RUN_SETUP="NO"
# If the setup file exists,
if [[ -f "$DGNT_SETUP_SCRIPT_NOW" ]]; then
# source it
if [ $VERBOSE_MODE = true ]; then
printf "%b Importing functions from diginode-setup.sh\\n" "${TICK}"
printf "\\n"
fi
source "$DGNT_SETUP_SCRIPT_NOW"
# Set run location to local (this script cannot be run remotely). This variable is used when checking if the diginode.settings file needs updating.
DGNT_RUN_LOCATION="local"
# Otherwise,
else
printf "\\n"
printf "%b %bERROR: diginode-setup.sh file not found.%b\\n" "${WARN}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "\\n"
printf "%b The diginode-setup.sh file is required to continue.\\n" "${INDENT}"
printf "%b It contains functions we need to run the DigiNode Dashboard.\\n" "${INDENT}"
printf "\\n"
printf "%b If you have not already setup your DigiNode, please use\\n" "${INDENT}"
printf "%b the official DigiNode Setup script:\\n" "${INDENT}"
printf "\\n"
printf "%b $DGNT_SETUP_OFFICIAL_CMD\\n" "${INDENT}"
printf "\\n"
printf "%b Alternatively, to use 'DigiNode Dashboard' with your existing\\n" "${INDENT}"
printf "%b DigiByte node, clone the official repo to your home folder:\\n" "${INDENT}"
printf "\\n"
printf "%b cd ~ \\n" "${INDENT}"
printf "%b git clone https://github.com/DigiNode-Tools/diginode-tools/ \\n" "${INDENT}"
printf "%b chmod +x ~/diginode-tools/diginode.sh \\n" "${INDENT}"
printf "\\n"
printf "%b To run it:\\n" "${INDENT}"
printf "\\n"
printf "%b ~/diginode-tools/diginode.sh\\n" "${INDENT}"
printf "\\n"
exit 1
fi
}
# A simple function that clears the sreen and displays the Dashboard title in a box
digimon_title_box() {
clear -x
tput civis
tput smcup
echo ""
echo " ╔════════════════════════════════════════════════════════╗"
echo " ║ ║"
echo " ║ ${txtbld}D I G I N O D E D A S H B O A R D${txtrst} ║ "
echo " ║ ║"
echo " ║ Monitor your DigiByte & DigiAsset Node ║"
echo " ║ ║"
echo " ╚════════════════════════════════════════════════════════╝"
echo ""
}
# Show a disclaimer text during testing phase
digimon_disclaimer() {
printf "%b %bWARNING: This script is currently in public beta.%b\\n" "${WARN}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "%b Please join the Telegram support group to report any bugs and share feedback.\\n" "${INDENT}"
printf "\\n"
read -n 1 -s -r -p " < Press Ctrl-C to quit, or any other key to Continue. >"
printf "\\n\\n"
}
# This script will prompt the user to locate DigiByte core, or install it
locate_digibyte_node() {
printf "\\n"
printf "%b Please choose from the options below:\\n" "${INDENT}"
printf "\\n"
printf "%b 1. ${txtbld}Locate your existing DigiByte Node${txtrst}\\n" "${INDENT}"
printf "%b This will prompt you for the absolute path of your existing DigiByte Core\\n" "${INDENT}"
printf "%b installation folder.\\n" "${INDENT}"
printf "\\n"
printf "%b 2. ${txtbld}Setup a NEW DigiByte Node${txtrst}\\n" "${INDENT}"
printf "%b If you don't already have a DigiByte Node installed, this will launch\\n" "${INDENT}"
printf "%b DigiNode Setup so you can install one.\\n" "${INDENT}"
printf "\\n"
printf "%b 3. ${txtbld}Skip locating an existing DigiByte Node${txtrst}\\n" "${INDENT}"
printf "%b If there is an existing DigiByte Node installed on this system,\\n" "${INDENT}"
printf "%b it will not be monitored.\\n" "${INDENT}"
printf "\\n"
printf "%b 4. ${txtbld}EXIT${txtrst}\\n" "${INDENT}"
printf "%b Exit DigiNode Dashboard.\\n" "${INDENT}"
printf "\\n"
read -n 1 -r -s -p " Please choose option 1, 2, 3 or 4: "
printf "\\n"
if [[ $REPLY =~ ^[3]$ ]]; then
printf "\\n"
printf "%b Skip locating DigiByte Core install folder...\\n" "${INFO}"
echo ""
is_dgb_installed="no"
DGB_STATUS="not_detected"
SKIP_DETECTING_DIGIBYTE="YES"
elif [[ $REPLY =~ ^[2]$ ]]; then
printf "\\n"
printf "%b Running DigiNode Setup...\\n" "${INFO}"
echo ""
if [ "$DGNT_RUN_LOCATION" = "remote" ]; then
exec curl -sSL setup.diginode.tools | bash -s -- --fulldiginode
elif [ "$DGNT_RUN_LOCATION" = "local" ]; then
~/diginode-tools/diginode-setup.sh --fulldiginode
fi
exit
elif [[ $REPLY =~ ^[1]$ ]]; then
printf "\\n"
printf "%b Prompting for absoute path of digibyte core install folder...\\n" "${INFO}"
DGB_CORE_PATH=$(whiptail --inputbox "Please enter the absolute path of your DigiByte Core install folder.\\n\\nExample: /usr/bin/digibyted" 10 78 --title "Enter the absolute path of your DigiByte Node." 3>&1 1>&2 2>&3)
# A trick to swap stdout and stderr.
# Again, you can pack this inside if, but it seems really long for some 80-col terminal users.
exitstatus=$?
if [ $exitstatus == 0 ]; then
printf "%b You entered the following path: $DGB_CORE_PATH\\n" "${INFO}"
# Delete old ~/digibyte symbolic link
if [ -h "$USER_HOME/digibyte" ]; then
str="Deleting old 'digibyte' symbolic link from home folder..."
printf "%b %s" "${INFO}" "${str}"
rm $USER_HOME/digibyte
printf "%b%b %s Done!\\n" "${OVER}" "${TICK}" "${str}"
fi
# Create new symbolic link
str="Creating new ~/digibyte symbolic link pointing at $DGB_CORE_PATH ..."
printf "%b %s" "${INFO}" "${str}"
ln -s $DGB_CORE_PATH $USER_HOME/digibyte
printf "%b%b %s Done!\\n" "${OVER}" "${TICK}" "${str}"
printf "\\n"
printf "%b Run DigiNode again to check your new symbolic link...\\n" "${INFO}"
printf "\\n"
exit
else
printf "%b %bYou cancelled entering the path to your DigiByte Core install folder.%b\\n" "${INDENT}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "\\n"
printf "%b Tip: If you already have an existing DigiByte Node installed on this system, and\\n" "${INFO}"
printf "%b would rather locate it manually, you can create a 'digibyte' symbolic link in your\\n" "${INDENT}"
printf "%b home folder that points to the location of your existing DigiByte install folder:\\n" "${INDENT}"
printf "\\n"
printf "%b For example: ${txtbld}ln -s /usr/bin/digibyted ~/digibyte${txtrst}\\n" "${INDENT}"
printf "\\n"
exit
fi
else
printf "\\n"
printf "%b Tip: If you already have an existing DigiByte Node installed on this system, and\\n" "${INFO}"
printf "%b would rather locate it manually, you can create a 'digibyte' symbolic link in your\\n" "${INDENT}"
printf "%b home folder that points to the location of your existing DigiByte install folder:\\n" "${INDENT}"
printf "\\n"
printf "%b For example: ${txtbld}ln -s /usr/bin/digibyted ~/digibyte${txtrst}\\n" "${INDENT}"
printf "\\n"
exit
fi
printf "\\n"
}
# Check if this DigiNode was setup using the official install script
# (Looks for a hidden file in the 'digibyte' install directory - .officialdiginode)
digibyte_check_official() {
printf " =============== Checking: DigiByte Node ===============================\\n\\n"
# ==============================================================================
if [ -f "$DGB_INSTALL_LOCATION/.officialdiginode" ]; then
printf "%b Checking for Official DigiNode Install of DigiByte Core: %bDETECTED%b\\n" "${TICK}" "${COL_LIGHT_GREEN}" "${COL_NC}"
printf "\\n"
is_dgb_installed="yes"
else
printf "%b Checking for Official DigiNode Install of DigiByte Core: %bNOT DETECTED%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "\\n"
printf "%b This script will attempt to detect your setup but may require you to make\\n" "${INDENT}"
printf "%b manual changes to make it work. It is possible things may break.\\n" "${INDENT}"
printf "%b For best results use DigiNode Tools to setup your DigiNode.\\n" "${INDENT}"
printf "\\n"
is_dgb_installed="maybe"
fi
}
# Run checks to be sure that digibyte node is installed and running
is_dgbnode_installed() {
# Set local variables for DigiByte Core checks
local find_dgb_folder
local find_dgb_binaries
local find_dgb_data_folder
local find_dgb_conf_file
local find_dgb_service
# Begin check to see that DigiByte Core is installed
printf "%b Looking for DigiByte Core...\\n" "${INFO}"
printf "\\n"
# Check for digibyte core install folder in home folder (either 'digibyte' folder itself, or a symbolic link pointing to it)
if [ -h "$DGB_INSTALL_LOCATION" ]; then
find_dgb_folder="yes"
is_dgb_installed="maybe"
if [ $VERBOSE_MODE = true ]; then
printf "%b digibyte symbolic link found in home folder.\\n" "${TICK}"
fi
else
if [ -e "$DGB_INSTALL_LOCATION" ]; then
find_dgb_folder="yes"
is_dgb_installed="maybe"
if [ $VERBOSE_MODE = true ]; then
printf "%b digibyte folder found in home folder.\\n" "${TICK}"
fi
else
printf "\\n"
printf "%b %bERROR: Unable to detect DigiByte Node install folder%b\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "%b This script is unable to detect your DigiByte Core installation folder\\n" "${INDENT}"
if [ "$LOCATE_DIGIBYTE" = true ]; then
is_dgb_installed="no"
locate_digibyte_node
else
printf "\\n"
is_dgb_installed="no"
fi
fi
fi
# Check if digibyted is installed
if [ -f "$DGB_DAEMON" -a -f "$DGB_CLI" ]; then
find_dgb_binaries="yes"
is_dgb_installed="yes"
if [ $VERBOSE_MODE = true ]; then
printf "%b Digibyte Core Binaries located: ${TICK} digibyted ${TICK} digibyte-cli\\n" "${TICK}"
fi
else
printf "%b %bERROR: Unable to locate DigiByte Core binaries.%b\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "%b This script is unable to find your DigiByte Core binaries - digibyte & digibye-cli.\\n" "${INDENT}"
if [ "$LOCATE_DIGIBYTE" = true ] && [ "$SKIP_DETECTING_DIGIBYTE" != "YES" ]; then
is_dgb_installed="no"
locate_digibyte_node
else
printf "\\n"
is_dgb_installed="no"
fi
fi
# Is Dual Node detected?
str="Is a DigiByte Dual Node detected?..."
printf "%b %s" "${INFO}" "${str}"
if [ -f "$DGB2_SYSTEMD_SERVICE_FILE" ] || [ -f "$DGB2_UPSTART_SERVICE_FILE" ]; then
DGB2_STATUS="installed"
printf "%b%b %s YES!\\n" "${OVER}" "${TICK}" "${str}"
DGB_DUAL_NODE="YES"
sed -i -e "/^DGB_DUAL_NODE=/s|.*|DGB_DUAL_NODE=\"YES\"|" $DGNT_SETTINGS_FILE
else
DGB2_STATUS="not_detected"
printf "%b%b %s NO!\\n" "${OVER}" "${CROSS}" "${str}"
DGB_DUAL_NODE="NO"
sed -i -e "/^DGB_DUAL_NODE=/s|.*|DGB_DUAL_NODE=\"NO\"|" $DGNT_SETTINGS_FILE
fi
# Check if digibyte core is configured to run as a service
if [ -f "$DGB_SYSTEMD_SERVICE_FILE" ] || [ -f "$DGB_UPSTART_SERVICE_FILE" ]; then
find_dgb_service="yes"
if [ $VERBOSE_MODE = true ]; then
if [ "$DGB_DUAL_NODE" = "YES" ]; then
printf "%b Primary DigiByte Node service file is installed\\n" "${TICK}"
else
printf "%b DigiByte Node service file is installed\\n" "${TICK}"
fi
fi
else
printf "%b %bWARNING: digibyted.service not found%b\\n" "${WARN}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "%b To ensure your DigiByte Node stays running 24/7, it is a good idea to setup\\n" "${INDENT}"
printf "%b DigiByte daemon to run as a service. If you already have a systemd service file\\n" "${INDENT}"
printf "%b to run 'digibyted', you can rename it to /etc/systemd/system/digibyted.service\\n" "${INDENT}"
printf "%b so that this script can find it. If you wish to setup your DigiByte Node to run\\n" "${INDENT}"
printf "%b as a service, you can use DigiNode Setup.\\n" "${INDENT}"
printf "\\n"
local dgb_service_warning="yes"
fi
# Check for .digibyte data directory
if [ -d "$DGB_SETTINGS_LOCATION" ]; then
find_dgb_settings_folder="yes"
if [ $VERBOSE_MODE = true ]; then
printf "%b ~/.digibyte settings folder located\\n" "${TICK}"
fi
else
printf "%b %bERROR: ~/.digibyte settings folder not found.%b\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "%b The DigiByte settings folder contains your wallet and digibyte.conf\\n" "${INDENT}"
printf "%b in addition to the blockchain data itself. The folder was not found in\\n" "${INDENT}"
printf "%b the expected location here: $DGB_DATA_LOCATION\\n" "${INDENT}"
printf "\\n"
fi
# Check digibyte.conf file can be found
if [ -f "$DGB_CONF_FILE" ]; then
find_dgb_conf_file="yes"
printf "%b digibyte.conf file located.\\n" "${TICK}"
scrape_digibyte_conf
else
printf "%b %bERROR: digibyte.conf not found.%b\\n" "${INFO}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "%b The digibyte.conf contains important configuration settings for\\n" "${INDENT}"
printf "%b your node. DigiNode Setup can help you create one.\\n" "${INDENT}"
printf "%b The expected location is here: $DGB_CONF_FILE\\n" "${INDENT}"
printf "\\n"
if [ "$is_dgb_installed" = "yes" ]; then
exit 1
fi
fi
# If digibyed service is failing, then display the error
if [ $(systemctl is-active digibyted) = 'failed' ] && [ "$is_dgb_installed" = "yes" ]; then
local known_dgb_service_error
known_dgb_service_error="no"
IS_CHAIN_CONFIG_VALID=$(digibyted stop 2>&1 | grep -Eo "Invalid combination of -regtest, -signet, -testnet and -chain.")
if [ "$IS_CHAIN_CONFIG_VALID" = "Invalid combination of -regtest, -signet, -testnet and -chain." ]; then
known_dgb_service_error="yes"
printf "\\n"
printf "%b %bERROR: Invalid combination of -regtest, -signet, -testnet and -chain.%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "\\n"
printf "%b Your digibyte.conf file contains an invalid combination -regtest, -signet,\\n" "${INDENT}"
printf "%b -testnet and -chain. You can use at most one. For this reason, the DigiByte daemon.\\n" "${INDENT}"
printf "%b is unable to start. Please edit your digibyte.conf to fix this:\\n" "${INDENT}"
printf "\\n"
printf "%b %bdiginode --dgbconf%b\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "\\n"
printf "%b Restart DigiByte daemon when done:\\n" "${INDENT}"
printf "\\n"
printf "%b %bdiginode --dgbrestart%b\\n" "${INDENT}" "${COL_BOLD_WHITE}" "${COL_NC}"
printf "\\n"
exit 1
fi
if [ $known_dgb_service_error = "no" ]; then
printf "\\n"
printf "%b %bERROR: digibyted service does not appear to be running.%b\\n" "${CROSS}" "${COL_LIGHT_RED}" "${COL_NC}"
printf "\\n"
DGB_STATUS="stopped"
fi
# Kill digibyted in case it started running by accident
# dgb_process_id=$(pgrep digibyted)
# if [ "$dgb_process_id" != "" ]; then
# kill -9 $dgb_process_id
# fi
# printf "\\n"
# exit 1
fi
# Find out which DGB network is running - main, test, regtest, signet
if [ "$DGB_DUAL_NODE" = "YES" ]; then
str="Checking primary DigiByte Node chain..."
else
str="Checking DigiByte Node chain..."
fi
printf "%b %s" "${INFO}" "${str}"
# Query if DigiByte Core is running the mainn, test, regtest ro signet chain
query_digibyte_chain
if [ "$DGB_NETWORK_CURRENT" = "TESTNET" ] && [ "$DGB_NETWORK_CURRENT_LIVE" = "YES" ]; then
printf "%b%b %s %bTESTNET%b (live)\\n" "${OVER}" "${TICK}" "${str}" "${COL_LIGHT_YEL}" "${COL_NC}"
elif [ "$DGB_NETWORK_CURRENT" = "REGTEST" ] && [ "$DGB_NETWORK_CURRENT_LIVE" = "YES" ]; then
printf "%b%b %s %bREGTEST%b (live)\\n" "${OVER}" "${TICK}" "${str}" "${COL_LIGHT_YEL}" "${COL_NC}"
elif [ "$DGB_NETWORK_CURRENT" = "SIGNET" ] && [ "$DGB_NETWORK_CURRENT_LIVE" = "YES" ]; then
printf "%b%b %s %SIGNET%b (live)\\n" "${OVER}" "${TICK}" "${str}" "${COL_LIGHT_YEL}" "${COL_NC}"
elif [ "$DGB_NETWORK_CURRENT" = "MAINNET" ] && [ "$DGB_NETWORK_CURRENT_LIVE" = "YES" ]; then
printf "%b%b %s MAINNET (live)\\n" "${OVER}" "${TICK}" "${str}"
elif [ "$DGB_NETWORK_CURRENT" = "TESTNET" ] && [ "$DGB_NETWORK_CURRENT_LIVE" = "NO" ]; then
printf "%b%b %s %bTESTNET%b (from digibyte.conf)\\n" "${OVER}" "${TICK}" "${str}" "${COL_LIGHT_YEL}" "${COL_NC}"
elif [ "$DGB_NETWORK_CURRENT" = "REGTEST" ] && [ "$DGB_NETWORK_CURRENT_LIVE" = "NO" ]; then
printf "%b%b %s %bREGTEST%b (from digibyte.conf)\\n" "${OVER}" "${TICK}" "${str}" "${COL_LIGHT_YEL}" "${COL_NC}"
elif [ "$DGB_NETWORK_CURRENT" = "SIGNET" ] && [ "$DGB_NETWORK_CURRENT_LIVE" = "NO" ]; then
printf "%b%b %s %SIGNET%b (from digibyte.conf)\\n" "${OVER}" "${TICK}" "${str}" "${COL_LIGHT_YEL}" "${COL_NC}"
elif [ "$DGB_NETWORK_CURRENT" = "MAINNET" ] && [ "$DGB_NETWORK_CURRENT_LIVE" = "NO" ]; then
printf "%b%b %s MAINNET (from digibyte.conf)\\n" "${OVER}" "${TICK}" "${str}"
fi
# Get current listening port
query_digibyte_port
# Show current listening port of primary DigiByte Node
if [ "$DGB_LISTEN_PORT" != "" ] && [ "$DGB_LISTEN_PORT_LIVE" = "YES" ]; then
if [ "$DGB_DUAL_NODE" = "YES" ]; then
printf "%b Primary DigiByte Node listening port: $DGB_LISTEN_PORT (live)\\n" "${INFO}"