forked from jackyaz/scMerlin
-
Notifications
You must be signed in to change notification settings - Fork 2
/
scmerlin.sh
2334 lines (2161 loc) · 73.8 KB
/
scmerlin.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
######################################################
## __ __ _ _ ##
## | \/ | | |(_) ##
## ___ ___ | \ / | ___ _ __ | | _ _ __ ##
## / __| / __|| |\/| | / _ \| '__|| || || '_ \ ##
## \__ \| (__ | | | || __/| | | || || | | | ##
## |___/ \___||_| |_| \___||_| |_||_||_| |_| ##
## ##
## https://github.com/jackyaz/scMerlin ##
## ##
######################################################
# Last Modified: 2024-Sep-29
#-----------------------------------------------------
########## Shellcheck directives ###########
# shellcheck disable=SC2016
# shellcheck disable=SC2018
# shellcheck disable=SC2019
# shellcheck disable=SC2059
# shellcheck disable=SC2034
# shellcheck disable=SC2155
# shellcheck disable=SC3043
######################################################
### Start of script variables ###
readonly SCRIPT_NAME="scMerlin"
readonly SCRIPT_NAME_LOWER="$(echo "$SCRIPT_NAME" | tr 'A-Z' 'a-z' | sed 's/d//')"
readonly SCM_VERSION="v2.5.8"
readonly SCRIPT_VERSION="v2.5.8"
SCRIPT_BRANCH="master"
SCRIPT_REPO="https://raw.githubusercontent.com/decoderman/$SCRIPT_NAME/$SCRIPT_BRANCH"
readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME_LOWER.d"
readonly SCRIPT_WEBPAGE_DIR="$(readlink /www/user)"
readonly SCRIPT_WEB_DIR="$SCRIPT_WEBPAGE_DIR/$SCRIPT_NAME_LOWER"
readonly SHARED_DIR="/jffs/addons/shared-jy"
readonly SHARED_REPO="https://raw.githubusercontent.com/decoderman/shared-jy/master"
readonly SHARED_WEB_DIR="$SCRIPT_WEBPAGE_DIR/shared-jy"
readonly NTP_WATCHDOG_FILE="$SCRIPT_DIR/.watchdogenabled"
readonly TAIL_TAINTED_FILE="$SCRIPT_DIR/.tailtaintdnsenabled"
##----------------------------------------##
## Modified by Martinski W. [2024-Jun-07] ##
##----------------------------------------##
readonly NTP_READY_CHECK_KEYN="NTP_Ready_Check"
readonly NTP_READY_CHECK_FILE="NTP_Ready_Config"
readonly NTP_READY_CHECK_CONF="$SCRIPT_DIR/$NTP_READY_CHECK_FILE"
isInteractiveMenuMode=false
if [ -z "$(which crontab)" ]
then cronListCmd="cru l"
else cronListCmd="crontab -l"
fi
[ -z "$(nvram get odmpid)" ] && ROUTER_MODEL="$(nvram get productid)" || ROUTER_MODEL="$(nvram get odmpid)"
ROUTER_MODEL="$(echo "$ROUTER_MODEL" | tr 'a-z' 'A-Z')"
### End of script variables ###
### Start of output format variables ###
readonly CRIT="\\e[41m"
readonly ERR="\\e[31m"
readonly WARN="\\e[33m"
readonly PASS="\\e[32m"
readonly BOLD="\\e[1m"
readonly SETTING="${BOLD}\\e[36m"
readonly CLEARFORMAT="\\e[0m"
##-------------------------------------##
## Added by Martinski W. [2024-Apr-28] ##
##-------------------------------------##
readonly REDct="\033[1;31m\033[1m"
readonly GRNct="\033[1;32m\033[1m"
readonly YLWct="\033[1;33m\033[1m"
readonly CLEARct="\033[0m"
readonly BOLDUNDERLN="\033[1;4m"
### End of output format variables ###
##----------------------------------------##
## Modified by Martinski W. [2024-Jun-03] ##
##----------------------------------------##
readonly BEGIN_InsertTag="/\*\*BEGIN:scMerlin\*\*/"
readonly ENDIN_InsertTag="/\*\*END:scMerlin\*\*/"
readonly SUPPORTstr="$(nvram get rc_support)"
Band_24G_Support=false
Band_5G_1_Support=false
Band_5G_2_support=false
Band_6G_1_Support=false
Band_6G_2_Support=false
if echo "$SUPPORTstr" | grep -qw '2.4G'
then Band_24G_Support=true ; fi
if echo "$SUPPORTstr" | grep -qw '5G'
then Band_5G_1_Support=true ; fi
if echo "$SUPPORTstr" | grep -qw 'wifi6e'
then Band_6G_1_Support=true ; fi
##-------------------------------------##
## Added by Martinski W. [2024-Jun-04] ##
##-------------------------------------##
_GetWiFiBandsSupported_()
{
local wifiIFNameList wifiIFName wifiBandInfo wifiBandName
local wifi5GHzCount=0 wifi6GHzCount=0
wifiIFNameList="$(nvram get wl_ifnames)"
if [ -z "$wifiIFNameList" ]
then
printf "\n**ERROR**: WiFi Interface List is *NOT* found.\n"
return 1
fi
for wifiIFName in $wifiIFNameList
do
wifiBandInfo="$(wl -i "$wifiIFName" status 2>/dev/null | grep 'Chanspec:')"
if [ -z "$wifiBandInfo" ]
then
printf "\n**ERROR**: Could not find 'Chanspec' for WiFi Interface [$wifiIFName].\n"
continue
fi
wifiBandName="$(echo "$wifiBandInfo" | awk -F ' ' '{print $2}')"
case "$wifiBandName" in
2.4GHz) Band_24G_Support=true
;;
5GHz) let wifi5GHzCount++
[ "$wifi5GHzCount" -eq 1 ] && Band_5G_1_Support=true
[ "$wifi5GHzCount" -eq 2 ] && Band_5G_2_support=true
;;
6GHz) let wifi6GHzCount++
[ "$wifi6GHzCount" -eq 1 ] && Band_6G_1_Support=true
[ "$wifi6GHzCount" -eq 2 ] && Band_6G_2_Support=true
;;
*) printf "\nWiFi Interface=[$wifiIFName], WiFi Band=[$wifiBandName]\n"
;;
esac
done
}
_GetWiFiBandsSupported_
##----------------------------------------##
## Modified by Martinski W. [2024-Jun-07] ##
##----------------------------------------##
GetIFaceName()
{
if [ $# -eq 0 ] || [ -z "$1" ] ; then echo "" ; return 1 ; fi
theIFnamePrefix=""
case "$1" in
"2.4GHz")
if "$Band_24G_Support"
then
if [ "$ROUTER_MODEL" = "GT-BE98" ] || \
[ "$ROUTER_MODEL" = "GT-BE98_PRO" ] || \
[ "$ROUTER_MODEL" = "GT-AXE16000" ]
then theIFnamePrefix="wl3"
else theIFnamePrefix="wl0"
fi
fi
;;
"5GHz_1")
if "$Band_5G_1_Support"
then
if [ "$ROUTER_MODEL" = "GT-BE98" ] || \
[ "$ROUTER_MODEL" = "GT-BE98_PRO" ] || \
[ "$ROUTER_MODEL" = "GT-AXE16000" ]
then theIFnamePrefix="wl0"
else theIFnamePrefix="wl1"
fi
fi
;;
"5GHz_2")
if "$Band_5G_2_support"
then
if [ "$ROUTER_MODEL" = "GT-BE98" ] || \
[ "$ROUTER_MODEL" = "GT-AXE16000" ]
then theIFnamePrefix="wl1"
else theIFnamePrefix="wl2"
fi
fi
;;
"6GHz_1")
if "$Band_6G_1_Support"
then
if [ "$ROUTER_MODEL" = "GT-BE98_PRO" ]
then theIFnamePrefix="wl1"
else theIFnamePrefix="wl2"
fi
fi
;;
"6GHz_2")
if "$Band_6G_2_Support" || \
[ "$ROUTER_MODEL" = "GT-BE98_PRO" ]
then theIFnamePrefix="wl2" ; fi
;;
esac
if [ -z "$theIFnamePrefix" ]
then echo ""
else echo "$(nvram get "${theIFnamePrefix}_ifname")"
fi
}
##-------------------------------------##
## Added by Martinski W. [2023-Jun-02] ##
##-------------------------------------##
GetTemperatureValue()
{
theIFname="$(GetIFaceName "$1")"
if [ -z "$theIFname" ]
then echo "[N/A]"
else echo "$(wl -i "$theIFname" phy_tempsense | awk '{print $1/2+20}')"
fi
}
# $1 = print to syslog, $2 = message to print, $3 = log level
Print_Output(){
if [ "$1" = "true" ]; then
logger -t "$SCRIPT_NAME" "$2"
fi
printf "${BOLD}${3}%s${CLEARFORMAT}\\n\\n" "$2"
}
Firmware_Version_Check(){
if nvram get rc_support | grep -qF "am_addons"; then
return 0
else
return 1
fi
}
### Code for these functions inspired by https://github.com/Adamm00 - credit to @Adamm ###
Check_Lock(){
if [ -f "/tmp/$SCRIPT_NAME_LOWER.lock" ]; then
ageoflock=$(($(date +%s) - $(date +%s -r "/tmp/$SCRIPT_NAME_LOWER.lock")))
if [ "$ageoflock" -gt 60 ]; then
Print_Output true "Stale lock file found (>60 seconds old) - purging lock" "$ERR"
kill "$(sed -n '1p' "/tmp/$SCRIPT_NAME_LOWER.lock")" >/dev/null 2>&1
Clear_Lock
echo "$$" > "/tmp/$SCRIPT_NAME_LOWER.lock"
return 0
else
Print_Output true "Lock file found (age: $ageoflock seconds)" "$ERR"
if [ -z "$1" ]; then
exit 1
else
return 1
fi
fi
else
echo "$$" > "/tmp/$SCRIPT_NAME_LOWER.lock"
return 0
fi
}
Clear_Lock(){
rm -f "/tmp/$SCRIPT_NAME_LOWER.lock" 2>/dev/null
return 0
}
##############################################
Set_Version_Custom_Settings(){
SETTINGSFILE="/jffs/addons/custom_settings.txt"
case "$1" in
local)
if [ -f "$SETTINGSFILE" ]; then
if [ "$(grep -c "scmerlin_version_local" $SETTINGSFILE)" -gt 0 ]; then
if [ "$2" != "$(grep "scmerlin_version_local" /jffs/addons/custom_settings.txt | cut -f2 -d' ')" ]; then
sed -i "s/scmerlin_version_local.*/scmerlin_version_local $2/" "$SETTINGSFILE"
fi
else
echo "scmerlin_version_local $2" >> "$SETTINGSFILE"
fi
else
echo "scmerlin_version_local $2" >> "$SETTINGSFILE"
fi
;;
server)
if [ -f "$SETTINGSFILE" ]; then
if [ "$(grep -c "scmerlin_version_server" $SETTINGSFILE)" -gt 0 ]; then
if [ "$2" != "$(grep "scmerlin_version_server" /jffs/addons/custom_settings.txt | cut -f2 -d' ')" ]; then
sed -i "s/scmerlin_version_server.*/scmerlin_version_server $2/" "$SETTINGSFILE"
fi
else
echo "scmerlin_version_server $2" >> "$SETTINGSFILE"
fi
else
echo "scmerlin_version_server $2" >> "$SETTINGSFILE"
fi
;;
esac
}
Update_Check(){
echo 'var updatestatus = "InProgress";' > "$SCRIPT_WEB_DIR/detect_update.js"
doupdate="false"
localver=$(grep "SCRIPT_VERSION=" "/jffs/scripts/$SCRIPT_NAME_LOWER" | grep -m1 -oE 'v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})')
/usr/sbin/curl -fsL --retry 3 "$SCRIPT_REPO/$SCRIPT_NAME_LOWER.sh" | grep -qF "jackyaz" || { Print_Output true "404 error detected - stopping update" "$ERR"; return 1; }
serverver=$(/usr/sbin/curl -fsL --retry 3 "$SCRIPT_REPO/$SCRIPT_NAME_LOWER.sh" | grep "SCRIPT_VERSION=" | grep -m1 -oE 'v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})')
if [ "$localver" != "$serverver" ]; then
doupdate="version"
Set_Version_Custom_Settings server "$serverver"
echo 'var updatestatus = "'"$serverver"'";' > "$SCRIPT_WEB_DIR/detect_update.js"
else
localmd5="$(md5sum "/jffs/scripts/$SCRIPT_NAME_LOWER" | awk '{print $1}')"
remotemd5="$(curl -fsL --retry 3 "$SCRIPT_REPO/$SCRIPT_NAME_LOWER.sh" | md5sum | awk '{print $1}')"
if [ "$localmd5" != "$remotemd5" ]; then
doupdate="md5"
Set_Version_Custom_Settings server "$serverver-hotfix"
echo 'var updatestatus = "'"$serverver-hotfix"'";' > "$SCRIPT_WEB_DIR/detect_update.js"
fi
fi
if [ "$doupdate" = "false" ]; then
echo 'var updatestatus = "None";' > "$SCRIPT_WEB_DIR/detect_update.js"
fi
echo "$doupdate,$localver,$serverver"
}
Update_Version()
{
if [ $# -eq 0 ] || [ -z "$1" ]
then
updatecheckresult="$(Update_Check)"
isupdate="$(echo "$updatecheckresult" | cut -f1 -d',')"
localver="$(echo "$updatecheckresult" | cut -f2 -d',')"
serverver="$(echo "$updatecheckresult" | cut -f3 -d',')"
if [ "$isupdate" = "version" ]; then
Print_Output true "New version of $SCRIPT_NAME available - $serverver" "$PASS"
elif [ "$isupdate" = "md5" ]; then
Print_Output true "MD5 hash of $SCRIPT_NAME does not match - hotfix available - $serverver" "$PASS"
fi
if [ "$isupdate" != "false" ]; then
printf "\\n${BOLD}Do you want to continue with the update? (y/n)${CLEARFORMAT} "
read -r confirm
case "$confirm" in
y|Y)
printf "\\n"
Update_File shared-jy.tar.gz
Update_File scmerlin_www.asp
Update_File sitemap.asp
Update_File tailtop
Update_File tailtopd
Update_File tailtaintdns
Update_File tailtaintdnsd
Update_File sc.func
Update_File S99tailtop
Update_File S95tailtaintdns
Download_File "$SCRIPT_REPO/$SCRIPT_NAME_LOWER.sh" "/jffs/scripts/$SCRIPT_NAME_LOWER" && Print_Output true "$SCRIPT_NAME successfully updated"
chmod 0755 "/jffs/scripts/$SCRIPT_NAME_LOWER"
Set_Version_Custom_Settings local "$serverver"
Set_Version_Custom_Settings server "$serverver"
Clear_Lock
PressEnter
exec "$0"
exit 0
;;
*)
printf "\\n"
Clear_Lock
return 1
;;
esac
else
Print_Output true "No updates available - latest is $localver" "$WARN"
Clear_Lock
fi
fi
if [ "$1" = "force" ]
then
serverver=$(/usr/sbin/curl -fsL --retry 3 "$SCRIPT_REPO/$SCRIPT_NAME_LOWER.sh" | grep "SCRIPT_VERSION=" | grep -m1 -oE 'v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})')
Print_Output true "Downloading latest version ($serverver) of $SCRIPT_NAME" "$PASS"
Update_File shared-jy.tar.gz
Update_File scmerlin_www.asp
Update_File sitemap.asp
Update_File tailtop
Update_File tailtopd
Update_File tailtaintdns
Update_File tailtaintdnsd
Update_File sc.func
Update_File S99tailtop
Update_File S95tailtaintdns
Download_File "$SCRIPT_REPO/$SCRIPT_NAME_LOWER.sh" "/jffs/scripts/$SCRIPT_NAME_LOWER" && Print_Output true "$SCRIPT_NAME successfully updated"
chmod 0755 "/jffs/scripts/$SCRIPT_NAME_LOWER"
Set_Version_Custom_Settings local "$serverver"
Set_Version_Custom_Settings server "$serverver"
Clear_Lock
if [ -z "$2" ]; then
PressEnter
exec "$0"
elif [ "$2" = "unattended" ]; then
exec "$0" postupdate
fi
exit 0
fi
}
Update_File(){
if [ "$1" = "scmerlin_www.asp" ] || [ "$1" = "sitemap.asp" ] ; then
tmpfile="/tmp/$1"
Download_File "$SCRIPT_REPO/$1" "$tmpfile"
if ! diff -q "$tmpfile" "$SCRIPT_DIR/$1" >/dev/null 2>&1; then
if [ -f "$SCRIPT_DIR/$1" ]; then
Get_WebUI_Page "$SCRIPT_DIR/$1"
sed -i "\\~$MyPage~d" /tmp/menuTree.js
rm -f "$SCRIPT_WEBPAGE_DIR/$MyPage" 2>/dev/null
fi
Download_File "$SCRIPT_REPO/$1" "$SCRIPT_DIR/$1"
Print_Output true "New version of $1 downloaded" "$PASS"
Mount_WebUI
fi
rm -f "$tmpfile"
elif [ "$1" = "shared-jy.tar.gz" ]; then
if [ ! -f "$SHARED_DIR/$1.md5" ]; then
Download_File "$SHARED_REPO/$1" "$SHARED_DIR/$1"
Download_File "$SHARED_REPO/$1.md5" "$SHARED_DIR/$1.md5"
tar -xzf "$SHARED_DIR/$1" -C "$SHARED_DIR"
rm -f "$SHARED_DIR/$1"
Print_Output true "New version of $1 downloaded" "$PASS"
else
localmd5="$(cat "$SHARED_DIR/$1.md5")"
remotemd5="$(curl -fsL --retry 3 "$SHARED_REPO/$1.md5")"
if [ "$localmd5" != "$remotemd5" ]; then
Download_File "$SHARED_REPO/$1" "$SHARED_DIR/$1"
Download_File "$SHARED_REPO/$1.md5" "$SHARED_DIR/$1.md5"
tar -xzf "$SHARED_DIR/$1" -C "$SHARED_DIR"
rm -f "$SHARED_DIR/$1"
Print_Output true "New version of $1 downloaded" "$PASS"
fi
fi
elif [ "$1" = "S99tailtop" ]; then
tmpfile="/tmp/$1"
Download_File "$SCRIPT_REPO/$1" "$tmpfile"
if ! diff -q "$tmpfile" "$SCRIPT_DIR/$1" >/dev/null 2>&1; then
if [ -f "$SCRIPT_DIR/S99tailtop" ]; then
"$SCRIPT_DIR/S99tailtop" stop >/dev/null 2>&1
sleep 2
fi
Download_File "$SCRIPT_REPO/$1" "$SCRIPT_DIR/$1"
chmod 0755 "$SCRIPT_DIR/$1"
"$SCRIPT_DIR/S99tailtop" start >/dev/null 2>&1
Print_Output true "New version of $1 downloaded" "$PASS"
fi
rm -f "$tmpfile"
elif [ "$1" = "tailtop" ] || [ "$1" = "tailtopd" ]; then
tmpfile="/tmp/$1"
Download_File "$SCRIPT_REPO/$1" "$tmpfile"
if ! diff -q "$tmpfile" "$SCRIPT_DIR/$1" >/dev/null 2>&1; then
if [ -f "$SCRIPT_DIR/S99tailtop" ]; then
"$SCRIPT_DIR/S99tailtop" stop >/dev/null 2>&1
sleep 2
fi
Download_File "$SCRIPT_REPO/$1" "$SCRIPT_DIR/$1"
chmod 0755 "$SCRIPT_DIR/$1"
"$SCRIPT_DIR/S99tailtop" start >/dev/null 2>&1
Print_Output true "New version of $1 downloaded" "$PASS"
fi
rm -f "$tmpfile"
elif [ "$1" = "S95tailtaintdns" ]; then
tmpfile="/tmp/$1"
Download_File "$SCRIPT_REPO/$1" "$tmpfile"
if ! diff -q "$tmpfile" "$SCRIPT_DIR/$1" >/dev/null 2>&1; then
if [ -f "$SCRIPT_DIR/S95tailtaintdns" ]; then
"$SCRIPT_DIR/S95tailtaintdns" stop >/dev/null 2>&1
sleep 2
fi
Download_File "$SCRIPT_REPO/$1" "$SCRIPT_DIR/$1"
chmod 0755 "$SCRIPT_DIR/$1"
if [ "$(NTP_BootWatchdog status)" = "ENABLED" ]; then
"$SCRIPT_DIR/S95tailtaintdns" start >/dev/null 2>&1
fi
Print_Output true "New version of $1 downloaded" "$PASS"
fi
rm -f "$tmpfile"
elif [ "$1" = "tailtaintdns" ] || [ "$1" = "tailtaintdnsd" ]; then
tmpfile="/tmp/$1"
Download_File "$SCRIPT_REPO/$1" "$tmpfile"
if ! diff -q "$tmpfile" "$SCRIPT_DIR/$1" >/dev/null 2>&1; then
if [ -f "$SCRIPT_DIR/S95tailtaintdns" ]; then
"$SCRIPT_DIR/S95tailtaintdns" stop >/dev/null 2>&1
sleep 2
fi
Download_File "$SCRIPT_REPO/$1" "$SCRIPT_DIR/$1"
chmod 0755 "$SCRIPT_DIR/$1"
if [ "$(NTP_BootWatchdog status)" = "ENABLED" ]; then
"$SCRIPT_DIR/S95tailtaintdns" start >/dev/null 2>&1
fi
Print_Output true "New version of $1 downloaded" "$PASS"
fi
rm -f "$tmpfile"
elif [ "$1" = "sc.func" ]; then
tmpfile="/tmp/$1"
Download_File "$SCRIPT_REPO/$1" "$tmpfile"
if ! diff -q "$tmpfile" "$SCRIPT_DIR/$1" >/dev/null 2>&1; then
Download_File "$SCRIPT_REPO/$1" "$SCRIPT_DIR/$1"
chmod 0755 "$SCRIPT_DIR/$1"
Print_Output true "New version of $1 downloaded" "$PASS"
fi
rm -f "$tmpfile"
else
return 1
fi
}
Validate_Number(){
if [ "$1" -eq "$1" ] 2>/dev/null; then
return 0
else
return 1
fi
}
Create_Dirs(){
if [ ! -d "$SCRIPT_DIR" ]; then
mkdir -p "$SCRIPT_DIR"
fi
if [ ! -d "$SHARED_DIR" ]; then
mkdir -p "$SHARED_DIR"
fi
if [ ! -d "$SCRIPT_WEBPAGE_DIR" ]; then
mkdir -p "$SCRIPT_WEBPAGE_DIR"
fi
if [ ! -d "$SCRIPT_WEB_DIR" ]; then
mkdir -p "$SCRIPT_WEB_DIR"
fi
}
##----------------------------------------##
## Modified by Martinski W. [2024-Apr-28] ##
##----------------------------------------##
Create_Symlinks()
{
rm -rf "${SCRIPT_WEB_DIR:?}/"* 2>/dev/null
ln -s /tmp/scmerlin-top "$SCRIPT_WEB_DIR/top.htm" 2>/dev/null
ln -s /tmp/addonwebpages.tmp "$SCRIPT_WEB_DIR/addonwebpages.htm" 2>/dev/null
ln -s /tmp/scmcronjobs.tmp "$SCRIPT_WEB_DIR/scmcronjobs.htm" 2>/dev/null
ln -s "$NTP_WATCHDOG_FILE" "$SCRIPT_WEB_DIR/watchdogenabled.htm" 2>/dev/null
ln -s "$NTP_READY_CHECK_CONF" "$SCRIPT_WEB_DIR/${NTP_READY_CHECK_FILE}.htm" 2>/dev/null
ln -s "$TAIL_TAINTED_FILE" "$SCRIPT_WEB_DIR/tailtaintdnsenabled.htm" 2>/dev/null
if [ ! -d "$SHARED_WEB_DIR" ]; then
ln -s "$SHARED_DIR" "$SHARED_WEB_DIR" 2>/dev/null
fi
}
Auto_ServiceEvent(){
case $1 in
create)
if [ -f /jffs/scripts/service-event ]; then
STARTUPLINECOUNT=$(grep -c '# '"$SCRIPT_NAME" /jffs/scripts/service-event)
STARTUPLINECOUNTEX=$(grep -cx 'if echo "$2" | /bin/grep -q "'"$SCRIPT_NAME_LOWER"'"; then { /jffs/scripts/'"$SCRIPT_NAME_LOWER"' service_event "$@" & }; fi # '"$SCRIPT_NAME" /jffs/scripts/service-event)
if [ "$STARTUPLINECOUNT" -gt 1 ] || { [ "$STARTUPLINECOUNTEX" -eq 0 ] && [ "$STARTUPLINECOUNT" -gt 0 ]; }; then
sed -i -e '/# '"$SCRIPT_NAME"'/d' /jffs/scripts/service-event
fi
if [ "$STARTUPLINECOUNTEX" -eq 0 ]; then
echo 'if echo "$2" | /bin/grep -q "'"$SCRIPT_NAME_LOWER"'"; then { /jffs/scripts/'"$SCRIPT_NAME_LOWER"' service_event "$@" & }; fi # '"$SCRIPT_NAME" >> /jffs/scripts/service-event
fi
else
echo "#!/bin/sh" > /jffs/scripts/service-event
echo "" >> /jffs/scripts/service-event
echo 'if echo "$2" | /bin/grep -q "'"$SCRIPT_NAME_LOWER"'"; then { /jffs/scripts/'"$SCRIPT_NAME_LOWER"' service_event "$@" & }; fi # '"$SCRIPT_NAME" >> /jffs/scripts/service-event
chmod 0755 /jffs/scripts/service-event
fi
;;
delete)
if [ -f /jffs/scripts/service-event ]; then
STARTUPLINECOUNT=$(grep -i -c '# '"$SCRIPT_NAME" /jffs/scripts/service-event)
if [ "$STARTUPLINECOUNT" -gt 0 ]; then
sed -i -e '/# '"$SCRIPT_NAME"'/d' /jffs/scripts/service-event
fi
fi
;;
esac
}
##----------------------------------------##
## Modified by Martinski W. [2024-Mar-12] ##
##----------------------------------------##
Auto_Startup(){
case $1 in
create)
if [ -f /jffs/scripts/post-mount ]; then
STARTUPLINECOUNT=$(grep -i -c '# '"$SCRIPT_NAME$" /jffs/scripts/post-mount)
if [ "$STARTUPLINECOUNT" -gt 0 ]; then
sed -i -e '/# '"$SCRIPT_NAME$"'/d' /jffs/scripts/post-mount
fi
fi
if [ -f /jffs/scripts/services-start ]; then
## Clean up erroneous entries ##
grep -iq '# '"${SCRIPT_NAME}[$]$" /jffs/scripts/services-start && \
sed -i -e '/# '"${SCRIPT_NAME}[$]$"'/d' /jffs/scripts/services-start
STARTUPLINECOUNT=$(grep -i -c '# '"$SCRIPT_NAME$" /jffs/scripts/services-start)
STARTUPLINECOUNTEX=$(grep -i -cx "/jffs/scripts/$SCRIPT_NAME_LOWER startup"' & # '"$SCRIPT_NAME$" /jffs/scripts/services-start)
if [ "$STARTUPLINECOUNT" -gt 1 ] || { [ "$STARTUPLINECOUNTEX" -eq 0 ] && [ "$STARTUPLINECOUNT" -gt 0 ]; }; then
sed -i -e '/# '"$SCRIPT_NAME$"'/d' /jffs/scripts/services-start
fi
if [ "$STARTUPLINECOUNTEX" -eq 0 ]; then
echo "/jffs/scripts/$SCRIPT_NAME_LOWER startup"' & # '"$SCRIPT_NAME" >> /jffs/scripts/services-start
fi
else
echo "#!/bin/sh" > /jffs/scripts/services-start
echo "" >> /jffs/scripts/services-start
echo "/jffs/scripts/$SCRIPT_NAME_LOWER startup"' & # '"$SCRIPT_NAME" >> /jffs/scripts/services-start
chmod 0755 /jffs/scripts/services-start
fi
;;
delete)
if [ -f /jffs/scripts/post-mount ]; then
STARTUPLINECOUNT=$(grep -i -c '# '"$SCRIPT_NAME$" /jffs/scripts/post-mount)
if [ "$STARTUPLINECOUNT" -gt 0 ]; then
sed -i -e '/# '"$SCRIPT_NAME$"'/d' /jffs/scripts/post-mount
fi
fi
if [ -f /jffs/scripts/services-start ]; then
## Clean up erroneous entries ##
grep -iq '# '"${SCRIPT_NAME}[$]$" /jffs/scripts/services-start && \
sed -i -e '/# '"${SCRIPT_NAME}[$]$"'/d' /jffs/scripts/services-start
STARTUPLINECOUNT=$(grep -i -c '# '"$SCRIPT_NAME$" /jffs/scripts/services-start)
if [ "$STARTUPLINECOUNT" -gt 0 ]; then
sed -i -e '/# '"$SCRIPT_NAME$"'/d' /jffs/scripts/services-start
fi
fi
;;
esac
}
Download_File(){
/usr/sbin/curl -fsL --retry 3 "$1" -o "$2"
}
Get_WebUI_Page(){
MyPage="none"
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
page="/www/user/user$i.asp"
if [ -f "$page" ] && [ "$(md5sum < "$1")" = "$(md5sum < "$page")" ]; then
MyPage="user$i.asp"
return
elif [ "$MyPage" = "none" ] && [ ! -f "$page" ]; then
MyPage="user$i.asp"
fi
done
}
### function based on @dave14305's FlexQoS webconfigpage function ###
Get_WebUI_URL(){
urlpage=""
urlproto=""
urldomain=""
urlport=""
urlpage="$(sed -nE "/$SCRIPT_NAME/ s/.*url\: \"(user[0-9]+\.asp)\".*/\1/p" /tmp/menuTree.js)"
if [ "$(nvram get http_enable)" -eq 1 ]; then
urlproto="https"
else
urlproto="http"
fi
if [ -n "$(nvram get lan_domain)" ]; then
urldomain="$(nvram get lan_hostname).$(nvram get lan_domain)"
else
urldomain="$(nvram get lan_ipaddr)"
fi
if [ "$(nvram get ${urlproto}_lanport)" -eq 80 ] || [ "$(nvram get ${urlproto}_lanport)" -eq 443 ]; then
urlport=""
else
urlport=":$(nvram get ${urlproto}_lanport)"
fi
if echo "$urlpage" | grep -qE "user[0-9]+\.asp"; then
echo "${urlproto}://${urldomain}${urlport}/${urlpage}" | tr "A-Z" "a-z"
else
echo "WebUI page not found"
fi
}
### ###
##----------------------------------------##
## Modified by Martinski W. [2023-Jun-09] ##
##----------------------------------------##
### locking mechanism code credit to Martineau (@MartineauUK) ###
Mount_WebUI(){
realpage=""
Print_Output true "Mounting WebUI tabs for $SCRIPT_NAME" "$PASS"
LOCKFILE=/tmp/addonwebui.lock
FD=386
eval exec "$FD>$LOCKFILE"
flock -x "$FD"
Get_WebUI_Page "$SCRIPT_DIR/scmerlin_www.asp"
if [ "$MyPage" = "none" ]; then
Print_Output true "Unable to mount $SCRIPT_NAME WebUI page, exiting" "$CRIT"
flock -u "$FD"
return 1
fi
cp -f "$SCRIPT_DIR/scmerlin_www.asp" "$SCRIPT_WEBPAGE_DIR/$MyPage"
echo "$SCRIPT_NAME" > "$SCRIPT_WEBPAGE_DIR/$(echo $MyPage | cut -f1 -d'.').title"
if [ "$(uname -o)" = "ASUSWRT-Merlin" ]; then
if [ ! -f /tmp/index_style.css ]; then
cp -f /www/index_style.css /tmp/
fi
if ! grep -q '.menu_Addons' /tmp/index_style.css ; then
echo ".menu_Addons { background: url(ext/shared-jy/addons.png); background-size: contain; }" >> /tmp/index_style.css
fi
if grep -q '.menu_Addons' /tmp/index_style.css && ! grep -q 'url(ext/shared-jy/addons.png); background-size: contain;' /tmp/index_style.css; then
sed -i 's/addons.png);/addons.png); background-size: contain;/' /tmp/index_style.css
fi
if grep -q '.dropdown-content {display: block;}' /tmp/index_style.css ; then
sed -i '/dropdown-content/d' /tmp/index_style.css
fi
if ! grep -q '.dropdown-content {visibility: visible;}' /tmp/index_style.css ; then
{
echo ".dropdown-content {top: 0px; left: 185px; visibility: hidden; position: absolute; background-color: #3a4042; min-width: 165px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1000;}"
echo ".dropdown-content a {padding: 6px 8px; text-decoration: none; display: block; height: 100%; min-height: 20px; max-height: 40px; font-weight: bold; text-shadow: 1px 1px 0px black; font-family: Verdana, MS UI Gothic, MS P Gothic, Microsoft Yahei UI, sans-serif; font-size: 12px; border: 1px solid #6B7071;}"
echo ".dropdown-content a:hover {background-color: #77a5c6;}"
echo ".dropdown:hover .dropdown-content {visibility: visible;}"
} >> /tmp/index_style.css
fi
umount /www/index_style.css 2>/dev/null
mount -o bind /tmp/index_style.css /www/index_style.css
if [ ! -f /tmp/menuTree.js ]; then
cp -f /www/require/modules/menuTree.js /tmp/
fi
sed -i "\\~$MyPage~d" /tmp/menuTree.js
## Use the same BEGIN/END insert tags here as those used in the "Menu_Uninstall()" function ##
if ! grep -qE '^menuName: "Addons"' /tmp/menuTree.js
then
lineinsbefore="$(($(grep -n "^exclude:" /tmp/menuTree.js | cut -f1 -d':') - 1))"
sed -i "$lineinsbefore""i\
${BEGIN_InsertTag}\n\
,\n{\n\
menuName: \"Addons\",\n\
index: \"menu_Addons\",\n\
tab: [\n\
{url: \"javascript:var helpwindow=window.open('\/ext\/shared-jy\/redirect.htm')\", tabName: \"Help & Support\"},\n\
{url: \"NULL\", tabName: \"__INHERIT__\"}\n\
]\n}\n\
${ENDIN_InsertTag}" /tmp/menuTree.js
fi
sed -i "/url: \"javascript:var helpwindow=window.open('\/ext\/shared-jy\/redirect.htm'/i {url: \"$MyPage\", tabName: \"$SCRIPT_NAME\"}," /tmp/menuTree.js
realpage="$MyPage"
if [ -f "$SCRIPT_DIR/sitemap.asp" ]; then
Get_WebUI_Page "$SCRIPT_DIR/sitemap.asp"
if [ "$MyPage" = "none" ]; then
Print_Output true "Unable to mount $SCRIPT_NAME sitemap page, exiting" "$CRIT"
flock -u "$FD"
return 1
fi
cp -f "$SCRIPT_DIR/sitemap.asp" "$SCRIPT_WEBPAGE_DIR/$MyPage"
sed -i "\\~$MyPage~d" /tmp/menuTree.js
sed -i "/url: \"javascript:var helpwindow=window.open('\/ext\/shared-jy\/redirect.htm'/a {url: \"$MyPage\", tabName: \"Sitemap\"}," /tmp/menuTree.js
umount /www/state.js 2>/dev/null
cp -f /www/state.js /tmp/
sed -i 's~<td width=\\"335\\" id=\\"bottom_help_link\\" align=\\"left\\">~<td width=\\"335\\" id=\\"bottom_help_link\\" align=\\"left\\"><a style=\\"font-weight: bolder;text-decoration:underline;cursor:pointer;\\" href=\\"\/'"$MyPage"'\\" target=\\"_blank\\">Sitemap<\/a>\ \|\ ~' /tmp/state.js
cat << 'EOF' >> /tmp/state.js
var myMenu = [];
function AddDropdowns(){
if(myMenu.length == 0){
setTimeout(AddDropdowns,1000);
return;
}
for(var i = 0; i < myMenu.length; i++){
var sitemapstring = '<div class="dropdown-content">';
for(var i2 = 0; i2 < myMenu[i].tabs.length; i2++){
if(myMenu[i].tabs[i2].tabName == '__HIDE__'){
continue;
}
var tabname = myMenu[i].tabs[i2].tabName;
var taburl = myMenu[i].tabs[i2].url;
if(tabname == '__INHERIT__'){
tabname = taburl.split('.')[0];
}
if(taburl.indexOf('redirect.htm') != -1){
taburl = '/ext/shared-jy/redirect.htm';
}
sitemapstring += '<a href="'+taburl+'">'+tabname+'</a>';
}
document.getElementsByClassName(myMenu[i].index)[0].parentElement.parentElement.parentElement.parentElement.parentElement.innerHTML += sitemapstring;
document.getElementsByClassName(myMenu[i].index)[0].parentElement.parentElement.parentElement.parentElement.parentElement.classList.add('dropdown');
}
}
function GenerateSiteMap(showurls){
myMenu = [];
if(typeof menuList == 'undefined' || menuList == null){
setTimeout(GenerateSiteMap,1000,false);
return;
}
for(var i = 0; i < menuList.length; i++){
var myobj = {};
myobj.menuName = menuList[i].menuName;
myobj.index = menuList[i].index;
var myTabs = menuList[i].tab.filter(function(item){
return !menuExclude.tabs.includes(item.url);
});
myTabs = myTabs.filter(function(item){
if(item.tabName == '__INHERIT__' && item.url == 'NULL'){
return false;
}
else{
return true;
}
});
myTabs = myTabs.filter(function(item){
if(item.tabName == '__HIDE__' && item.url == 'NULL'){
return false;
}
else{
return true;
}
});
myTabs = myTabs.filter(function(item){
return item.url.indexOf('TrafficMonitor_dev') == -1;
});
myTabs = myTabs.filter(function(item){
return item.url != 'AdaptiveQoS_Adaptive.asp';
});
myobj.tabs = myTabs;
myMenu.push(myobj);
}
myMenu = myMenu.filter(function(item) {
return !menuExclude.menus.includes(item.index);
});
myMenu = myMenu.filter(function(item) {
return item.index != 'menu_Split';
});
var sitemapstring = '';
for(var i = 0; i < myMenu.length; i++){
if(myMenu[i].tabs[0].tabName == '__HIDE__' && myMenu[i].tabs[0].url != 'NULL'){
if(showurls == true){
sitemapstring += '<span style="font-size:14px;background-color:#4D595D;"><b><a style="color:#FFCC00;background-color:#4D595D;" href="'+myMenu[i].tabs[0].url+'" target="_blank">'+myMenu[i].menuName+'</a> - '+myMenu[i].tabs[0].url+'</b></span><br>';
}
else{
sitemapstring += '<span style="font-size:14px;background-color:#4D595D;"><b><a style="color:#FFCC00;background-color:#4D595D;" href="'+myMenu[i].tabs[0].url+'" target="_blank">'+myMenu[i].menuName+'</a></b></span><br>';
}
}
else{
sitemapstring += '<span style="font-size:14px;background-color:#4D595D;"><b>'+myMenu[i].menuName+'</b></span><br>';
}
for(var i2 = 0; i2 < myMenu[i].tabs.length; i2++){
if(myMenu[i].tabs[i2].tabName == '__HIDE__'){
continue;
}
var tabname = myMenu[i].tabs[i2].tabName;
var taburl = myMenu[i].tabs[i2].url;
if(tabname == '__INHERIT__'){
tabname = taburl.split('.')[0];
}
if(taburl.indexOf('redirect.htm') != -1){
taburl = '/ext/shared-jy/redirect.htm';
}
if(showurls == true){
sitemapstring += '<a style="text-decoration:underline;background-color:#4D595D;" href="'+taburl+'" target="_blank">'+tabname+'</a> - '+taburl+'<br>';
}
else{
sitemapstring += '<a style="text-decoration:underline;background-color:#4D595D;" href="'+taburl+'" target="_blank">'+tabname+'</a><br>';
}
}
sitemapstring += '<br>';
}
return sitemapstring;
}
GenerateSiteMap(false);
AddDropdowns();
EOF
mount -o bind /tmp/state.js /www/state.js
Print_Output true "Mounted Sitemap page as $MyPage" "$PASS"
fi
umount /www/require/modules/menuTree.js 2>/dev/null
mount -o bind /tmp/menuTree.js /www/require/modules/menuTree.js
fi
flock -u "$FD"
Print_Output true "Mounted $SCRIPT_NAME WebUI page as $realpage" "$PASS"
}
##----------------------------------------##
## Modified by Martinski W. [2024-Sep-29] ##
##----------------------------------------##
Get_Cron_Jobs()
{
printf "%-27s┌────────── minute (0 - 59)\\n" " "
printf "%-27s│%-9s┌──────── hour (0 - 23)\\n" " " " "
printf "%-27s│%-9s│%-9s┌────── day of month (1 - 31)\\n" " " " " " "
printf "%-27s│%-9s│%-9s│%-9s┌──── month (1 - 12)\\n" " " " " " " " "
printf "%-27s│%-9s│%-9s│%-9s│%-9s┌── day of week (0 - 6 => Sunday - Saturday)\\n" " " " " " " " " " "
printf "%-27s│%-9s│%-9s│%-9s│%-9s│\\n" " " " " " " " " " "
printf "%-27s↓%-9s↓%-9s↓%-9s↓%-9s↓\\n" " " " " " " " " " "
printf "${GRNct}%-25s %-9s %-9s %-9s %-9s %-10s %s${CLEARFORMAT}\n" "Cron Job Name" "Min" "Hour" "DayM" "Month" "DayW" "Command"
cronjobs="$(eval $cronListCmd | awk 'FS="#" {printf "%s %s\n",$2,$1}' | awk '{printf "%-25s %-9s %-9s %-9s %-9s %-10s ",$1,$2,$3,$4,$5,$6;for(i=7; i<=NF; ++i) printf "%s ", $i; print ""}')"
echo "$cronjobs"
eval $cronListCmd | sed 's/,/|/g' | awk 'FS="#" {printf "%s %s\n",$2,$1}' | \
awk '{printf "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"",$1,$2,$3,$4,$5,$6;for(i=7; i<=NF; ++i) printf "%s ", $i; print "\""}' | sed 's/ "$/"/g' > /tmp/scmcronjobs.tmp
}
Get_Addon_Pages(){
urlpage=""
urlproto=""
urldomain=""
urlport=""
if [ "$(nvram get http_enable)" -eq 1 ]; then
urlproto="https"
else
urlproto="http"
fi
if [ -n "$(nvram get lan_domain)" ]; then
urldomain="$(nvram get lan_hostname).$(nvram get lan_domain)"
else
urldomain="$(nvram get lan_ipaddr)"
fi
if [ "$(nvram get ${urlproto}_lanport)" -eq 80 ] || [ "$(nvram get ${urlproto}_lanport)" -eq 443 ]; then
urlport=""
else
urlport=":$(nvram get ${urlproto}_lanport)"
fi
weburl="$(echo "${urlproto}://${urldomain}${urlport}/" | tr "A-Z" "a-z")"
grep "user.*\.asp" /tmp/menuTree.js | awk -F'"' -v wu="$weburl" '{printf "%-12s "wu"%s\n",$4,$2}' | sort -f
grep "user.*\.asp" /tmp/menuTree.js | awk -F'"' -v wu="$weburl" '{printf "%s,"wu"%s\n",$4,$2}' > /tmp/addonwebpages.tmp
}
##-------------------------------------##
## Added by Martinski W. [2024-Apr-28] ##
##-------------------------------------##
_WaitForConfirmation_()
{
! "$isInteractiveMenuMode" && return 0
local promptStr
if [ $# -eq 0 ] || [ -z "$1" ]
then promptStr=" [yY|nN] N? "
else promptStr="$1 [yY|nN] N? "
fi
printf "$promptStr" ; read -rn 3 YESorNO
if echo "$YESorNO" | grep -qE "^([Yy](es)?)$"
then echo "OK" ; return 0
else echo "NO" ; return 1
fi
}
##-------------------------------------##
## Added by Martinski W. [2024-Apr-29] ##
##-------------------------------------##
NTP_ReadyCheckOption()
{
case "$1" in
enable)
echo "${NTP_READY_CHECK_KEYN}=ENABLED" > "$NTP_READY_CHECK_CONF" ;;
disable)
if "$isInteractiveMenuMode"
then
printf "${REDct}**${YLWct}WARNING${REDct}**${CLEARct}\n"
printf "You're about to disable the \"NTP Ready\" check. This is generally not recommended\n"
printf "unless you have some very specific conditions (e.g. WAN state is not connected).\n"
printf "Remember to re-enable the \"NTP Ready\" check as soon as you possibly can.\n\n"
if ! _WaitForConfirmation_ "Proceed to ${REDct}DISABLE${CLEARct} the 'NTP Ready' check"
then return 1 ; fi
fi