Repository navigation
Expand file tree
/
Copy pathsucrtools
More file actions
1257 lines (1060 loc) · 56.6 KB
/
Copy pathsucrtools
File metadata and controls
1257 lines (1060 loc) · 56.6 KB
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
#version:0.2.2
#changelog:\nLocation of sentinel log\nReview system log\n@reboot crontab review\nDownload Location - ability to change\nLanguage update\nRussian Language Support\ngithub support
NONE='\033[00m'
RED='\033[01;31m'
GREEN='\033[01;32m'
YELLOW='\033[01;33m'
PURPLE='\033[01;35m'
CYAN='\033[01;36m'
WHITE='\033[01;37m'
BOLD='\033[1m'
UNDERLINE='\033[4m'
BINDIR=/root/sucr
COIN="SUCR "
DAEMON="sucrd"
CONF="/root/.sucrcore/sucr.conf"
CLI=/usr/bin/sucr-cli
CORE=/root/.sucrcore
TOOLBIN=/usr/bin
TOOLTMP=/tmp
TOOLNAME=sucrtools
TOOLNAMENEW=sucrtoolsnew
TOOLHUB=masternodetools.com/tools
##SENTINEL_LOG="/root/sentinel-cron.log"
SENTINEL_LOG="/root/.sucrcore/sentinel/sentinel-cron.log"
CURVERSION="`cat $TOOLBIN/$TOOLNAME | grep -m1 \#version: | awk '{print $1}'| cut -f2 -d:`"
SCANPORT="" ## include port if needed while scanning external ip configuration
LANGUAGE="`cat $CORE/$TOOLNAME.conf | grep LANGUAGE=`"
GREPSYSLOG="sucr"
WALLETSTART=""
ShowFirewall() {
echo -e "$firewall"
#"\n${YELLOW}Display firewall rules${NONE}\n Using the command:\n ufw status numbered\n"
ufw status numbered
echo
}
ShowSentinel() {
DaemonMustBeActive
if [ "$TOT_DAEMON" = "2" ]
then
SENTINEL_DEBUG=1
savdir="`pwd`"
cd $CORE/sentinel
echo "Execute venv/bin/python bin/sentinel.py"
echo "Response should be blanks."
echo "Begin Response."
venv/bin/python bin/sentinel.py
echo "End Response."
cd $savdir
fi
echo
}
ShowServerUptime() {
echo -e "$serverUptime"
## "\n${YELLOW}Server Uptime.${NONE}\n Using the command:\n uptime"
uptime
echo
}
ShowActiveDaemon() {
echo -e "$activeDaemon"
## "\n${YELLOW}Check $DAEMON daemon.${NONE}\n\n The Daemon is a process that communicates to $COIN Network to keep your MasterNode active\n It must be active to receive rewards\n\n Using the command:\n ps -ef | grep $DAEMON\n"
TOT_DAEMON="`ps -ef | grep -c $DAEMON`"
if [ "$TOT_DAEMON" = "2" ]
then
echo -e "$goodDaemon"
else
echo -e "$badDaemon"
fi
echo
}
MasterNodeEnabled() {
DaemonMustBeActive
if [ "$TOT_DAEMON" = "2" ]
then
echo -e "$MNENABLED"
##"\n${YELLOW}Show MasterNode Enabled Status.${NONE}\n Using the command:\n $CLI masternode list full | grep $HOST_IP"
##$CLI masternode list full | grep $HOST_IP
MN_STATUS="`$CLI masternode list full | grep $HOST_IP`"
echo -e "\n $MN_STATUS \n"
echo -e " look for enabled"
## I think this can be expressed on command line as
# xxx-cli masternodelist full `/sbin/ifconfig eth0 | grep Mask | awk '{print $2}'| cut -f2 -d:`
## echo $MN_STATUS
MN_IS_ENABLED=`echo $MN_STATUS | grep ENABLED | wc`
MN_STATUS=`echo $MN_IS_ENABLED | awk '{print $1}'`
if [ "$MN_STATUS" = "1" ]
then
echo -e "`date +"%Y-%m-%d %T"` MasterNode $HOST_IP is Up - ${WHITE}ENABLED${NONE}"
else
echo -e "`date +"%Y-%m-%d %T"` MasterNode $HOST_IP is Down - ${RED}NOT ENABLED${NONE}"
fi
fi
echo
}
MasternodeListStatus() {
DaemonMustBeActive
if [ "$TOT_DAEMON" = "2" ]
then
echo -e "$mnList"
##echo -e "\n${YELLOW}Show MasterNode List.${NONE}\n Using the command:\n $CLI masternode list addr | grep $HOST_IP"
##echo -e "\nYou should find your IP address listed below. If you do not - your MasterNode is not registered\n\nbegin ...."
$CLI masternode list addr | grep $HOST_IP
##echo "end ....."
fi
echo
}
ShowIpAddress() {
IP_ONLY="`echo "$EXTERNAL_IP" | awk -F"=" '{ print $2 }'`"
echo -e "checkingVPS"
#"${YELLOW}Checking VPS / Masternode external IP address${NONE}\n Your external ip address for putty / masternode configuration is: $HOST_IP\n"
echo -e "$checkingVPS2"
#" To verify everything is setup properly - we scan the config file [ $CONF ] for the keyword $SCANIP\n Then we compare the results to the HOST_IP address [ $HOST_IP ]\n"
echo -e "$checkingVPS3"
#"\n To find your IP address we use the command:\n /sbin/ifconfig eth0 | grep Mask | awk '{print $2}'| cut -f2 -d:\n"
echo -e "$checkingVPS4"
#"\n We compare that to the config file [ $CONF ] to your IP addreess using\n cat $CONF | grep external\n"
echo -e "$checkingVPS5"
#"Now we will check VPS configuration file\nThis is located in $CONF"
if [ "$HOST_IP$SCANPORT" != "$IP_ONLY" ]
then
echo -e "$checkingVPS6"
#"${RED}** Possibly issue with externalip $IP_ONLY .... host IP = $HOST_IP $CONF ${NONE}\n Use the menu to review your config file"
else
echo -e "$checkingVPS7"
#"${WHITE}externalip appears to be configured properly - $EXTERNAL_IP${NONE}"
fi
echo
}
ReviewSyslog() {
echo -e "$reviewSyslog"
##reviewSyslog="\n${YELLOW}Review System Log for Sentinel issues${NONE}\n Using the command:\n grep CRON /var/log/syslog | grep $CORE\n"
## reviewSyslog="\n${YELLOW}Revise el registro del sistema para problemas de Sentinel${NONE}\n Usando el comando:\n grep CRON /var/log/syslog | grep $CORE\n"
grep CRON /var/log/syslog | grep $GREPSYSLOG
echo "`date` CRON Review $GREPSYSLOG log date" >> /var/log/syslog
}
diagnoseCrontab() {
echo -e "$diagCrontab"
#"\n${YELLOW}crontab diagnosis${NONE}\n Using the command:\n crontab -l\n Use the following command to edit\n crontab -e\n"
if [ "$MY_CRONTAB" = "$MY_CRONTABREVIEW" ]
then
echo -e "$reviewCrontab"
#"Reviewing crontab for sentinel.\n $MY_CRONTABREVIEW\n\n${WHITE}Looks good.${NONE}\n"
else
echo -e "$reviewError"
#"${RED}Check crontab - possible error\ndid not find\n$MY_CRONTABREVIEW\n${NONE}"
fi
# reboot
if [ "$MY_CRONTAB2" = "$MY_CRONTABREVIEW2" ]
then
echo -e "$reviewCrontab2"
#"Reviewing crontab for command to restart daemon if VPS is restarted.\n $MY_CRONTABREVIEW\n\n${WHITE}Looks good.${NONE}\n"
else
echo -e "$reviewCrontab3"
#"${RED}Check crontab - possible error\ndid not find\n$MY_CRONTABREVIEW2\n${NONE}"
fi
}
ShowCrontab() {
echo -e "$crontabContents"
#"\n${YELLOW}crontab contents${NONE}\n Using the command:\n crontab -l\n Use crontab -e to edit\n"
crontab -l
}
ShowWalletInfo() {
DaemonMustBeActive
if [ "$TOT_DAEMON" = "2" ]
then
echo -e "$walletDaemon"
##echo -e "\n${YELLOW}The deamon is active so we show the wallet information${NONE}\n Using the command:\n $CLI getinfo;\n"
$CLI getinfo;
fi
}
ShowWalletSyncStatus() {
DaemonMustBeActive
if [ "$TOT_DAEMON" = "2" ]
then
echo -e "$walletSync"
## "\n${YELLOW}The deamon is active so we show the wallet information${NONE}\n Using the command:\n $CLI mnsync status\n"
SYNCSTATUS="`$CLI mnsync status`"
SYNCSTATUSRESULT="`$CLI mnsync status | grep IsMasternodeListSynced | awk '{print $2}'`"
echo "$SYNCSTATUS"
if [ "$SYNCSTATUSRESULT" = "true," ]
then
echo -e "$walletSync2"
##"${WHITE}The wallet is synced.${NONE}\n"
else
echo -e "$walletSync3"
##"${RED}The wallet has not finished syncing.${NONE}\n"
fi
fi
}
MasternodeStatus() {
DaemonMustBeActive
if [ "$TOT_DAEMON" = "2" ]
then
echo -e "$mnStatus"
## "\n${YELLOW}The deamon is active so we show the wallet information${NONE}\n Using the command:\n $CLI masternode status\n"
$CLI masternode status
echo
fi
}
ReindexWallet() {
echo '** not ready yet ** Shutting down wallet daemon...'
}
DisplayWalletConfig() {
echo -e "$walletConfig"
#"\n${YELLOW}Display Wallet daemon${NONE}\n Using the command:\n cat $CONF\n"
cat $CONF
echo
}
EditWalletConfig() {
sudo nano $CONF
}
ViewSentinelLogFile() {
echo -e "$logFile"
#"\n${YELLOW}View Sentinel Log File${NONE}\n Using the command:\n tail $SENTINEL_LOG\n"
tail $SENTINEL_LOG
}
ClearSentinelLogFile() {
echo -e "$clearLogFile"
#"\n${YELLOW}Clear Sentinel Log File${NONE}\n Using the command:\n echo \" \" > $SENTINEL_LOG\n"
echo "" > $SENTINEL_LOG
}
DateSentinelLogFile() {
echo -e "$dateLogFile"
#"\n${YELLOW}Add a Date to Sentinel Log File${NONE}\n Using the command:\n date \" \" >> $SENTINEL_LOG\n"
date >> $SENTINEL_LOG
}
StartWalletDaemon() {
echo -e "$startWalletDaemon"
#"\n${YELLOW}Start Wallet daemon${NONE}\n Using the command:\n $DAEMON -daemon\n"
TOT_DAEMON="`ps -ef | grep -c $DAEMON`"
if [ "$TOT_DAEMON" = "2" ]
then
echo -e "$daemonRunning"
#"${RED}** The $DAEMON is already running [ ps -ef | grep -c $DAEMON ] ${NONE}"
else
echo "Starting $DAEMON"
$DAEMON -daemon
sleep 5
fi
echo
}
StopWalletDaemon() {
echo -e "$stopWallet"
#"\n${YELLOW}Stop Wallet daemon${NONE}\n Using the command:\n $CLI stop\n"
DaemonMustBeActive
if [ "$TOT_DAEMON" = "2" ]
then
$CLI stop
sleep 5
fi
}
killWalletDaemon() {
echo -e "$killWallet"
#"\n${YELLOW}Stop Wallet daemon${NONE}\n Using the command:\n ps -aef | grep $DAEMON | grep -v grep | awk '{print $2}' | xargs kill\n"
DaemonMustBeActive
if [ "$TOT_DAEMON" = "2" ]
then
ps -aef | grep $DAEMON | grep -v grep | awk '{print $2}' | xargs kill
echo "$killWallet2"
#"If there were no errors - the process has been killed"
else
echo -e "${YELLOW}** $DAEMON wallet daemon is not running - no need to stop${NONE}"
fi
}
ReviewMyMasterNode() {
ShowOSversion
ShowServerUptime
ShowFreeSpace
ShowFirewall
ShowIpAddress
diagnoseCrontab
ShowWalletInfo
ShowWalletSyncStatus
ShowActiveDaemon
MasterNodeEnabled
}
ShowFreeSpace() {
echo -e "$freeSpace"
## "\n${YELLOW}free space / swap${NONE}\n Using the command:\n free -h\n"
echo -e "\n$freeSpace1 ${YELLOW} `free -h | grep Mem: | awk '{print $2}'` ${NONE} $freeSpace2"
echo -e "$freeSpace3"
#"It appears that you currently have ${YELLOW} `free -h | grep Swap | awk '{print $2}'` ${NONE} swap space available\n"
free -h
echo
}
ShowOSversion() {
echo -e "$operatingSystem"
## "\n${YELLOW}Operating system version${NONE}\n Using the command:\n cat /etc/issue.net\n"
cat /etc/issue.net
echo
}
ShowWalletMenu() {
response1="1"
declare -ga WalletMenu=("" "${CYAN}[1]${NONE} Show Active wallet daemon" "${CYAN}[2]${NONE} Show wallet info"
"${CYAN}[3]${NONE} Show wallet sync status" "${CYAN}[4]${NONE} Start wallet daemon"
"${CYAN}[5]${NONE} Stop wallet daemon" "${CYAN}[6]${NONE} Display wallet config"
"${CYAN}[7]${NONE} Edit wallet config")
declare -ga WalletMenuOptions=("" "ShowActiveDaemon" "ShowWalletInfo" "ShowWalletSyncStatus" "StartWalletDaemon" "StopWalletDaemon" "DisplayWalletConfig" "EditWalletConfig")
if [ "$LANGUAGE" = "LANGUAGE=SPANISH" ]
then
declare -ga WalletMenu=("" "${CYAN}[1]${NONE} Mostrar daemon de monedero activo" "${CYAN}[2]${NONE} Mostrar información de la billetera"
"${CYAN}[3]${NONE} Mostrar el estado de sincronización de la billetera" "${CYAN}[4]${NONE} Inicie el daemon de monedero"
"${CYAN}[5]${NONE} Detener wallet daemon" "${CYAN}[6]${NONE} Mostrar configuración de billetera"
"${CYAN}[7]${NONE} Editar la configuración de la billetera")
fi
if [ "$LANGUAGE" = "LANGUAGE=RUSSIAN" ]
then
declare -ga WalletMenu=("" "${CYAN}[1]${NONE} Показать активный кошелек daemon" "${CYAN}[2]${NONE} Показать информацию о кошельке"
"${CYAN}[3]${NONE} Показывать статус синхронизации кошелька" "${CYAN}[4]${NONE} Начало демона кошелька"
"${CYAN}[5]${NONE} Демон дескриптора кошелька" "${CYAN}[6]${NONE} Показать конфигурацию кошелька"
"${CYAN}[7]${NONE} Изменить конфигурацию кошелька")
fi
until [ "$response1" == "" ]; do
zi2=0
for i in "${WalletMenu[@]}"
do
if [ "$CMDLINE" == "/help" ]
then
chrlen=${#WalletMenuOptions[$zi2]}
if [ "$chrlen" -gt "14" ]
then
tab="\t"
else
tab="\t\t"
fi
echo -e "\t${WalletMenuOptions[$zi2]} $tab $i"
response1=""
else
echo -e "$i"
fi
let "zi2 = $zi2 + 1"
done
if [ "$CMDLINE" != "/help" ]
then
echo -e "${BOLD}$whatWouldYou${NONE}"
read -p "$selectDescription " response1
echo
fi
enterToContinue="$response1"
if [ "$CMDLINE" != "/help" ]
then
until [ "$enterToContinue" == "" ]; do
${WalletMenuOptions[enterToContinue]}
read -p "$pressEnter " enterToContinue
done
fi
done
}
ShowMasterNodeMenu() {
declare -ga MasterNodeMenu=("" "${CYAN}[1]${NONE} Show Masternode List Status" "${CYAN}[2]${NONE} Show Masternode Status"
"${CYAN}[3]${NONE} Is MasterNode Enabled"
"${CYAN}[4]${NONE} Show IP Address / Config File validation" "${CYAN}[5]${NONE} Show Sentinel")
if [ "$LANGUAGE" = "LANGUAGE=SPANISH" ]
then
declare -ga MasterNodeMenu=("" "${CYAN}[1]${NONE} Mostrar estado de la lista Masternode" "${CYAN}[2]${NONE} Mostrar estado de Masternode"
"${CYAN}[3]${NONE} ¿MasterNode está habilitado?"
"${CYAN}[4]${NONE} Mostrar la validación de la dirección IP / archivo de configuración" "${CYAN}[5]${NONE} Mostrar Sentinel")
fi
if [ "$LANGUAGE" = "LANGUAGE=RUSSIAN" ]
then
declare -ga MasterNodeMenu=("" "${CYAN}[1]${NONE} Показать статус списка Masternode" "${CYAN}[2]${NONE} Показать статус Masternode"
"${CYAN}[3]${NONE} Включен ли MasterNode"
"${CYAN}[4]${NONE} Показать подтверждение IP-адреса / конфига" "${CYAN}[5]${NONE} Показать Sentinel")
fi
declare -ga MasterNodeMenuOptions=("" "MasternodeListStatus" "MasternodeStatus" "MasterNodeEnabled" "ShowIpAddress" "ShowSentinel")
response1="1"
until [ "$response1" == "" ]; do
zi2=0
for i in "${MasterNodeMenu[@]}"
do
if [ "$CMDLINE" == "/help" ]
then
chrlen=${#MasterNodeMenuOptions[$zi2]}
if [ "$chrlen" -gt "14" ]
then
tab="\t"
else
tab="\t\t"
fi
echo -e "\t${MasterNodeMenuOptions[$zi2]} $tab $i"
response1=""
else
echo -e "$i"
fi
let "zi2 = $zi2 + 1"
done
if [ "$CMDLINE" != "/help" ]
then
echo -e "${BOLD}$whatWouldYou${NONE}"
read -p "$selectDescription " response1
echo
fi
enterToContinue="$response1"
if [ "$CMDLINE" != "/help" ]
then
until [ "$enterToContinue" == "" ]; do
${MasterNodeMenuOptions[enterToContinue]}
read -p "$pressEnter " enterToContinue
done
fi
done
}
ShowSentinelMenu() {
response1="1"
declare -ga SentinelMenu=("" "${CYAN}[1]${NONE} View sentinel log file" "${CYAN}[2]${NONE} Clear sentinel log file"
"${CYAN}[3]${NONE} Add a time date stamp to sentinel log file" "${CYAN}[4]${NONE} Show Sentinel" "${CYAN}[5]${NONE} Review System Log for Sentinel Issues")
if [ "$LANGUAGE" = "LANGUAGE=SPANISH" ]
then
declare -ga SentinelMenu=("" "${CYAN}[1]${NONE} Ver archivo de registro centinela" "${CYAN}[2]${NONE} Borrar el archivo de registro centinela"
"${CYAN}[3]${NONE} Agregue un sello de fecha y hora al archivo de registro centinela" "${CYAN}[4]${NONE} Mostrar Sentinel" "${CYAN}[5]${NONE} Revise el registro del sistema para problemas de Sentinel")
fi
if [ "$LANGUAGE" = "LANGUAGE=RUSSIAN" ]
then
declare -ga SentinelMenu=("" "${CYAN}[1]${NONE} Просмотр файла журнала отправителя" "${CYAN}[2]${NONE} Очистить файл журнала дозорного"
"${CYAN}[3]${NONE} Добавить метку даты в файл журнала дозорного" "${CYAN}[4]${NONE} Показать Sentinel" "${CYAN}[5]${NONE} Обзор системного журнала для проблем Sentinel")
fi
declare -ga SentinelMenuOptions=("" "ViewSentinelLogFile" "ClearSentinelLogFile" "DateSentinelLogFile" "ShowSentinel" "ReviewSyslog")
until [ "$response1" == "" ]; do
zi2=0
for i in "${SentinelMenu[@]}"
do
if [ "$CMDLINE" == "/help" ]
then
chrlen=${#SentinelMenuOptions[$zi2]}
if [ "$chrlen" -gt "14" ]
then
tab="\t"
else
tab="\t\t"
fi
echo -e "\t${SentinelMenuOptions[$zi2]} $tab $i"
response1=""
else
echo -e "$i"
fi
let "zi2 = $zi2 + 1"
done
if [ "$CMDLINE" != "/help" ]
then
echo -e "${BOLD}$whatWouldYou${NONE}"
read -p "$selectDescription " response1
echo
fi
enterToContinue="$response1"
if [ "$CMDLINE" != "/help" ]
then
until [ "$enterToContinue" == "" ]; do
${SentinelMenuOptions[enterToContinue]}
read -p "$pressEnter " enterToContinue
done
fi
done
}
LanguageMenu() {
declare -ga LanguageMenu=("" "${CYAN}[1]${NONE} Set Menu to English" "${CYAN}[2]${NONE} Set Menu to Spanish" "${CYAN}[3]${NONE} Set Menu Russian")
if [ "$LANGUAGE" = "LANGUAGE=SPANISH" ]
then
declare -ga LanguageMenu=("" "${CYAN}[1]${NONE} Establecer menú en inglés" "${CYAN}[2]${NONE} Establecer menú para español" "${CYAN}[3]${NONE} Establecer el menú ruso")
fi
if [ "$LANGUAGE" = "LANGUAGE=RUSSIAN" ]
then
declare -ga LanguageMenu=("" "${CYAN}[1]${NONE} Установить меню на английский язык" "${CYAN}[2]${NONE} Установить меню на испанский" "${CYAN}[3]${NONE} Меню Set Russian")
fi
declare -ga LanguageMenuOptions=("" "SetLanguage ENGLISH" "SetLanguage SPANISH" "SetLanguage RUSSIAN")
response1="1"
until [ "$response1" == "" ]; do
zi2=0
for i in "${LanguageMenu[@]}"
do
if [ "$CMDLINE" == "/help" ]
then
chrlen=${#LanguageMenuOptions[$zi2]}
if [ "$chrlen" -gt "14" ]
then
tab="\t"
else
tab="\t\t"
fi
echo -e "\t${LanguageMenuOptions[$zi2]} $tab $i"
response1=""
else
echo -e "$i"
fi
let "zi2 = $zi2 + 1"
done
if [ "$CMDLINE" != "/help" ]
then
echo -e "${BOLD}$whatWouldYou${NONE}"
read -p "$selectDescription " response1
echo
fi
enterToContinue="$response1"
if [ "$CMDLINE" != "/help" ]
then
until [ "$enterToContinue" == "" ]; do
${LanguageMenuOptions[enterToContinue]}
read -p "$pressEnter " enterToContinue
done
fi
done
}
SetLanguage() {
confRemove "LANGUAGE="
echo "Language: ${1^^}"
echo "LANGUAGE=${1^^}" >> $CORE/$TOOLNAME.conf
LANGUAGE="`cat $CORE/$TOOLNAME.conf`"
exit
}
confRemove() {
oldConf=`cat $CORE/$TOOLNAME.conf | grep -v $1`
echo "$oldConf" > $CORE/$TOOLNAME.conf
}
downLoadMenu() {
declare -ga DownLoadMenu=("" "${CYAN}[1]${NONE} Set Location to Download to production (Stable Releases)" "${CYAN}[2]${NONE} Set Location to Download to masternodetools.com (newest / not the coin developer site / tool developer site)")
if [ "$LANGUAGE" = "LANGUAGE=SPANISH" ]
then
declare -ga DownLoadMenu=("" "${CYAN}[1]${NONE} Establecer la ubicación para descargar a producción (Versiones estables)" "${CYAN}[2]${NONE} Establezca la ubicación para descargar a masternodetools.com (el sitio del desarrollador del sitio / herramienta desarrollador de monedas más nuevo / no)")
fi
if [ "$LANGUAGE" = "LANGUAGE=RUSSIAN" ]
then
declare -ga DownLoadMenu=("" "${CYAN}[1]${NONE} Установить местоположение для загрузки в производство (стабильные выпуски)" "${CYAN}[2]${NONE} Установить местоположение для загрузки на masternodetools.com (новейший / не сайт разработчика сайта / разработчика монеты)")
fi
declare -ga DownLoadMenuOptions=("" "SetDownload github" "SetDownload toolsite")
responseD1="1"
until [ "$responseD1" == "" ]; do
zi2=0
for i in "${DownLoadMenu[@]}"
do
if [ "$CMDLINE" == "/help" ]
then
chrlen=${#DownLoadMenuOptions[$zi2]}
if [ "$chrlen" -gt "14" ]
then
tab="\t"
else
tab="\t\t"
fi
echo -e "\t${DownLoadMenuOptions[$zi2]} $tab $i"
responseD1=""
else
echo -e "$i"
fi
let "zi2 = $zi2 + 1"
done
if [ "$CMDLINE" != "/help" ]
then
echo -e "${BOLD}$whatWouldYou${NONE}"
read -p "$selectDescription " responseD1
echo
fi
enterToContinue="$responseD1"
if [ "$CMDLINE" != "/help" ]
then
until [ "$enterToContinue" == "" ]; do
${DownLoadMenuOptions[enterToContinue]}
read -p "$pressEnter " enterToContinue
done
fi
done
}
downloadLocation() {
TOOLDOWNLOAD="`cat $CORE/$TOOLNAME.conf | grep TOOLDOWNLOAD | awk -F\= '{gsub(/"/,"",$2);print $2}'`"
if [ "$TOOLDOWNLOAD" = "" ]
then
# No setting in config file
TOOLHUB="https://github.com/sucremoneda/sucre-tools.git"
TOOLDOWNLOAD = "github"
elif [ "$TOOLDOWNLOAD" = "github" ]
then
# github / coin website
TOOLHUB="https://github.com/sucremoneda/sucre-tools.git"
else
# Traditional location
TOOLHUB=masternodetools.com/tools
fi
if [ "$TOOLDOWNLOAD" = "github" ]
then
sudo rm -rf /root/sucre-tools
sudo git clone $TOOLHUB > /dev/null 2>&1
sudo cp /root/sucre-tools/sucrtools $TOOLTMP/$TOOLNAMENEW
do_nothing="N"
else
wget $TOOLHUB/$TOOLNAME -O $TOOLTMP/$TOOLNAMENEW > /dev/null 2>&1
if [ $? -ne 0 ]
then
do_nothing="Y"
else
do_nothing="N"
fi
fi
}
SetDownload() {
confRemove "TOOLDOWNLOAD="
echo "TOOLDOWNLOAD=$1" >> $CORE/$TOOLNAME.conf
}
counter () {
## Total useage
TOTALCTR="`cat $CORE/$TOOLNAME.conf | grep -m1 \TOTALCTR | awk '{print $1}'| cut -f2 -d:`"
let "TOTALCTR = $TOTALCTR + 1"
confRemove "TOTALCTR="
echo "TOTALCTR=$TOTALCTR" >> $CORE/$TOOLNAME.conf
## Count to 10 check for update
USEAGE="`cat $CORE/$TOOLNAME.conf | grep -m1 \USEAGE | awk '{print $1}'| cut -f2 -d:`"
let "USEAGE = $USEAGE + 1"
confRemove "USEAGE="
let "testUSEAGE = $USEAGE"
if [ "$USEAGE" -gt 10 ]
then
downloadLocation
#wget $TOOLHUB/$TOOLNAME -O $TOOLTMP/$TOOLNAMENEW > /dev/null 2>&1
#if [ $? -ne 0 ]
# then
# do_nothing="Y"
#else
if [ "$do_nothing" = "N" ]
then
NEWVERSION="`cat $TOOLTMP/$TOOLNAMENEW | grep -m1 \#version: | awk '{print $1}'| cut -f2 -d:`"
if [ "$CURVERSION" = "$NEWVERSION" ]
then
do_nothing="Y"
else
echo -e "\n${RED}** Upgrade available to version $NEWVERSION ** ${NONE}\n"
CHANGES="`cat $TOOLTMP/$TOOLNAMENEW | grep -m1 \#changelog:`"
echo -e "${YELLOW}$CHANGES${NONE}\n"
fi
fi
USEAGE="0"
fi
echo "USEAGE=$USEAGE" >> $CORE/$TOOLNAME.conf
}
ShowSystemMenu() {
declare -ga SystemMenu=("" "${CYAN}[1]${NONE} Show Firewall" "${CYAN}[2]${NONE} Show crontab (Scheduled tasks)"
"${CYAN}[3]${NONE} Diagnose crontab (Scheduled tasks)" "${CYAN}[4]${NONE} Show Server Uptime"
"${CYAN}[5]${NONE} Show IP Address" "${CYAN}[6]${NONE} Show Free Space"
"${CYAN}[7]${NONE} Show OS version" "${CYAN}[8]${NONE} Language Options" "${CYAN}[9]${NONE} Download Updates Location")
if [ "$LANGUAGE" = "LANGUAGE=SPANISH" ]
then
declare -ga SystemMenu=("" "${CYAN}[1]${NONE} Mostrar Firewall" "${CYAN}[2]${NONE} Mostrar crontab (tareas programadas)"
"${CYAN}[3]${NONE} Diagnosticar crontab (Tareas programadas)" "${CYAN}[4]${NONE} Mostrar el tiempo de actividad del servidor"
"${CYAN}[5]${NONE} Mostrar dirección IP" "${CYAN}[6]${NONE} Mostrar espacio libre"
"${CYAN}[7]${NONE} Mostrar la versión del sistema operativo" "${CYAN}[8]${NONE} Opciones de lenguaje" "${CYAN}[9]${NONE} Descargue Actualizaciones Ubicación" )
fi
if [ "$LANGUAGE" = "LANGUAGE=RUSSIAN" ]
then
declare -ga SystemMenu=("" "${CYAN}[1]${NONE} Показать межсетевой экран" "${CYAN}[2]${NONE} Показать crontab (Запланированные задания)"
"${CYAN}[3]${NONE} Диагностика crontab (Запланированные задания)" "${CYAN}[4]${NONE} Показывать время сервера"
"${CYAN}[5]${NONE} Показать IP-адрес" "${CYAN}[6]${NONE} Показать свободное пространство"
"${CYAN}[7]${NONE} Показать версию ОС" "${CYAN}[8]${NONE} Параметры языка" "${CYAN}[9]${NONE} Загрузка обновлений")
fi
declare -ga SystemMenuOptions=("" "ShowFirewall" "ShowCrontab" "diagnoseCrontab" "ShowServerUptime"
"ShowIpAddress" "ShowFreeSpace" "ShowOSversion" "LanguageMenu" "downLoadMenu")
response1="1"
until [ "$response1" == "" ]; do
zi2=0
for i in "${SystemMenu[@]}"
do
if [ "$CMDLINE" == "/help" ]
then
chrlen=${#SystemMenuOptions[$zi2]}
if [ "$chrlen" -gt "14" ]
then
tab="\t"
else
tab="\t\t"
fi
echo -e "\t${SystemMenuOptions[$zi2]} $tab $i"
response1=""
else
echo -e "$i"
fi
let "zi2 = $zi2 + 1"
done
if [ "$CMDLINE" != "/help" ]
then
echo -e "${BOLD}$whatWouldYou${NONE}"
read -p "$selectDescription " response1
echo
fi
enterToContinue="$response1"
if [ "$CMDLINE" != "/help" ]
then
until [ "$enterToContinue" == "" ]; do
${SystemMenuOptions[enterToContinue]}
read -p "$pressEnter " enterToContinue
done
fi
done
}
ShowAbout() {
echo -e "$aboutInfo"
echo
read -p "$pressEnter1 " enterToContinue
}
Upgrade() {
echo -e "\n${WHITE}Check for upgrade.${NONE}"
downloadLocation
#wget $TOOLHUB/$TOOLNAME -O $TOOLTMP/$TOOLNAMENEW > /dev/null 2>&1
if [ "$do_nothing" = "Y" ]
then
echo -e "${RED}Not able to reach server $TOOLHUB/$TOOLNAME ${NONE}"
echo -e "Try again later.\n"
else
NEWVERSION="`cat $TOOLTMP/$TOOLNAMENEW | grep -m1 \#version: | awk '{print $1}'| cut -f2 -d:`"
if [ "$CURVERSION" = "$NEWVERSION" ]
then
echo "$currentRelease"
#"Already at current or newest release $CURVERSION"
echo -e "${WHITE}Press Enter to continue.${NONE}"
read -e -p "" $continue
else
CHANGES="`cat $TOOLTMP/$TOOLNAMENEW | grep -m1 \#changelog:`"
currentRelease2="An Upgrade from $CURVERSION to $NEWVERSION is available - it includes the following changes ${GREEN}\n$CHANGES${NONE}"
if [ "$LANGUAGE" = "LANGUAGE=SPANISH" ]
then
currentRelease2="Una actualización de $CURVERSION a $NEWVERSION está disponible, incluye los siguientes cambios ${GREEN}\n$CHANGES${NONE}"
fi
if [ "$LANGUAGE" = "LANGUAGE=RUSSIAN" ]
then
currentRelease2="Обновление с $CURVERSION to $NEWVERSION доступен - он включает следующие изменения: ${GREEN}\n$CHANGES${NONE}"
fi
echo -e "$currentRelease2"
#"An Upgrade from $CURVERSION to $NEWVERSION is available - it includes the following changes ${GREEN}\n$CHANGES${NONE}"
read -e -p "Upgrade to new version of MasterNode Utilities? [Y/n] :" upgrade_now
if [[ ("$upgrade_now" == "y" || "$upgrade_now" == "Y" || "$upgrade_now" == "") ]]; then
echo "$currentRelease3"
#"Let's upgrade - restart tools after upgrade"
chmod 755 $TOOLTMP/$TOOLNAMENEW
mv $TOOLTMP/$TOOLNAMENEW $TOOLBIN/$TOOLNAME
exit
else
echo -e "$currentRelease4"
#"Upgrade cancelled."
fi
fi
fi
}
DaemonMustBeActive() {
echo -e "$daemonMustBeRunning1"
##"\n${YELLOW}The daemon must be active to perform this command${NONE}\n Using the command:\n ps -ef | grep -c $DAEMON\n we check to see if the daemon is running\n"
TOT_DAEMON="`ps -ef | grep -c $DAEMON`"
if [ "$TOT_DAEMON" = "2" ]
then
stop="Yes"
else
echo -e "$daemonMustBeRunning2"
##"${YELLOW}The daemon $DAEMON must be running to use option\nUse Start Wallet Daemon option${NONE}"
fi
}
#######################################
counter
HOST_IP="`/sbin/ifconfig eth0 | grep Mask | awk '{print $2}'| cut -f2 -d:`"
SCANIP="external"
EXTERNAL_IP="`cat $CONF | grep $SCANIP`"
IP_ONLY="`echo "$EXTERNAL_IP" | awk -F"=" '{ print $2 }'`"
MY_CRONTAB="`crontab -l | grep sucrcore | grep sentinel-cron.log`"
MY_CRONTABREVIEW="* * * * * cd /root/.sucrcore/sentinel && ./venv/bin/python bin/sentinel.py >> sentinel-cron.log 2>&1"
MY_CRONTAB2="`crontab -l | grep $DAEMON`"
MY_CRONTABREVIEW2="@reboot sucrd -daemon"
declare -ga MainMenu=("" "${CYAN}[1]${NONE} Review My MasterNode" "${CYAN}[2]${NONE} Show Wallet Menu"
"${CYAN}[3]${NONE} Show Sentinel Menu" "${CYAN}[4]${NONE} Masternode Menu"
"${CYAN}[5]${NONE} Show System Menu" "" ""
"${CYAN}[8]${NONE} Show About / Information" "${CYAN}[9]${NONE} Check for new version / upgrade this script")
menuDescription="+-ver: $CURVERSION ----------------------+\n"
menuDescription+="| ${CYAN}$COIN Coin MasterNode Utilities${NONE} |\n"
menuDescription+="+----------------------------------+\n"
whatWouldYou="What would you like me to do?"
selectDescription="Select option with number:"
pressEnter1="Press enter to continue"
pressEnter="Press enter or Option to continue"
walletDaemon="\n${YELLOW}The deamon is active so we show the wallet information${NONE}\n Using the command:\n $CLI getinfo;\n"
walletSync="\n${YELLOW}The deamon is active so we show the wallet information${NONE}\n Using the command:\n $CLI mnsync status\n"
walletSync2="${WHITE}The wallet is synced.${NONE}\n"
walletSync3="${RED}The wallet has not finished syncing.${NONE}\n"
daemonMustBeRunning1=#"\n${YELLOW}The daemon must be active to perform this command${NONE}\n Using the command:\n ps -ef | grep -c $DAEMON\n we check to see if the daemon is running\n"
daemonMustBeRunning2="${YELLOW}The daemon $DAEMON must be running to use option\nUse Start Wallet Daemon option${NONE}"
operatingSystem="\n${YELLOW}Operating system version${NONE}\n Using the command:\n cat /etc/issue.net\n"
serverUptime="\n${YELLOW}Server Uptime.${NONE}\n Using the command:\n uptime"
activeDaemon="\n${YELLOW}Check $DAEMON daemon.${NONE}\n\n The Daemon is a process that communicates to $COIN Network to keep your MasterNode active\n It must be active to receive rewards\n\n Using the command:\n ps -ef | grep $DAEMON\n"
goodDaemon="${WHITE}Proper number of $DAEMON daemons running${NONE}"
badDaemon="${RED}[Error - Invalid number of $DAEMON daemons running${NONE}"
mnList="\n${YELLOW}Show MasterNode List.${NONE}\n Using the command:\n $CLI masternode list addr | grep $HOST_IP\nYou should find your IP address listed below. If you do not - your MasterNode is not registered\n\nbegin ...."
mnStatus="\n${YELLOW}The deamon is active so we show the wallet information${NONE}\n Using the command:\n $CLI masternode status\n"
freeSpace="\n${YELLOW}free space / swap${NONE}\n Using the command:\n free -h\n"
freeSpace1="Your VPS is configured with"
freeSpace2="memory available"
freeSpace3="It appears that you currently have ${YELLOW} `free -h | grep Swap | awk '{print $2}'` ${NONE} swap space available\n"
walletConfig="\n${YELLOW}Display Wallet daemon${NONE}\n Using the command:\n cat $CONF\n"
logFile="\n${YELLOW}View Sentinel Log File${NONE}\n Using the command:\n tail $SENTINEL_LOG\n"
clearLogFile="\n${YELLOW}Clear Sentinel Log File${NONE}\n Using the command:\n echo \" \" > $SENTINEL_LOG\n"
dateLogFile="\n${YELLOW}Add a Date to Sentinel Log File${NONE}\n Using the command:\n date \" \" >> $SENTINEL_LOG\n"
startWalletDaemon="\n${YELLOW}Start Wallet daemon${NONE}\n Using the command:\n $DAEMON -daemon\n"
firewall="\n${YELLOW}Display firewall rules${NONE}\n Using the command:\n ufw status numbered\n"
diagCrontab="\n${YELLOW}crontab diagnosis${NONE}\n Using the command:\n crontab -l\n Use the following command to edit\n crontab -e\n"
reviewCrontab="Reviewing crontab for sentinel.\n $MY_CRONTABREVIEW\n\n${WHITE}Looks good.${NONE}\n"
reviewSyslog="\n${YELLOW}Review System Log for Sentinel issues${NONE}\n Using the command:\n grep CRON /var/log/syslog | grep $GREPSYSLOG\n"
reviewCrontab2="Reviewing crontab for command to restart daemon if VPS is restarted.\n $MY_CRONTABREVIEW2\n\n${WHITE}Looks good.${NONE}\n"
reviewCrontab3="${RED}Check crontab - possible error\ndid not find\n$MY_CRONTABREVIEW2\n${NONE}"
reviewError="${RED}Check crontab - possible error\ndid not find\n$MY_CRONTABREVIEW\n${NONE}"
crontabContents="\n${YELLOW}crontab contents${NONE}\n Using the command:\n crontab -l\n Use crontab -e to edit\n"
checkingVPS="${YELLOW}Checking VPS / Masternode external IP address${NONE}\n Your external ip address for putty / masternode configuration is: $HOST_IP\n"
checkingVPS2=" To verify everything is setup properly - we scan the config file [ $CONF ] for the keyword $SCANIP\n Then we compare the results to the HOST_IP address [ $HOST_IP ]\n"
checkingVPS3="\n To find your IP address we use the command:\n /sbin/ifconfig eth0 | grep Mask | awk '{print $2}'| cut -f2 -d:\n"
checkingVPS4="\n Compare that information to the config file [ $CONF ] to your IP address Using the command:\n cat $CONF | grep external\n"
checkingVPS5="Now we will check VPS configuration file\nThis is located in $CONF"
checkingVPS6="${RED}** There maybe an issue with externalip $IP_ONLY .... host IP = $HOST_IP $CONF ${NONE}\n Use the menu to review your config file"
checkingVPS7="${WHITE}externalip appears to be configured properly - $EXTERNAL_IP${NONE}"
stopWallet="\n${YELLOW}Stop Wallet daemon${NONE}\n Using the command:\n $CLI stop\n"
killWallet="\n${YELLOW}Stop Wallet daemon${NONE}\n Using the command:\n ps -aef | grep $DAEMON | grep -v grep | awk '{print $2}' | xargs kill\n"
killWallet2="If there were no errors - the process has been killed"
daemonRunning="${RED}** The $DAEMON is already running [ ps -ef | grep -c $DAEMON ] ${NONE}"
helpOptions="${YELLOW}Display $TOOLNAME help options\n${WHITE} Use command:\n $TOOLNAME {argument}${NONE}\n"
aboutInfo="${WHITE}+----------------------------------------------------+${NONE}\n"
aboutInfo+="${WHITE}| ${CYAN}$COIN Masternode Tools ver: $CURVERSION ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} ${YELLOW}The tools are free of charge. ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} ${YELLOW}Consider using the donation address if you want ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} ${YELLOW}us to continue the development of these tools ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} SAROS Donation: SeNPFMFBAPvSV2FFR8Tc2m6dncTE2ky7Se ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} SUCR Donation: SjUp3Fu2eB7wLBAQkFHs946m1ScWjWXbdr ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} GCH Donation: GT8bbHhtEQSzgMoXvLeHTf7dL9HwuGVeGY ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} LILI Donation: GT8bbHhtEQSzgMoXvLeHTf7dL9HwuGVeGY ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}|${NONE} ${WHITE}|${NONE}\n"
aboutInfo+="${WHITE}+----------------------------------------------------+${NONE}\n"
aboutInfo+="\nTools have been used $TOTALCTR times.\n"
MNENABLED="\n${YELLOW}Show MasterNode Enabled Status.${NONE}\n Using the command:\n $CLI masternode list full | grep $HOST_IP"