-
Notifications
You must be signed in to change notification settings - Fork 1
/
rtrmon.sh
5948 lines (5396 loc) · 273 KB
/
rtrmon.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
# RTRMON - Asus-Merlin Router Monitor by Viktor Jaep, 2022-2024
#
# RTRMON is a shell script that provides near-realtime stats about your Asus-Merlin firmware router. Instead of having to
# find this information on various different screens or apps, this tool was built to bring all this info together in one
# stat dashboard. Having a 'system' dashboard showing current CPU, Memory, Disk and Network stats would compiment other
# dashboard-like scripts greatly (like RTRMON), sitting side-by-side in their own SSH windows to give you everything
# you need to know that's happening on your network with a glance at your screen.
#
# Capabilities have been added to give a full view of your router's CPU, Memory, Disk, NVRAM, Swap file, WAN, LAN, Wi-FI,
# IP4/6 addresses, CPU/Antenna Temps, in addition to having incorporated the Ookla Speedtest Binaries for you to run an on
# -demand Speedtest with the press of a button. New supported models are continually being added as @RMerlin adds support
# for them with his own firmware.
#
# Please use the 'sh rtrmon.sh -setup' command to configure the necessary parameters that match your environment the best!
#
# -------------------------------------------------------------------------------------------------------------------------
# System Variables (Do not change beyond this point or this may change the programs ability to function correctly)
# -------------------------------------------------------------------------------------------------------------------------
# Last Modified: 2024-Nov-28
###########################################################################################################################
Version="2.1.4"
Beta=0
ScreenshotMode=0
LOGFILE="/jffs/addons/rtrmon.d/rtrmon.log" # Logfile path/name that captures important date/time events - change
APPPATH="/jffs/scripts/rtrmon.sh" # Path to the location of rtrmon.sh
CFGPATH="/jffs/addons/rtrmon.d/rtrmon.cfg" # Path to the location of rtrmon.cfg
DLVERPATH="/jffs/addons/rtrmon.d/version.txt" # Path to downloaded version from the source repository
OOKLAPATH="/jffs/addons/rtrmon.d/speedtest" # Path to Ookla speedtest binary
SPDRESPATH="/jffs/addons/rtrmon.d/results.txt" # Path to latest speedtest results
IFLIST="/jffs/addons/rtrmon.d/interfaces.txt" # Path to the Interface List
DIAGRESPATH="/jffs/addons/rtrmon.d/diagres.txt" # Path to the network diagnostics results
NMAPWANRESPATH="/jffs/addons/rtrmon.d/nwanres.txt" # Path to the nmap WAN open TCP port results
NMAPLANRESPATH="/jffs/addons/rtrmon.d/nlanres.txt" # Path to the nmap LAN open TCP port results
NMAPUWANRESPATH="/jffs/addons/rtrmon.d/nuwanres.txt" # Path to the nmap WAN open UDP port results
NMAPULANRESPATH="/jffs/addons/rtrmon.d/nulanres.txt" # Path to the nmap LAN open UDP port results
INITIALBOOT=0
CHANGES=0
LOGSIZE=2000
Interval=10
MaxSpeedInet=1000
MaxSpeedInetUL=50
MaxSpeedLAN=1000
MaxSpeed24Ghz=450
MaxSpeed5Ghz=780
MaxSpeed6Ghz=920
TempUnits="C"
Speedtst=0
WANOverride="Auto"
WAN0AltModes=0
VPNSite2Site=0
PSView="TCP"
NCView="WAN"
spdtestsvrID=0
autorotate=0
autorotateindicator="OFF"
QueueSpdTest=0
QueueNetworkDiag=0
QueueNetworkConn=0
QueueVPNSlot1=0
QueueVPNSlot2=0
QueueVPNSlot3=0
QueueVPNSlot4=0
QueueVPNSlot5=0
vpn1slot=0
vpn2slot=0
vpn3slot=0
vpn4slot=0
vpn5slot=0
VPNState=0
VPN2State=0
VPN3State=0
VPN4State=0
VPN5State=0
vpncity="Unknown"
vpn2city="Unknown"
vpn3city="Unknown"
vpn4city="Unknown"
vpn5city="Unknown"
vpnip="0.0.0.0"
vpn2ip="0.0.0.0"
vpn3ip="0.0.0.0"
vpn4ip="0.0.0.0"
vpn5ip="0.0.0.0"
vpn1on="False"
vpn2on="False"
vpn3on="False"
vpn4on="False"
vpn5on="False"
FromUI=0
NextPage=1
memused1=0
memfree1=0
memshrd1=0
membuff1=0
memcach1=0
memused2=0
memfree2=0
memshrd2=0
membuff2=0
memcach2=0
cpuusr1=0
cpusys1=0
cpunice1=0
cpuidle1=0
cpuirq1=0
displaycpuusr1=0
displaycpusys1=0
displaycpunice1=0
displaycpuidle1=0
displaycpuirq1=0
w24udsched="Scheduler Inactive"
w5udsched="Scheduler Inactive"
w52udsched="Scheduler Inactive"
w6udsched="Scheduler Inactive"
w62udsched="Scheduler Inactive"
w24updown="UP"
w5updown="UP"
w52updown="UP"
w6updown="UP"
w62updown="UP"
SortbyOpt="Name"
##-------------------------------------##
## Added by Martinski W. [2024-Nov-04] ##
##-------------------------------------##
timerReset=0
timeoutcmd="" # For "timeout" cmd for "nvram" calls #
timeoutsec="" # For "timeout" cmd for "nvram" calls #
timeoutlng="" # For "timeout" cmd for "nvram" calls #
hideoptions=1 # Hide/Show menu options flag #
prevHideOpts=X # Avoid redisplaying the options menu unnecessarily too often #
prevSortByOpt=X # Avoid resetting the timer loop unnecessarily too often #
bootInterval=10 # For "Boot Sequence" loop #
LAN_HostName=""
readonly gSavedSTTY="$(stty -g)"
##-------------------------------------##
## Added by Martinski W. [2024-Nov-05] ##
##-------------------------------------##
pausedTimerEnabled=false # To pause/resume main loop timer cycle #
pausedTimerDispStr=""
readonly pausedTimerMsgStr=" [** PAUSED **] "
readonly pausedTimerMsgLen="${#pausedTimerMsgStr}"
# Color variables
CBlack="\e[1;30m"
InvBlack="\e[1;40m"
CRed="\e[1;31m"
InvRed="\e[1;41m"
CGreen="\e[1;32m"
InvGreen="\e[1;42m"
CDkGray="\e[1;90m"
InvDkGray="\e[1;100m"
InvLtGray="\e[1;47m"
CYellow="\e[1;33m"
InvYellow="\e[1;43m"
CBlue="\e[1;34m"
InvBlue="\e[1;44m"
CMagenta="\e[1;35m"
CCyan="\e[1;36m"
InvCyan="\e[1;46m"
CWhite="\e[1;37m"
InvWhite="\e[1;107m"
CClear="\e[0m"
# -------------------------------------------------------------------------------------------------------------------------
# Functions
# -------------------------------------------------------------------------------------------------------------------------
#Shows the version bar formatted for build and date/time with TZ spacing#
##----------------------------------------##
## Modified by Martinski W. [2024-Nov-04] ##
##----------------------------------------##
showheader()
{
if [ "$hideoptions" = "0" ] && [ "$hideoptions" != "$prevHideOpts" ]
then displayopsmenu ; fi
timerReset=0
prevHideOpts="$hideoptions"
prevSortByOpt="$SortbyOpt"
tzone="$(date +%Z)"
tzonechars="${#tzone}"
if [ "$tzonechars" = "1" ]; then tzspaces=" ";
elif [ "$tzonechars" = "2" ]; then tzspaces=" ";
elif [ "$tzonechars" = "3" ]; then tzspaces=" ";
elif [ "$tzonechars" = "4" ]; then tzspaces=" ";
elif [ "$tzonechars" = "5" ]; then tzspaces=" "; fi
#Display RTRMON client header
echo -en "${InvGreen} ${InvDkGray}${CWhite} RTRMON - v"
printf "%-8s" $Version
echo -e " ${CGreen}(S)${CWhite}how/${CGreen}(H)${CWhite}ide Operations Menu ${InvDkGray} $tzspaces$(date) ${CClear}"
}
# -------------------------------------------------------------------------------------------------------------------------
# Displays the "Operations Menu" on top of screen.
##----------------------------------------##
## Modified by Martinski W. [2024-Nov-02] ##
##----------------------------------------##
displayopsmenu()
{
amtmdisp="${CDkGray}[n/a] "
echo -e "${InvGreen} ${InvDkGray}${CWhite} Operations Menu ${CClear}"
if [ "$vpn1on" == "True" ] || [ "$vpn2on" == "True" ] || [ "$vpn3on" == "True" ] || [ "$vpn4on" == "True" ] || [ "$vpn5on" == "True" ]
then
echo -e "${InvGreen} ${CClear} Speedtest ${CGreen}(I)${CClear} WAN / VPN Slot ${CGreen}(1)(2)(3)(4)(5)${CClear} ${InvGreen} ${CClear} ${CGreen}(M)${CClear}ain Setup Menu / Configuration Menu${CClear}"
else
echo -e "${InvGreen} ${CClear} Speedtest against ${CGreen}(I)${CClear} WAN interface${CClear} ${InvGreen} ${CClear} ${CGreen}(M)${CClear}ain Setup Menu / Configuration Menu${CClear}"
fi
echo -e "${InvGreen} ${CClear} Run Router Network ${CGreen}(D)${CClear}iagnostics ${InvGreen} ${CClear} L${CGreen}(O)${CClear}g Viewer / Trim Log Size (rows): ${CGreen}$LOGSIZE${CClear}"
echo -e "${InvGreen} ${CClear} Refresh ${CGreen}(C)${CClear}urrent Network Statistics ${InvGreen} ${CClear} ${CGreen}(N)${CClear}ext Page / ${CGreen}(P)${CClear}revious Page: ${CGreen}($NextPage/7)${CClear}"
echo -e "${InvGreen} ${CClear} View ${CGreen}(W)${CClear}AN / ${CGreen}(L)${CClear}AN / ${CGreen}(V)${CClear}PN Stats ${InvGreen} ${CClear} Auto ${CGreen}(R)${CClear}otate Pages Option: ${CGreen}$autorotateindicator${CClear}"
echo -e "${InvGreen} ${CClear} ${CDkGray}(A)MTM Email Notifications: $amtmdisp${CClear} ${InvGreen} ${CClear} Router Model/FW: ${CGreen}${RouterModel} | ${FWBUILD}${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}--------------------------------------------------------------------------------------------------------------${CClear}"
echo ""
}
##-------------------------------------##
## Added by Martinski W. [2024-Nov-02] ##
##-------------------------------------##
_ConsumeKeypressBuffer_()
{
local savedSettings
local keyPress='' prevTimeSec
savedSettings="$(stty -g)"
prevTimeSec="$(date +%s)"
read -rs -n1000 -t 1 keyPress < "$(tty 0>&2)"
while [ "$(date +%s)" -lt "$((prevTimeSec + 1))" ]
do
stty -echo -icanon min 0 time 1
cat - > /dev/null
done
stty "$savedSettings"
}
##-------------------------------------##
## Added by Martinski W. [2024-Nov-02] ##
##-------------------------------------##
_IgnoreKeypresses_()
{
if [ $# -eq 0 ] || [ -z "$1" ]
then return 1 ; fi
case "$1" in
ON) stty -echo ;;
OFF) stty "$gSavedSTTY" ; stty echo ;;
esac
}
# -------------------------------------------------------------------------------------------------------------------------
# LogoNM displays the RTRMON script name in a cool ASCII font that fades in
##----------------------------------------##
## Modified by Martinski W. [2024-Nov-02] ##
##----------------------------------------##
logoNM ()
{
clear
echo ""
echo ""
echo ""
echo -e "${CDkGray} ____ __________ __ _______ _ __"
echo -e " / __ \/_ __/ __ \/ |/ / __ \/ | / /"
echo -e " / /_/ / / / / /_/ / /|_/ / / / / |/ /"
echo -e " / _, _/ / / / _, _/ / / / /_/ / /| /"
echo -e " /_/ |_| /_/ /_/ |_/_/ /_/\____/_/ |_/ v$Version"
echo ""
echo ""
printf "\r ${CGreen} [ INITIALIZING ] ${CClear}"
_ConsumeKeypressBuffer_
clear
echo ""
echo ""
echo ""
echo -e "${CYellow} ____ __________ __ _______ _ __"
echo -e " / __ \/_ __/ __ \/ |/ / __ \/ | / /"
echo -e " / /_/ / / / / /_/ / /|_/ / / / / |/ /"
echo -e " / _, _/ / / / _, _/ / / / /_/ / /| /"
echo -e " /_/ |_| /_/ /_/ |_/_/ /_/\____/_/ |_/ v$Version"
echo ""
echo ""
}
# -------------------------------------------------------------------------------------------------------------------------
# logoNMexit displays the RTRMON script name in a cool ASCII font that fades out
logoNMexit () {
clear
echo ""
echo ""
echo ""
echo -e "${CYellow} ____ __________ __ _______ _ __"
echo -e " / __ \/_ __/ __ \/ |/ / __ \/ | / /"
echo -e " / /_/ / / / / /_/ / /|_/ / / / / |/ /"
echo -e " / _, _/ / / / _, _/ / / / /_/ / /| /"
echo -e " /_/ |_| /_/ /_/ |_/_/ /_/\____/_/ |_/ v$Version"
echo ""
echo ""
printf "\r ${CGreen} [ SHUTTING DOWN ] ${CClear}"
sleep 1
clear
echo ""
echo ""
echo ""
echo -e "${CDkGray} ____ __________ __ _______ _ __"
echo -e " / __ \/_ __/ __ \/ |/ / __ \/ | / /"
echo -e " / /_/ / / / / /_/ / /|_/ / / / / |/ /"
echo -e " / _, _/ / / / _, _/ / / / /_/ / /| /"
echo -e " /_/ |_| /_/ /_/ |_/_/ /_/\____/_/ |_/ v$Version"
echo ""
echo ""
printf "\r ${CGreen} [ SHUTTING DOWN ] ${CClear}"
sleep 1
printf "\r ${CDkGray} [ GOODBYE... ] ${CClear}\n\n"
sleep 1
}
##-------------------------------------##
## Added by Martinski W. [2024-Nov-02] ##
##-------------------------------------##
_PressAnyKeyToContinue_()
{ printf "\nPress any key to continue..." ; read -rsn1 anykey ; echo ; }
# -------------------------------------------------------------------------------------------------------------------------
# promptyn takes input for Y/N questions
promptyn () { # No defaults, just y or n
while true; do
read -p '[y/n]? ' YESNO
case "$YESNO" in
[Yy]* ) return 0 ;;
[Nn]* ) return 1 ;;
* ) echo -e "\nPlease answer y or n.";;
esac
done
}
# -------------------------------------------------------------------------------------------------------------------------
# Spinner provides a small spinning indicator on the screen to show script activity
spinner()
{
spins="$1"
spin=0
totalspins="$((spins / 4))"
while [ "$spin" -le "$totalspins" ]
do
for spinchar in / - \\ \|
do
printf "\r$spinchar"
sleep 1
done
spin="$((spin+1))"
done
printf "\r"
}
# -------------------------------------------------------------------------------------------------------------------------
# Preparebar and Progressbar is a script that provides a nice progressbar to show script activity and bar charts
##----------------------------------------##
## Modified by Martinski W. [2024-Nov-02] ##
##----------------------------------------##
preparebar()
{
# $1 - bar length
# $2 - bar char
barlen="$1"
barspaces="$(printf "%*s" "$1" ' ')"
barchars="$(printf "%*s" "$1" ' ' | tr ' ' "$2")"
}
##----------------------------------------##
## Modified by Martinski W. [2024-Nov-02] ##
##----------------------------------------##
# Had to make some mods to the variables being passed, and created an inverse colored progress bar
progressbar()
{
# $1 - number (-1 for clearing the bar)
# $2 - max number
# $3 - system name
# $4 - measurement
# $5 - standard/reverse progressbar
# $6 - alternate display values
# $7 - alternate value for progressbar exceeding 100%
insertspc=" "
if [ "$1" -eq -1 ]
then
printf "\r $barspaces\r"
else
if [ $# -gt 6 ] && [ -n "$7" ] && [ "$1" -ge "$7" ]
then
barch="$(($7*barlen/$2))"
barsp="$((barlen-barch))"
progr="$((100*$1/$2))"
else
barch="$(($1*barlen/$2))"
barsp="$((barlen-barch))"
progr="$((100*$1/$2))"
fi
if [ $# -gt 5 ] && [ -n "$6" ]; then AltNum="$6" ; else AltNum="$1" ; fi
if [ "$5" = "Standard" ]
then
if [ "$progr" -le 60 ]; then
printf "${InvGreen}${CWhite}$insertspc${CClear}${CWhite}${3} ${CDkGray}[${CGreen}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
elif [ "$progr" -gt 60 ] && [ "$progr" -le 85 ]; then
printf "${InvYellow}${CBlack}$insertspc${CClear}${CYellow}${3} ${CDkGray}[${CYellow}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
else
printf "${InvRed}${CWhite}$insertspc${CClear}${CRed}${3} ${CDkGray}[${CRed}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
fi
elif [ "$5" = "Reverse" ]
then
if [ "$progr" -le 15 ]; then
printf "${InvRed}${CWhite}$insertspc${CClear}${CRed}${3} ${CDkGray}[${CRed}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
elif [ "$progr" -gt 15 ] && [ "$progr" -le 40 ]; then
printf "${InvYellow}${CBlack}$insertspc${CClear}${CYellow}${3} ${CDkGray}[${CYellow}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
else
printf "${InvGreen}${CWhite}$insertspc${CClear}${CWhite}${3}${CGreen} ${CDkGray}[${CGreen}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
fi
elif [ "$5" = "CPU" ]
then
if [ "$progr" -le 80 ]; then
printf "${InvGreen}${CWhite}$insertspc${CClear}${CWhite}${3}${CGreen} ${CDkGray}[${CGreen}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
elif [ "$progr" -gt 80 ] && [ "$progr" -le 90 ]; then
printf "${InvYellow}${CBlack}$insertspc${CClear}${CYellow}${3} ${CDkGray}[${CYellow}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
else
printf "${InvRed}${CWhite}$insertspc${CClear}${CRed}${3} ${CDkGray}[${CRed}%.${barch}s%.${barsp}s${CDkGray}]${CClear} ${CWhite}${InvDkGray}$AltNum ${4} / ${progr}%%\r${CClear}" "$barchars" "$barspaces"
fi
fi
fi
}
# -------------------------------------------------------------------------------------------------------------------------
# Shows a more minimalistic progress bar that indicates seconds/%
##----------------------------------------##
## Modified by Martinski W. [2024-Nov-06] ##
##----------------------------------------##
progressbaroverride()
{
# $1 - number (-1 for clearing the bar)
# $2 - max number
# $3 - system name
# $4 - measurement
# $5 - standard/reverse progressbar
# $6 - alternate display values
# $7 - alternate value for progressbar exceeding 100%
local barch barsp percnt altNum readTimeSec
insertspc=" "
_GetPercent_() { printf "%.1f" "$(echo "$1" | awk "{print $1}")" ; }
_UpdateProgressBar_()
{
if [ "$2" = "Standard" ] && [ "$INITIALBOOT" -eq 0 ]
then
printf " ${CWhite}${InvDkGray}%3d${1} /%5.1f%%${CClear} [${CGreen}e${CClear}=Exit] [Selection? ${InvGreen} ${CClear}${CGreen}] ${pausedTimerDispStr} \r${CClear}" "$altNum" "$percnt"
elif [ "$2" = "Standard" ] && [ "$INITIALBOOT" -eq 1 ]
then
printf "${CDkGray} [${CGreen}%.${barch}s%.${barsp}s${CDkGray}] \r${CClear}" "$barchars" "$barspaces"
fi
}
_PausedTimerHandler_()
{
local keyPress readTimeSec
while "$pausedTimerEnabled"
do
keyPress=''
readTimeSec="$(date +%s)"
read -rsn1 -t 1 keyPress < "$(tty 0>&2)"
if [ "$keyPress" = "X" ]
then
pausedTimerEnabled=false
pausedTimerDispStr="$(printf "%*s" "$pausedTimerMsgLen" ' ')"
break
fi
if [ "$(date +%s)" -lt "$((readTimeSec + 1))" ]
then
stty -icanon min 0 time 5
cat - > /dev/null
fi
done
}
if [ "$1" -eq -1 ]
then
printf "\r $barspaces\r"
else
if [ $# -gt 6 ] && [ -n "$7" ] && [ "$1" -ge "$7" ]
then
barch="$(($7*barlen/$2))"
barsp="$((barlen-barch))"
percnt="$(_GetPercent_ "(100*$1/$2)")"
else
barch="$(($1*barlen/$2))"
barsp="$((barlen-barch))"
percnt="$(_GetPercent_ "(100*$1/$2)")"
fi
if [ $# -gt 5 ] && [ -n "$6" ]; then altNum="$6" ; else altNum="$1" ; fi
_UpdateProgressBar_ "$4" "$5"
if [ "$INITIALBOOT" = "0" ]
then
# Borrowed this wonderful keypress capturing mechanism from @Eibgrad... thank you! :)
readTimeSec="$(date +%s)"
key_press=''; read -rsn1 -t 1 key_press < "$(tty 0>&2)"
if [ "$key_press" ]
then
case "$key_press" in
[Cc]) QueueNetworkConn=1
echo -e "${CClear}[Queuing Network Connection Stats] ";
sleep 1; NextPage=6; timerReset=1
;;
[Dd]) QueueNetworkDiag=1
echo -e "${CClear}[Queuing Network Diagnostics] ";
sleep 1; NextPage=5; timerReset=1
;;
[Ee]) clear; logoNMexit; echo -e "${CClear}"; exit 0
;;
[Hh]) hideoptions=1 ; [ "$hideoptions" != "$prevHideOpts" ] && timerReset=1
;;
[Ii]) QueueSpdTest=1
echo -e "${CClear}[Queuing WAN Speedtest] ";
sleep 1; NextPage=4; timerReset=1
;;
[Ll]) NCView="LAN"; NextPage=6; timerReset=1
;;
[Mm]) _IgnoreKeypresses_ OFF
FromUI=1; vsetup; source "$CFGPATH"
echo -e "\n${CClear}[Returning to the Main UI momentarily] ";
sleep 1; FromUI=0; timerReset=1
;;
[Nn]) timerReset=1
if [ "$NextPage" = "1" ]; then NextPage=2
elif [ "$NextPage" = "2" ]; then NextPage=3
elif [ "$NextPage" = "3" ]; then NextPage=4
elif [ "$NextPage" = "4" ]; then NextPage=5
elif [ "$NextPage" = "5" ]; then NextPage=6
elif [ "$NextPage" = "6" ]; then NextPage=7
elif [ "$NextPage" = "7" ]; then NextPage=1
fi
;;
[Oo]) _IgnoreKeypresses_ OFF ; vlogs ;;
[Pp]) timerReset=1
if [ "$NextPage" = "1" ]; then NextPage=7
elif [ "$NextPage" = "2" ]; then NextPage=1
elif [ "$NextPage" = "3" ]; then NextPage=2
elif [ "$NextPage" = "4" ]; then NextPage=3
elif [ "$NextPage" = "5" ]; then NextPage=4
elif [ "$NextPage" = "6" ]; then NextPage=5
elif [ "$NextPage" = "7" ]; then NextPage=6
fi
;;
[Rr]) if [ "$autorotate" = 0 ]
then autorotate=1; autorotateindicator="ON"
elif [ "$autorotate" = "1" ]
then autorotate=0; autorotateindicator="OFF"
fi
timerReset=1
;;
[Ss]) hideoptions=0 ; [ "$hideoptions" != "$prevHideOpts" ] && timerReset=1
;;
[Tt]) PSView="TCP"; NextPage=5; timerReset=1
;;
[Uu]) PSView="UDP"; NextPage=5; timerReset=1
;;
[Vv]) NCView="VPN"; NextPage=6; timerReset=1
;;
[Ww]) NCView="WAN"; NextPage=6; timerReset=1
;;
X) if "$pausedTimerEnabled"
then
pausedTimerEnabled=false
pausedTimerDispStr="$(printf "%*s" "$pausedTimerMsgLen" ' ')"
else
pausedTimerEnabled=true
pausedTimerDispStr="${CWhite}${InvRed}${pausedTimerMsgStr}${CClear}"
_UpdateProgressBar_ "$4" "$5"
_PausedTimerHandler_
fi
;;
1) QueueVPNSlot1=1
echo -e "${CClear}[Queuing VPN1 Speedtest] ";
sleep 1; NextPage=4; timerReset=1
;;
2) QueueVPNSlot2=1
echo -e "${CClear}[Queuing VPN2 Speedtest] ";
sleep 1; NextPage=4; timerReset=1
;;
3) QueueVPNSlot3=1
echo -e "${CClear}[Queuing VPN3 Speedtest] ";
sleep 1; NextPage=4; timerReset=1
;;
4) QueueVPNSlot4=1
echo -e "${CClear}[Queuing VPN4 Speedtest] ";
sleep 1; NextPage=4; timerReset=1
;;
5) QueueVPNSlot5=1
echo -e "${CClear}[Queuing VPN5 Speedtest] ";
sleep 1; NextPage=4; timerReset=1
;;
[\!]) SortbyOpt="Name"; [ "$SortbyOpt" != "$prevSortByOpt" ] && [ "$NextPage" = "7" ] && timerReset=1 ;;
[\@]) SortbyOpt="IP"; [ "$SortbyOpt" != "$prevSortByOpt" ] && [ "$NextPage" = "7" ] && timerReset=1 ;;
[\#]) SortbyOpt="MAC"; [ "$SortbyOpt" != "$prevSortByOpt" ] && [ "$NextPage" = "7" ] && timerReset=1 ;;
*) ;; ##IGNORE INVALID key presses ##
esac
_IgnoreKeypresses_ ON
if [ "$(date +%s)" -lt "$((readTimeSec + 1))" ]
then
stty -icanon min 0 time 1
cat - > /dev/null
fi
fi
else
## Initial Boot Sequence Loop ##
_ConsumeKeypressBuffer_
fi
fi
}
# -------------------------------------------------------------------------------------------------------------------------
# converttemps converts temp readouts from C to F or K
converttemps () {
# $1 is the incoming C Temp
if [ "$TempUnits" == "F" ]; then
currenttemp=$(awk -v v1=$1 'BEGIN{printf "%0.2f\n", (v1*9)/5+32}' | cut -d . -f 1)
currentrange=212
elif [ "$TempUnits" == "K" ]; then
currenttemp=$(awk -v v1=$1 'BEGIN{printf "%0.2f\n", v1+273}' | cut -d . -f 1)
currentrange=373
elif [ "$TempUnits" == "C" ]; then
currenttemp=$1
currentrange=100
else
# Default to C if someone entered something other than C, F or K
TempUnits="C"
currenttemp=$1
currentrange=100
fi
}
# -------------------------------------------------------------------------------------------------------------------------
# updatecheck downloads the latest update version file from github, and compares it with what's currently installed
updatecheck () {
# Download the latest version file from the source repository
curl --silent --retry 3 "https://raw.githubusercontent.com/ViktorJp/RTRMON/master/version.txt" -o "/jffs/addons/rtrmon.d/version.txt"
if [ -f $DLVERPATH ]
then
# Read in its contents for the current version file
DLVersion=$(cat $DLVERPATH)
# Compare the new version with the old version and log it
if [ "$Beta" == "1" ]; then # Check if Dev/Beta Mode is enabled and disable notification message
UpdateNotify=0
elif [ "$DLVersion" != "$Version" ]; then
DLVersionPF=$(printf "%-8s" $DLVersion)
VersionPF=$(printf "%-8s" $Version)
UpdateNotify="${InvYellow} ${InvDkGray}${CWhite} Update available: v$VersionPF -> v$DLVersionPF ${CClear}"
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new update (v$DLVersion) is available to download" >> $LOGFILE
else
UpdateNotify=0
fi
fi
}
# -------------------------------------------------------------------------------------------------------------------------
# calls the nano text editor to view the RTRMON log file
vlogs() {
export TERM=linux
nano +999999 --linenumbers $LOGFILE
timerReset=1
}
# -------------------------------------------------------------------------------------------------------------------------
# trimlogs will cut down log size (in rows) based on custom value
trimlogs()
{
if [ "$LOGSIZE" -gt 0 ]
then
currlogsize=$(wc -l $LOGFILE | awk '{ print $1 }' ) # Determine the number of rows in the log
if [ "$currlogsize" -gt "$LOGSIZE" ] # If it's bigger than the max allowed, tail/trim it!
then
echo "$(tail -$LOGSIZE $LOGFILE)" > $LOGFILE
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: Trimmed the log file down to $LOGSIZE lines" >> $LOGFILE
fi
fi
}
# -------------------------------------------------------------------------------------------------------------------------
# vconfig guides you through the various configuration options for RTRMON
##----------------------------------------##
## Modified by Martinski W. [2024-Nov-02] ##
##----------------------------------------##
vconfig()
{
_SetUpTimeoutCmdVars_
if [ -f "$CFGPATH" ] #Making sure file exists before proceeding
then
source "$CFGPATH"
CHANGES=0 #track notification to save your changes#
while true
do
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} RTRMON Configuration Options ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please choose from the various options below, which allow you to modify certain${CClear}"
echo -e "${InvGreen} ${CClear} customizable parameters that affect the operation of this script.${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 1)${CClear} : Timer Interval (seconds) : ${CGreen}$Interval"
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 2)${CClear} : Max Internet Download Speed (Mbps) : ${CGreen}$MaxSpeedInet"
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 3)${CClear} : Max Internet Upload Speed (Mbps) : ${CGreen}$MaxSpeedInetUL"
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 4)${CClear} : Max LAN Speed (Mbps) : ${CGreen}$MaxSpeedLAN"
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 5)${CClear} : Max 2.4GHz Speed (Mbps) : ${CGreen}$MaxSpeed24Ghz"
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 6)${CClear} : Max 5GHz Speed (Mbps) : ${CGreen}$MaxSpeed5Ghz"
if [ "$FourBandCustom55624" == "True" ] || [ "$ThreeBand2456" == "True" ] || [ "$FourBandCustom56624" == "True" ]; then
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 7)${CClear} : Max 6GHz Speed (Mbps) : ${CGreen}$MaxSpeed6Ghz"
else
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 7)${CClear} : ${CDkGray}Max 6GHz Speed (Mbps) : N/A"
fi
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 8)${CClear} : Temperature Units (C/F/K) : ${CGreen}$TempUnits"
echo -en "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( 9)${CClear} : Enable Ookla Speedtest? (Y/N) : ${CGreen}"
if [ "$Speedtst" = "0" ]
then printf "No\n"
else printf "Yes\n"
fi
if [ "$spdtestsvrID" == "0" ] && [ "$Speedtst" == "1" ]; then
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}(10)${CClear} : Custom Speedtest Server ID? : ${CGreen}Use Closest"
elif [ "$spdtestsvrID" != "0" ] && [ "$Speedtst" == "1" ]; then
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}(10)${CClear} : Custom Speedtest Server ID? : ${CGreen}$spdtestsvrID"
else
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}(10)${CClear} : Custom Speedtest Server ID? : ${CDkGray}N/A"
fi
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}(11)${CClear} : WAN0 Interface Override? : ${CGreen}$WANOverride"
if [ "$WAN0AltModes" == "0" ]; then WAN0AltModesdisp="No"; else WAN0AltModesdisp="Yes"; fi
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}(12)${CClear} : Mark Router As iMesh Node/Repeater/Bridge? : ${CGreen}$WAN0AltModesdisp"
if [ "$VPNSite2Site" == "0" ]; then VPNSite2Sitedisp="No"; else VPNSite2Sitedisp="Yes"; fi
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}(13)${CClear} : Mark Router As VPN Site-To-Site Only? : ${CGreen}$VPNSite2Sitedisp"
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}(14)${CClear} : Custom Event Log Size? : ${CGreen}$LOGSIZE"
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite} | ${CClear}"
if [ $CHANGES -eq 0 ]; then
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( s)${CClear} : Save Config & Exit"
else
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( s)${CClear} : Save Config & Exit ${CWhite}${InvRed}<-- Save your changes! ${CClear}"
fi
echo -e "${InvGreen} ${CClear} ${InvDkGray}${CWhite}( e)${CClear} : Exit & Discard Changes"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
read -p "Please select? (1-13, s=Save, e=Exit): " ConfigSelection
CHANGES=1
# Execute chosen selections
case "$ConfigSelection" in
1) # -----------------------------------------------------------------------------------------
while true
do
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} Refresh Interval ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please indicate after how many seconds you would like RTRMON to refresh your stats?${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} (Default = 10 seconds)${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo
echo -e "${CClear}Current Refresh Interval: ${CGreen}${Interval}${CClear} seconds"
echo
read -p "Please enter value in seconds [5-999] (e=Exit): " newInterval
if [ -z "$newInterval" ] || echo "$newInterval" | grep -qE "^(e|E)$"
then
if echo "$Interval" | grep -qE "^([1-9][0-9]{0,2})$" && \
[ "$Interval" -ge 5 ] && [ "$Interval" -le 999 ]
then
timer="$Interval"
printf "\n${CClear}[Exiting]\n"
sleep 1 ; break
else
printf "\n${CRed}*ERROR*: Please enter a valid number between 5 and 999.${CClear}\n"
_PressAnyKeyToContinue_
fi
elif echo "$newInterval" | grep -qE "^([1-9][0-9]{0,2})$" && \
[ "$newInterval" -ge 5 ] && [ "$newInterval" -le 999 ]
then
Interval="$newInterval"
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new refresh interval ($Interval) has been selected." >> $LOGFILE
CHANGES=1
timer="$Interval"
printf "\n${CClear}[OK]\n"
sleep 1 ; break
else
printf "\n${CRed}*ERROR*: Please enter a valid number between 5 and 999.${CClear}\n"
_PressAnyKeyToContinue_
fi
done
;;
2) # -----------------------------------------------------------------------------------------
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} Maximum Internet Download Bandwidth ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please indicate what your maximum internet download bandwidth/speed is in Mbps?${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} (Default = 50 Mbps)${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
echo -e "${CClear}Current: ${CGreen}$MaxSpeedInet${CClear} Mbps"
echo ""
read -p 'Please enter value in Mbps (ex: 1000): ' MaxSpeedInet1
MaxSpeedInet2=$(echo $MaxSpeedInet1 | tr -d -c 0-9)
if [ -z "$MaxSpeedInet1" ]; then MaxSpeedInet=50; else MaxSpeedInet=$MaxSpeedInet2; fi
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new Internet Download Bandwidth soeed ($MaxSpeedInet Mbps) has been selected." >> $LOGFILE
;;
3) # -----------------------------------------------------------------------------------------
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} Maximum Internet Upload Bandwidth ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please indicate what your maximum internet upload bandwidth/speed is in Mbps?${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} (Default = 50 Mbps)${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
echo -e "${CClear}Current: ${CGreen}$MaxSpeedInetUL${CClear} Mbps"
echo ""
read -p 'Please enter value in Mbps (ex: 1000): ' MaxSpeedInetUL1
MaxSpeedInetUL2=$(echo $MaxSpeedInetUL1 | tr -d -c 0-9)
if [ -z "$MaxSpeedInetUL1" ]; then MaxSpeedInetUL=50; else MaxSpeedInetUL=$MaxSpeedInetUL2; fi
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new Internet Upload Bandwidth speed ($MaxSpeedInetUL Mbps) has been selected." >> $LOGFILE
;;
4) # -----------------------------------------------------------------------------------------
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} Maximum Local Area Network (LAN) Bandwidth ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please indicate what your maximum LAN bandwidth/speed is in Mbps?${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} (Default = 1000 Mbps)${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
echo -e "${CClear}Current: ${CGreen}$MaxSpeedLAN${CClear} Mbps"
echo ""
read -p 'Please enter value in Mbps (ex: 1000): ' MaxSpeedLAN1
MaxSpeedLAN2=$(echo $MaxSpeedLAN1 | tr -d -c 0-9)
if [ -z "$MaxSpeedLAN1" ]; then MaxSpeedLAN=1000; else MaxSpeedLAN=$MaxSpeedLAN2; fi
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new LAN Bandwidth speed ($MaxSpeedLAN Mbps) has been selected." >> $LOGFILE
;;
5) # -----------------------------------------------------------------------------------------
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} Maximum 2.4GHz Bandwidth Speed ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please indicate what your maximum realistic 2.4GHz speed is in Mbps?${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} (Default = 450 Mbps)${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
echo -e "${CClear}Current: ${CGreen}$MaxSpeed24Ghz${CClear} Mbps"
echo ""
read -p 'Please enter value in Mbps (ex: 1000): ' MaxSpeed24Ghz1
MaxSpeed24Ghz2=$(echo $MaxSpeed24Ghz1 | tr -d -c 0-9)
if [ -z "$MaxSpeed24Ghz1" ]; then MaxSpeed24Ghz=450; else MaxSpeed24Ghz=$MaxSpeed24Ghz2; fi
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new 2.4GHz Bandwidth speed ($MaxSpeed24Ghz Mbps) has been selected." >> $LOGFILE
;;
6) # -----------------------------------------------------------------------------------------
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} Maximum 5GHz Bandwidth Speed ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please indicate what your maximum realistic 5GHz speed is in Mbps?${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} (Default = 780 Mbps)${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
echo -e "${CClear}Current: ${CGreen}$MaxSpeed5Ghz${CClear} Mbps"
echo ""
read -p 'Please enter value in Mbps (ex: 1000): ' MaxSpeed5Ghz1
MaxSpeed5Ghz2=$(echo $MaxSpeed5Ghz1 | tr -d -c 0-9)
if [ -z "$MaxSpeed5Ghz1" ]; then MaxSpeed5Ghz=780; else MaxSpeed5Ghz=$MaxSpeed5Ghz2; fi
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new 5GHz Bandwidth speed ($MaxSpeed5Ghz Mbps) has been selected." >> $LOGFILE
;;
7) # -----------------------------------------------------------------------------------------
clear
if [ "$FourBandCustom55624" == "True" ] || [ "$ThreeBand2456" == "True" ] || [ "$FourBandCustom56624" == "True" ]; then
echo -e "${InvGreen} ${InvDkGray}${CWhite} Maximum 6GHz Bandwidth Speed ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please indicate what your maximum realistic 6GHz speed is in Mbps?${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} (Default = 920 Mbps)${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
echo -e "${CClear}Current: ${CGreen}$MaxSpeed6Ghz${CClear} Mbps"
echo ""
read -p 'Please enter value in Mbps (ex: 1000): ' MaxSpeed6Ghz1
MaxSpeed6Ghz2=$(echo $MaxSpeed6Ghz1 | tr -d -c 0-9)
if [ -z "$MaxSpeed6Ghz1" ]; then MaxSpeed6Ghz=920; else MaxSpeed6Ghz=$MaxSpeed6Ghz2; fi
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new 6GHz Bandwidth speed ($MaxSpeed6Ghz Mbps) has been selected." >> $LOGFILE
else
echo -e "${CRed}This item is currently only available for router models:"
echo -e "GT-AXE11000, GT-AXE16000, RT-BE96U and GT-BE98_Pro"
echo ""
sleep 3
fi
;;
8) # -----------------------------------------------------------------------------------------
while true
do
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} Temperature Unit Preferences ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Please indicate what Temperature Units you would prefer to use?${CClear}"
echo -e "${InvGreen} ${CClear} (C)elcius, (F)ahrenheit or (K)elvin"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} (Default = C)${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
echo -e "${CClear}Current: ${CGreen}$TempUnits${CClear}"
echo ""
read -p 'Temp Units (C/F/K): ' TempUnits1
case "$TempUnits1" in
[Cc]) TempUnits="C" ; break ;;
[Ff]) TempUnits="F" ; break ;;
[Kk]) TempUnits="K" ; break ;;
*)
printf "\n*ERROR*: Please enter a valid option.${CClear}\n"
sleep 2
;;
esac
done
if [ -z "$TempUnits1" ]; then TempUnits="C"; fi
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: A new Temperature Unit ($TempUnits) has been selected." >> $LOGFILE
;;
9) # -----------------------------------------------------------------------------------------
echo ""
if [ -f $OOKLAPATH ]; then
clear
echo -e "${InvGreen} ${InvDkGray}${CWhite} Remove Ookla Speedtest Binaries ${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear} Would you like to disable and uninstall the Ookla Speedtest binaries from RTRMON?${CClear}"
echo -e "${InvGreen} ${CClear}"
echo -e "${InvGreen} ${CClear}${CDkGray}---------------------------------------------------------------------------------------${CClear}"
echo ""
echo -e "${CClear}Current: ${CGreen}Ookla Speedtest Installed${CClear}"
echo ""
echo -e "Remove Speedtest binaries from RTRMON?${CClear}"
if promptyn "[y/n]: "
then
echo ""
echo ""
echo -e "${CClear}Removing Ookla Speedtest binaries..."
rm "/jffs/addons/rtrmon.d/speedtest"
rm "/jffs/addons/rtrmon.d/speedtest.5"
rm "/jffs/addons/rtrmon.d/speedtest.md"
sleep 1
if [ ! -f $OOKLAPATH ]; then
echo ""
echo -e "${CClear}Completed removing Ookla Speedtest binaries..."
echo -e "$(date +'%b %d %Y %X') $(_GetLAN_HostName_) RTRMON[$$] - INFO: Ookla Speedtest binaries have been successfully removed." >> $LOGFILE
Speedtst=0