/
tests.php
2244 lines (1895 loc) · 121 KB
/
tests.php
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
<?PHP
###############################################################
# #
# Fix Common Problems copyright 2015-2023, Andrew Zawadzki #
# #
###############################################################
/*
With the exception of the following global variables, all functions / tests should be 100% self contained and not
have any dependencies from another test
$fixPaths - various static local / remote paths
$fixSettings - the user defined settings for this plugin
$autoUpdateOverride - set if auto-update errors should generate a warning instead
$developerMode - a flag to signal certain tests to not run when the user is a developer of various items for Unraid (so that they are not bugged)
$communityApplicationsInstalled - True if CA is installed
$dockerRunning - True if docker is running
$ignoreList - List of errors which are currently ignored (can be safely ignored unless there's a very valid reason to not actually run the test if its ignored, as ignored items will not generate a notification)
$shareList - List of Unraid's user shares
$unRaidVersion - Currently installed version of Unraid
*/
###########################
# Check for array started #
###########################
# NOTE: This sets the global variables $shareList so it needs to be run first of all the tests
if ( is_dir("/mnt/user") ) {
$shareList = array_diff(scandir("/mnt/user"),array(".",".."));
} else {
$shareList = array();
}
$unRaidVars = my_parse_ini_file($fixPaths['var.ini']);
function isArrayStarted() {
global $shareList,$unRaidVars, $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
if ( $unRaidVars['mdState'] != "STARTED" ) {
addOther("Array is not started","Most (but not all) tests require the array to be started in order to run. There may be more errors / warnings than what is listed here");
}
}
#############################################################
# Check for implied array only but files / folders on cache #
#############################################################
function impliedArrayFilesOnCache() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
foreach ($shareList as $share) {
if ( startsWith($share,".") ) { continue; }
if ( ! is_file("/boot/config/shares/$share.cfg") ) {
if ( is_dir("/mnt/cache/$share") ) {
$shareURL = str_replace(" ","+",$share);
addWarning("Share <b>$share</b> is an implied <em>array-only</em> share, but files / folders exist on the cache","Set <b><em>Use Cache</em></b> appropriately, then rerun this analysis. ".addLinkButton("$share Settings","/Shares/Share?name=$shareURL"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098680");
}
}
}
}
############################################################
# Check for cache only share, but files / folders on array #
############################################################
function cacheOnlyFilesOnArray() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
foreach ($shareList as $share) {
if ( startsWith($share,".") ) { continue; }
if ( is_file("/boot/config/shares/$share.cfg") ) {
$shareCfg = my_parse_ini_file("/boot/config/shares/$share.cfg");
if ( $shareCfg['shareUseCache'] == "only" ) {
if (is_dir("/mnt/user0/$share") ) {
$contents = array_diff(scandir("/mnt/user0/$share"),array(".",".."));
if ( ! empty($contents) ) {
$shareURL = str_replace(" ","+",$share);
addWarning("Share <b>$share</b> set to <em>cache-only</em>, but files / folders exist on the array","You should change the shares settings appropriately ".addLinkButton("$share Settings","/Shares/Share?name=$shareURL")." or use the dolphin / krusader docker applications to move the offending files accordingly. Note that there are some valid use cases for a set up like this. In particular: <a href='https://forums.unraid.net/topic/39097-video-demo-managing-game-libraries-with-unraid-user-shares/#comment-381697' target='_blank'>THIS</a>","https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098683");
}
}
}
}
}
}
######################################
# Look for files on wrong cache pool #
######################################
function wrongCachePoolFiles() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList, $unRaidVersion;
if ( version_compare($unRaidVersion,"6.9.2","<") ) return;
$disks = my_parse_ini_file($fixPaths['disks.ini'],true);
foreach ($disks as $disk) {
if ( $disk['type'] == "Cache" && $disk['status'] !== "DISK_NP")
$pools[] = $disk['name'];
}
if ( ! isset($pools) ) return;
if ( version_compare($unRaidVersion,"6.10.0-rc2",">") ) {
$msg = "Either adjust which pool this share should be using or manually move the files with Dynamix File Manager";
} else {
$msg = "You will either have to manually move the files at the command prompt, or seek assistance on the forums";
}
foreach ( $shareList as $share) {
$shareCfg = my_parse_ini_file("/boot/config/shares/$share.cfg");
if ( ! $shareCfg ) continue;
if ( $shareCfg['shareUseCache'] == "only" || $shareCfg['shareUseCache'] == "prefer" || $shareCfg['shareUseCache'] == "yes" ) {
$sharePool = $shareCfg['shareCachePool'] ?? "cache";
if ( !is_dir("/mnt/$sharePool") ) {
addWarning("Share <b>$share</b> references non existent pool <b>$sharePool</b>","If you have renamed a pool this will have to be adjusted in the share's settings".addLinkButton("Share Settings","/Shares/Share?name=$share"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098686");
continue;
}
foreach ( $pools as $pool ) {
if ( $pool == $sharePool ) {
continue;
}
if ( is_dir("/mnt/$pool/$share") ) {
addWarning("Share <b>$share</b> set to use pool <b>$sharePool</b>, but files / folders exist on the $pool pool",$msg,"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098686");
}
}
}
}
}
#######################################################
# Check for don't use cache, but files on cache drive #
#######################################################
function arrayOnlyFilesOnCache() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
foreach ($shareList as $share) {
if ( startsWith($share,".") ) { continue; }
if ( is_file("/boot/config/shares/$share.cfg") ) {
$shareCfg = my_parse_ini_file("/boot/config/shares/$share.cfg");
if ( $shareCfg['shareUseCache'] == "no" ) {
if ( is_dir("/mnt/cache/$share") ) {
$contents = array_diff(scandir("/mnt/cache/$share"),array(".",".."));
if ( ! empty($contents) ) {
$shareURL = str_replace(" ","+",$share);
addWarning("Share <b>$share</b> set to <em>not use the cache</em>, but files / folders exist on the cache drive","You should change the shares settings appropriately ".addLinkButton("$share Settings","/Shares/Share?name=$shareURL")."or use the dolphin / krusader docker applications to move the offending files accordingly. Note that there are some valid use cases for a set up like this. In particular: <a href='https://lime-technology.com/forum/index.php?topic=40777.msg385753' target='_blank'>THIS</a>","https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098688");
}
}
}
}
}
}
##############################################
# Check for Dynamix to perform plugin checks #
##############################################
function pluginUpdateCheck() {
global $fixPaths, $communityPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
if ( is_file("/boot/config/plugins/ca.update.applications/plugin_update.cron") ) { return; }
if ( ! is_file("/boot/config/plugins/dynamix/plugin-check.cron") ) {
if ( $autoUpdateOverride ) {
$func = "addWarning";
} else {
$func = "addWarning";
}
$func("<b>Plugin Update Check</b> not enabled","Highly recommended to have dynamix check for plugin updates (including for the webUI".addLinkButton("Notification Settings","/Settings/Notifications"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098690");
}
}
#####################################################
# Check for Dynamix to perform docker update checks #
#####################################################
function dockerUpdateCheck() {
global $fixPaths, $communityPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList, $unRaidVersion;
if ( version_compare($unRaidVersion,"6.7.4","<") ) return;
if ( is_file("/boot/config/plugins/ca.update.applications/docker_update.cron") ) { return; }
if ( $dockerRunning ) {
if ( ! is_file("/boot/config/plugins/dynamix/docker-update.cron") ) {
addWarning("<b>Docker Update Check</b> not enabled","Recommended to enable update checks for docker applications".addLinkButton("Notification Settings","/Settings/Notifications"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098691");
}
}
}
###############################################
# Check for CA to auto update certain plugins #
###############################################
function autoUpdateCheck() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
global $communityPaths;
if ( $communityApplicationsInstalled ) {
$autoUpdateSettings = readJsonFile($communityPaths['autoUpdateSettings']);
if ( ! $autoUpdateSettings) {
$autoUpdateSettings['community.applications.plg'] = "true";
$autoUpdateSettings['fix.common.problems.plg'] = "true";
}
if ( ($autoUpdateSettings['Global'] ?? "") != "true" ) {
if ( ($autoUpdateSettings['fix.common.problems.plg'] ?? "") != "true" ) {
if ( $autoUpdateOverride ) {
$func = "addWarning";
} else {
$func = "addWarning";
}
$func("This plugin <b>(Fix Common Problems)</b> not set to auto update",addLinkButton("Auto Update Settings","/Settings/AutoUpdate")."Recommended to enable auto updates for this plugin to enable further problem solving / fixes","https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098693");
}
}
}
}
#############################################################
# Check for shares spelled the same but with different case #
#############################################################
function sameShareDifferentCase() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
foreach ( $shareList as $share ) {
$dupShareList = array_diff(scandir("/mnt/user/"),array(".","..",$share));
foreach ($dupShareList as $dup) {
if ( strtolower($share) === strtolower($dup) ) {
addError("Same share ($share) exists in a different case","This will confuse SMB shares. Manual intervention required. Use the dolphin / krusader docker app to combine the shares into one unified spelling","https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098695");
break;
}
}
}
}
################################################
# Check for communication to the outside world #
################################################
function outsideCommunication() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
if ( ! @file_get_contents($fixPaths['moderation']) || ! strlen(@file_get_contents($fixPaths['moderation'])) ) {
addError("Unable to communicate with GitHub.com","Reset your modem / router or try again later, or set your ".addLinkButton("DNS Settings","/Settings/NetworkSettings")." to 8.8.8.8 and 8.8.4.4 Also make sure that you have a Gateway address set up (Your Routers IP address). Additionally, this may also mean that GitHub is currently down. This error means that you may not be able to update your OS or plugins","https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098696");
}
}
###############################################################
# Check for inability to write to drives, flash, docker image #
###############################################################
function writeToDriveTest() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList, $unRaidVersion;
$availableDrives = array_diff(scandir("/mnt/"),array(".","..","user","user0","addons","disks","remotes","RecycleBin","rootshare"));
$disksIni = my_parse_ini_file($fixPaths['disks.ini'],true);
$disksPresent = array_keys(array_filter($disksIni, function($k) {
return ($k['status'] !== "DISK_NP" && $k['name'] !== "parity" && $k['name'] !== "parity2");
}));
$cachePools = array_keys(array_filter($disksIni, function($k) {
return ! preg_match("/disk\d(\d|$)|(parity|parity2|disks|remotes|addons|flash|diskP|diskQ)/",$k['name']);
}));
$spunDown = "";
foreach ($availableDrives as $drive) {
if ( $fixSettings['disableSpinUp'] == "true" ) {
if ( isset($disksIni[$drive]) ) {
if ( stripos($disksIni[$drive]['color'],"blink") || $disksIni[$drive]['spundown'] == "1" ) {
$spunDown .= " $drive ";
continue;
}
}
}
if ( is_file("/mnt/$drive") ) {
addError("File $drive present within /mnt","Generally speaking, most times when files get created within /mnt it is a result of an improperly configured application. This error may or may not cause issues for you","https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098777");
continue;
}
if ( ! in_array($drive,$disksPresent ) && ! in_array($drive,$cachePools) ) {
addError("Invalid folder $drive contained within /mnt","Generally speaking, most times when other folders get created within /mnt it is a result of an improperly configured application. This error may or may not cause issues for you","https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098777");
continue;
}
$filename = randomFile("/mnt/$drive");
@file_put_contents($filename,"test");
$result = @file_get_contents($filename);
if ( $result != "test" ) {
addError("Unable to write to $drive","Drive mounted read-only or completely full. Begin Investigation Here: ".addLinkButton("Unraid Main","/Main"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098699");
}
@unlink($filename);
}
if ( $dockerRunning ) {
$filename = randomFile("/var/lib/docker/tmp");
@file_put_contents($filename,"test");
$result = @file_get_contents($filename);
if ( $result != "test" ) {
addError("Unable to write to <b>Docker Image</b>","Docker Image either full or corrupted. Investigate Here: ".addLinkButton("Docker Settings","/Settings/DockerSettings"));
}
@unlink($filename);
}
}
###############################################################################
# check for default docker appdata location to be cache or directly on a disk #
###############################################################################
function dockerImageOnDiskShare() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList, $unRaidVersion;
if ( version_compare($unRaidVersion,"6.2.0-rc3",">=") || version_compare($unRaidVersion,"6.2",">=") ) { return; }
if ( is_dir("/mnt/cache") ) {
$dockerOptions = @my_parse_ini_file("/boot/config/docker.cfg");
if ( startsWith($dockerOptions['DOCKER_APP_CONFIG_PATH'],"/mnt/user/") ) {
addWarning("<b>docker appdata location</b> is stored within /mnt/user","Many (if not most) docker applications will have issues (weird results, not starting, etc) if their appdata is stored within a user share. You should constrain the appdata share to a <b>single</b>disk or to the cache drive. This is true even if the appdata share is a <em>Cache-Only</em> share. Change the default here: ".addLinkButton("Docker Settings","/Settings/DockerSettings"));
}
}
}
####################################################################
# check for default docker appdata location to be cache only share #
####################################################################
function dockerAppdataCacheOnly() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
if ( is_dir("/mnt/cache") ) {
$dockerOptions = @my_parse_ini_file("/boot/config/docker.cfg");
if ( ! startsWith($dockerOptions['DOCKER_APP_CONFIG_PATH'],"/mnt/user/") ) {
return;
}
$folders = explode("/",str_replace("/mnt/user/","",$dockerOptions['DOCKER_APP_CONFIG_PATH']));
$sharename = $folders[0]; # get the actual sharename from the path;
if ( is_file("/boot/config/shares/$sharename.cfg") ) {
$shareSettings = my_parse_ini_file("/boot/config/shares/$sharename.cfg");
if ( ( $shareSettings['shareUseCache'] != "only" ) && ( $shareSettings['shareUseCache'] != "prefer" ) ) {
addError("<b>Default docker appdata</b> location is not a cache-only share","If the appdata share is not set to be cache-only, then the mover program will cause your docker applications to become inoperable when it runs (6.1.x). Under 6.2+, this setting should not affect the operation of the application, but it will definitely impact significantly the performance of the application. Fix it via ".addLinkButton("$sharename Settings","/Shares/Share?name=$sharename"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098704");
}
}
}
}
###########################
# look for disabled disks #
###########################
function disabledDisksPresent() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$disks = my_parse_ini_file($fixPaths['disks.ini'],true);
foreach ($disks as $disk) {
if ( startsWith($disk['status'],'DISK_DSBL') ) {
addError("<b>".$disk['name']." (".$disk['id'].")</b> is disabled","Begin Investigation Here: ".addLinkButton("Unraid Main","/Main"));
}
}
}
##########################
# look for missing disks #
##########################
function missingDisksPresent() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$disks = my_parse_ini_file($fixPaths['disks.ini'],true);
foreach ($disks as $disk) {
if ( ( $disk['status'] == "DISK_NP") || ( $disk['status'] == "DISK_NP_DSBL" ) ) {
if ( $disk['id'] ) {
addError("<b>".$disk['name']." (".$disk['id'].")</b> is missing","Unraid believes that your hard drive is not connected to any SATA port. Begin Investigation Here: ".addLinkButton("Unraid Main","/Main")." And also look at the ".addLinkButton("Diagnostics","/Tools/Diagnostics"));
}
}
}
}
########################
# look for read errors #
########################
function readErrorsPresent() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$disks = my_parse_ini_file($fixPaths['disks.ini'],true);
foreach ($disks as $disk) {
if ( $disk['numErrors'] ) {
addError("<b>".$disk['name']." (".$disk['id'].")</b> has read errors","If the disk has not been disabled, then Unraid has successfully rewritten the contents of the offending sectors back to the hard drive. It would be a good idea to look at the S.M.A.R.T. Attributes for the drive in questionBegin Investigation Here: ".addLinkButton($disk['name']." Settings","/Main/Device?name=".$disk['name']));
}
}
}
###############################
# look for file system errors #
###############################
function fileSystemErrors() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$disks = my_parse_ini_file($fixPaths['disks.ini'],true);
$vars = my_parse_ini_file($fixPaths['var.ini'],true);
if ( $vars['mdState'] !== "STARTED" ) return;
if ( $vars['sbClean'] !== "no" ) return;
foreach ( $disks as $disk ) {
if ( !isset($disk['fsStatus']) || !$disk['fsStatus'] || $disk['fsStatus'] == "-" ) continue;
if ( strtolower($disk['fsStatus']) !== "mounted" ) {
addError("<b>".$disk['name']." (".$disk['id'].")</b> has file system errors (".$disk['fsError'].")","If the disk if XFS / REISERFS, stop the array, restart the Array in Maintenance mode, and run the file system checks. If the disk is BTRFS, then see <a href='https://forums.lime-technology.com/topic/46802-faq-for-unraid-v6/?page=2&tab=comments#comment-543490' target='_blank'>this post</a>. <b>If the disk is listed as being unmountable, and it has data on it, whatever you do do not hit the format button. Seek assistance <a href='http://lime-technology.com/forum/index.php?board=71.0' target='_blank'>HERE</a>");
}
}
}
###################################
# look for SSD's within the Array #
###################################
function SSDinArray() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$disks = my_parse_ini_file($fixPaths['disks.ini'],true);
foreach ( $disks as $disk ) {
if ( $disk['rotational'] == "0" ) {
if ( startsWith($disk['name'],"disk") ) {
addWarning("<b>".$disk['name']." (".$disk['id'].")</b> is an SSD.","SSDs are not currently supported within the array, and their background garbage collection *may* impact your ability to rebuild a disk");
}
}
}
}
###################################
# look for plugins not up to date #
###################################
function pluginsUpToDate() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
global $communityPaths, $unRaidVersion;
$autoUpdateSettings = readJsonFile($communityPaths['autoUpdateSettings']);
if ( ($autoUpdateSettings['Global'] ?? "") != "true" ) {
$installedPlugins = array_diff(scandir("/var/log/plugins"),array(".",".."));
foreach ($installedPlugins as $Plugin) {
if ( $Plugin == "community.applications.plg" ) {
continue;
}
if ( ($autoUpdateSettings[$Plugin] ?? "") != "true" ) {
if ( is_file("/var/log/plugins/$Plugin") ) {
if ( strtolower(pathinfo($Plugin, PATHINFO_EXTENSION)) == "plg" ) {
if ( checkPluginUpdate($Plugin) ) {
if ( $Plugin == "fix.common.problems.plg" ) {
addWarning("Plugin <b>$Plugin</b> is not up to date","Upgrade the plugin here: ".addLinkButton("Plugins","/Plugins"));
} else {
if ( $Plugin == "unRAIDServer.plg" ) {
$uptodateVersion = pluginVersion("/tmp/plugins/$Plugin");
addWarning("<b>Unraid OS</b> not up to date","You are currently running <b>".unRaidVersion()."</b> and the latest version is <b>$uptodateVersion</b>. It is recommended to upgrade here: ".addLinkButton("UpdateOS","/Tools/Update")." and review the release notes <a href='http://lime-technology.com/forum/index.php?board=1.0' target='_blank'>HERE</a>");
} else {
addWarning("Plugin <b>$Plugin</b> is not up to date","Upgrade the plugin here: ".addLinkButton("Plugins","/Plugins"));
}
}
}
}
}
}
}
}
}
##########################################
# Check if docker containers not updated #
##########################################
function dockerUpToDate() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList, $unRaidVersion;
if ( version_compare($unRaidVersion,"6.7.4","<") ) return;
if ( $dockerRunning ) {
$DockerClient = new DockerClient();
$info = $DockerClient->getDockerContainers();
$updateStatus = readJsonFile($fixPaths['dockerUpdateStatus']);
foreach ($info as $docker) {
if ( $updateStatus[$docker['Image']]['status'] == 'false' ) {
addWarning("Docker Application <b>".$docker['Name']."</b> has an update available for it","Install the updates here: ".addLinkButton("Docker","/Docker"));
}
}
}
}
######################################################################
# Check for docker application's config folders pointed at /mnt/user #
######################################################################
function dockerConfigUserShare() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList, $unRaidVersion;
if ( version_compare($unRaidVersion,"6.2.0-rc3",">=") || version_compare($unRaidVersion,"6.2",">=") ) { return; }
if ( $dockerRunning ) {
$DockerClient = new DockerClient();
$info = $DockerClient->getDockerContainers();
foreach ($info as $docker) {
$appData = findAppData($docker['Volumes']);
if ( startsWith($appData,"/mnt/user") ) {
addWarning("<b>".$docker['Name']."</b> docker application has its /config folder set to <b>$appData</b>","Many (if not most docker applications) will not function correctly if their appData folder is set to a user share. Ideally, they should be set to a disk share. Either /mnt/cache/... or /mnt/diskX/... Fix it here: ".addLinkButton("Docker Settings","/Docker"));
}
}
}
}
#################################
# Check for /var/log filling up #
#################################
function varLogFilled() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
global $troubleshooting;
unset($output);
exec("df /var/log",$output);
$statusLine = preg_replace('!\s+!', ' ', $output[1]);
$status = explode(" ",$statusLine);
$used = str_replace("%","",$status[4]);
if ( $troubleshooting ) {
logger("Fix Common Problems: /var/log currently $used % full");
}
if ( $used > 80 ) {
addError("<b>/var/log</b> is getting full (currently $used % used)","Either your server has an extremely long uptime, or your syslog could be potentially being spammed with error messages. A reboot of your server will at least temporarily solve this problem, but ideally you should seek assistance in the forums and post your ".addLinkButton("Diagnostics","/Tools/Diagnostics"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098706");
} else {
if ( $used > 50 ) {
addWarning("<b>/var/log</b> is getting full (currently $used % used)","Either your server has an extremely long uptime, or your syslog could be potentially being spammed with error messages. A reboot of your server will at least temporarily solve this problem, but ideally you should seek assistance in the forums and post your ".addLinkButton("Diagnostics","/Tools/Diagnostics"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098706");
}
}
}
#######################################
# Check for docker image getting full #
#######################################
function dockerImageFull() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
unset($output);
if ( $dockerRunning ) {
exec("df /var/lib/docker",$output);
$statusLine = preg_replace('!\s+!', ' ', $output[1]);
$status = explode(" ",$statusLine);
$used = str_replace("%","",$status[4]);
if ( $used > 90 ) {
addError("<b>Docker image</b> file is getting full (currently $used % used)","You should either increase the available image size to the docker image here ".addLinkButton("Docker Settings","/Settings/DockerSettings")."or investigate the possibility of docker applications storing completed downloads / incomplete downloads / etc within the actual docker image here: ".addLinkButton("Docker","/Docker"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098699");
} else {
if ( $used > 80 ) {
addWarning("<b>Docker image</b> file is getting full (currently $used % used)","You should either increase the available image size to the docker image here ".addLinkButton("Docker Settings","/Settings/DockerSettings")."or investigate the possibility of docker applications storing completed downloads / incomplete downloads / etc within the actual docker image here: ".addLinkButton("Docker","/Docker"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098699");
}
}
}
}
#################################
# Check for rootfs getting full #
#################################
function rootfsFull() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
global $troubleshooting;
unset($output);
if ( is_dir("/") ) {
exec("df /",$output);
$statusLine = preg_replace('!\s+!', ' ', $output[1]);
$status = explode(" ",$statusLine);
$used = str_replace("%","",$status[4]);
if ( $troubleshooting ) {
logger("Fix Common Problems: rootfs (/) currently $used % full");
}
if ( $used > 90 ) {
addError("<b>Rootfs</b> file is getting full (currently $used % used)","Possibly an application is storing excessive amount of data in /tmp. Seek assistance on the forums and post your ".addLinkButton("Diagnostics","/Tools/Diagnostics"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098710");
} else {
if ( $used > 75 ) {
addWarning("<b>Rootfs</b> file is getting full (currently $used % used)","Possibly an application is storing excessive amount of data in /tmp. Seek assistance on the forums and post your ".addLinkButton("Diagnostics","/Tools/Diagnostics"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098710");
}
}
}
}
#####################################
# Check for scheduled parity checks #
#####################################
function scheduledParityChecks() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
if ( is_file("/boot/config/plugins/dynamix/dynamix.cfg") ) {
$dynamixSettings = my_parse_ini_file("/boot/config/plugins/dynamix/dynamix.cfg",true);
if ( ($dynamixSettings['parity']['mode'] ?? "") == "0" ) {
addWarning("Scheduled <b>Parity Checks</b> are not enabled","It is highly recommended to schedule parity checks for your system (most users choose monthly). This is so that you know if Unraid has the ability to rebuild a failed drive if it needs to. Set the schedule here: ".addLinkButton("Scheduler","/Settings/Scheduler"));
}
}
}
################################################################
# Check for shares having both included and excluded disks set #
################################################################
function shareIncludeExcludeSet() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
foreach ($shareList as $share) {
if ( is_file("/boot/config/shares/$share.cfg") ) {
$shareCfg = my_parse_ini_file("/boot/config/shares/$share.cfg");
if ( ($shareCfg['shareInclude'] ?? "") && ($shareCfg['shareExclude'] ?? "") ) {
$shareURL = str_replace(" ","+",$share);
addWarning("Share <b>$share</b> is set for both included (".$shareCfg['shareInclude'].") and excluded (".$shareCfg['shareExclude'].") disks","While if you're careful this isn't a problem, there is absolutely no reason ever to specify BOTH included and excluded disks. It is far easier and safer to only set either the included list or the excluded list. Fix it here: ".addLinkButton("$share Settings","/Shares/Share?name=$shareURL"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098712");
}
}
}
# Check for global share settings having both included and exluded disks set
if ( is_file("/boot/config/share.cfg") ) {
$shareCfg = my_parse_ini_file("/boot/config/share.cfg");
if ( $shareCfg['shareUserInclude'] && $shareCfg['shareUserExclude'] ) {
addWarning("<b>Global Share Settings</b> is set for both included (".$shareCfg['shareUserInclude'].") and excluded (".$shareCfg['shareUserExclude'].") disks","While if you're careful this isn't a problem, there is absolutely no reason ever to specify BOTH included and excluded disks. It is far easier and safer to only set either the included list or the excluded list. Fix it here: ".addLinkButton("Global Share Settings","/Settings/ShareSettings"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098712");
}
}
}
#########################################################################
# Check for shares having duplicated disks within included and excluded #
#########################################################################
function shareIncludeExcludeSameDisk() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
foreach ($shareList as $share) {
if ( is_file("/boot/config/shares/$share.cfg") ) {
$shareCfg = my_parse_ini_file("/boot/config/shares/$share.cfg");
if ( ! ($shareCfg['shareInclude'] ?? "") ) { continue; }
if ( ! ($shareCfg['shareExclude'] ?? "") ) { continue; }
$shareInclude = explode(",",$shareCfg['shareInclude']);
$shareExclude = explode(",",$shareCfg['shareExclude']);
foreach ($shareInclude as $included) {
foreach ($shareExclude as $excluded) {
if ( $included == $excluded ) {
$shareURL = str_replace(" ","+",$share);
addError("Share <b>$share</b> has the same disk ($included) set to be both included and excluded","The same disk cannot be both included and excluded. There is also no reason to ever set both the included and excluded disks for a share. Use one or the other. Fix it here:".addLinkButton("$share Settings","/Shares/Share?name=$shareURL"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098712");
}
}
}
}
}
# Check for having duplicated disks within global share included / excluded
if ( is_file("/boot/config/share.cfg") ) {
$shareCfg = my_parse_ini_file("/boot/config/share.cfg");
if ( ( $shareCfg['shareUserExclude'] ) && ( $shareCfg['shareUserInclude'] ) ) {
$shareInclude = explode(",",$shareCfg['shareUserInclude']);
$shareExclude = explode(",",$shareCfg['shareUserExclude']);
foreach ($shareInclude as $included) {
foreach ($shareExclude as $excluded) {
if ( $included == $excluded ) {
$shareURL = str_replace(" ","+",$share);
addError("Share <b>Global Share Settings</b> has the same disk ($included) set to be both included and excluded","The same disk cannot be both included and excluded. There is also no reason to ever set both the included and excluded disks for a share. Use one or the other. Fix it here:".addLinkButton("Global Share Settings","/Settings/ShareSettings"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098712");
}
}
}
}
}
}
##############################################################################
# Check for UD assigned disks not being passed as slave to docker containers #
##############################################################################
function UDmountedSlaveMode() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
if ( $dockerRunning ) {
if ( version_compare(unRaidVersion(),"6.2",">=") ) {
$DockerClient = new DockerClient();
$info = $DockerClient->getDockerContainers();
foreach ($info as $docker) {
if ( is_array($docker['Volumes']) ) {
foreach ($docker['Volumes'] as $volume) {
$volumePassed = explode(":",$volume);
if ( startsWith($volumePassed[0],"/mnt/disks/") || startsWith($volumePassed[0],"/mnt/remotes") ) {
if ( ! stripos($volumePassed[2],"slave") && ! stripos($volumePassed[2],"shared") ) {
addWarning("Docker application <b>".$docker['Name']."</b> has volumes being passed that are mounted by <em>Unassigned Devices</em>, but they are not mounted with the slave option","To help with a trouble free experience with this application, you need to pass any volumes mounted with Unassigned Devices using the slave option. Fix it here: ".addLinkButton("Docker","/Docker"),"https://forums.unraid.net/topic/120220-fix-common-problems-more-information/?tab=comments#comment-1098717");
}
}
}
}
}
}
}
}
#########################################
# Check for Unraid's ftp server running #
#########################################
function FTPrunning() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
unset($output);
exec("cat /etc/inetd.conf | grep vsftpd",$output);
foreach ($output as $line) {
if ($line[0] != "#") {
if ( is_file("/boot/config/vsftpd.user_list") ) {
addWarning("unRaids built in <b>FTP server</b> is running","Opening up your Unraid server directly to the internet is an extremely bad idea. - You <b>will</b> get hacked. If you require an FTP server running on your server, use one of the FTP docker applications instead. They will be more secure than the built in one".addLinkButton("FTP Server Settings","/Settings/FTP")." If you are only using the built in FTP server locally on your network you can ignore this warning, but ensure that you have not forwarded any ports from your router to your server. Note that there is a bug in Unraid 6.1.9 and 6.2b21 where if you disable the service, it will come back alive after a reboot. This check is looking at whether you have users authenticated to use the ftp server");
}
break;
} else {
if ( is_file("/boot/config/vsftpd.user_list") ) {
addWarning("unRaids built in <b>FTP server</b> is currently disabled, but users are defined","There is a "feature" within 6.1.9 and 6.2 beta 21 where after the server is reset, the FTP server will be automatically re-enabled regardless if you want it to be or not. Remove the users here".addLinkButton("FTP Settings","/Settings/FTP"));
}
}
}
}
########################################################
# Check for destination for Alert levels notifications #
########################################################
function checkNotifications() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$dynamixSettings = my_parse_ini_file("/boot/config/plugins/dynamix/dynamix.cfg",true);
if ( ($dynamixSettings['notify']['alert'] ?? "") == "0" ) {
addWarning("No destination (browser / email / agents set for <b>Alert level notifications</b>","Without a destination set for alerts, you will not know if any issue requiring your immediate attention happens on your server. Fix it here:".addLinkButton("Notification Settings","/Settings/Notifications"));
}
# Check for destination for Warning level notifications
if ( ($dynamixSettings['notify']['warning'] ?? "") == "0" ) {
addWarning("No destination (browser / email / agents set for <b>Warning level notifications</b>","Without a destination set for alerts, you will not know if any issue requiring your attention happens on your server. Fix it here:".addLinkButton("Notification Settings","/Settings/Notifications"));
}
# Check for destination email address
$notificationsSet = ($dynamixSettings['notify']['normal'] ?? 0) | ($dynamixSettings['notify']['warning'] ?? 0) | ($dynamixSettings['notify']['alert'] ?? 0);
$emailSelected = ($notificationsSet & 2) == 2;
if ( $emailSelected ) {
if ( ( ! $dynamixSettings['ssmtp']['RcptTo'] ) || ( ! $dynamixSettings['ssmtp']['server'] ) ) {
addWarning("<b>Email</b> selected as a notification destination, but not properly configured","Either deselect email as a destination for notifications or properly configure it here: ".addLinkButton("Notification Settings","/Settings/Notifications")." Note That this test does NOT test to see if you can actually send mail or not");
}
}
}
###########################################
# Check for blacklisted plugins installed #
###########################################
function blacklistedPluginsInstalled() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$caModeration = readJsonFile($fixPaths['moderation']);
if ( $caModeration ) {
$pluginList = array_diff(scandir("/var/log/plugins"),array(".",".."));
foreach ($pluginList as $plugin) {
if ( ! is_file("/var/log/plugins/$plugin") ) {
continue;
}
$pluginURL = getRedirectedURL(exec("/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin pluginURL /var/log/plugins/$plugin"));
if ( isset($caModeration[$pluginURL]['Blacklist']) ) {
addError("Blacklisted plugin <b>$plugin</b>","This plugin has been blacklisted and should no longer be used due to the following reason(s): <em><b>".$caModeration[$pluginURL]['ModeratorComment']."</b></em> You should remove this plugin as its continued installation may cause adverse effects on your server.".addLinkButton("Plugins","/Plugins"));
}
if ( isset($caModeration[$pluginURL]['Deprecated']) ) {
addWarning("Deprecated plugin <b>$plugin</b>","This plugin has been deprecated and should no longer be used due to the following reason(s): <em><b>".$caModeration[$pluginURL]['ModeratorComment']."</b></em> While this plugin should still be functional, it is no recommended to continue to use it.".addLinkButton("Plugins","/Plugins"));
}
}
} else {
addOther("Could not check for <b>blacklisted</b> plugins","The download of the blacklist failed");
}
}
###################################################################################################################
# check for docker applications installed but with changed container ports from what the author specified #
# concurrently check for docker applications running in a different network mode than what the template specifies #
###################################################################################################################
function dockerAppsChangedPorts() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
if ( $dockerRunning ) {
$templates = readJsonFile($fixPaths['templates']);
$dockerClient = new DockerClient();
$info = $dockerClient->getDockerContainers();
if ( is_array($templates['applist']) ) {
$allApps = $templates['applist'];
foreach ($info as $dockerInstalled) {
$dockerImage = $dockerInstalled['Image'];
if ( strtolower($dockerInstalled['NetworkMode']) != "host" && strtolower($dockerInstalled['NetworkMode']) != "bridge" ) {
continue;
}
foreach ($allApps as $app) {
$support = $app['Support'] ? $app['Support'] : $app['Forum'];
if ( ($app['Repository'] === str_replace(":latest","",$dockerImage) ) || ($app['Repository'] === $dockerImage) ) {
if ( ! $app['Networking']['Mode'] ) { # Fix for some lsio templates
$app['Networking']['Mode'] = $app['Network'];
}
if ( is_array($app['Networking']['Mode']) ) {
$app['Networking']['Mode'] = "Indeterminate";
}
$mode = strtolower($app['Networking']['Mode']);
if ( $mode != strtolower($dockerInstalled['NetworkMode']) ) {
addError("Docker Application <b>".$dockerInstalled['Name']."</b> is currently set up to run in <b>".$dockerInstalled['NetworkMode']."</b> mode","The template for this application specifies that the application should run in $mode mode. <a href='$support' target='_blank'>Application Support Thread</a> ".addLinkButton("Docker","/Docker"));
}
if ( $mode == "host" ) { continue;}
if ( ! @is_array($app['Networking']['Publish'][0]['Port']) ) { continue; }
$allPorts = $app['Networking']['Publish'][0]['Port'];
foreach ($allPorts as $port) {
if ( ! $port['ContainerPort'] ) { continue; }
$flag = false;
foreach ($dockerInstalled['Ports'] as $containerPort) {
if ( $containerPort['PrivatePort'] == $port['ContainerPort']) {
$flag = true;
break;
}
}
if ( ! $flag ) {
addError("Docker Application <b>".$dockerInstalled['Name'].", Container Port ".$port['ContainerPort']."</b> not found or changed on installed application","When changing ports on a docker container, you should only ever modify the HOST port, as the application in question will expect the container port to remain the same as what the template author dictated. Fix this here: ".addLinkButton("Docker","/Docker")."<a href='$support' target='_blank'>Application Support Thread</a>");
}
}
}
}
}
} else {
addOther("Could not perform <b>docker application port</b> tests","The download of the application feed failed.");
}
}
}
##############################################
# test for illegal characters in share names #
##############################################
function illegalShareName() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
foreach ($shareList as $share) {
if ( strpos($share, '\\') != false ) {
addError("Share <b>$share</b> contains the \\ character which is an illegal character on Windows systems.","You may run into issues with Windows and/or other programs attempting to access this share. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( strpos($share,"/") != false ) {
addError("Share <b>$share</b> contains the / character which is an illegal character on Windows / Linux systems.","You may run into issues with Windows and/or other programs attempting to access this share. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums. You probably also have some disk corruption, as this folder should be impossible to create");
}
if ( strpos($share,":") ) {
addError("Share <b>$share</b> contains the : character which is an illegal character on Windows / MAC systems.","You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( strpos($share,"*") != false ) {
addError("Share <b>$share</b> contains the * character which is an illegal character on Windows systems.","You may also run into issues with non-Windows systems when using this character. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( strpos($share,"?") != false ) {
addError("Share <b>$share</b> contains the ? character which is an illegal character on Windows systems.","You may run into issues with Windows and/or other programs attempting to access this share. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( strpos($share,'"') != false ) {
addError("Share <b>$share</b> contains the \" character which is an illegal character on Windows systems.","You may run into issues with Windows and/or other programs attempting to access this share. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( strpos($share,"<") != false ) {
addError("Share <b>$share</b> contains the < character which is an illegal character on Windows systems.","You may run into issues with Windows and/or other programs attempting to access this share You may also run into issues with non-Windows systems when using this character. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( strpos($share,">") != false ) {
addError("Share <b>$share</b> contains the > character which is an illegal character on Windows systems.","You may run into issues with Windows and/or other programs attempting to access this share. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( strpos($share,"|") != false ) {
addError("Share <b>$share</b> contains the | character which is an illegal character on Windows systems.","You may run into issues with Windows and/or other programs attempting to access this share. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( trim($share) == "" ) {
addError("Share <b>\"$share\"</b> contains only spaces which is illegal Windows systems.","You may run into issues with Windows and/or other programs attempting to access this share/ You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
if ( substr($share, -1) == "." ) {
addError("Share <b>$share</b> ends with the . character which is an illegal character to end a file / folder name on Windows systems.","You may run into issues with Windows and/or other programs attempting to access this share. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
}
# control characters in file names are a standard part of OSX
/* if ( ! ctype_print($share) ) {
addError("Share <b>$share</b> contains control character which should be illegal characters on any OS.","You may run into issues with programs attempting to access this share. You will most likely have to use the command prompt in order to rectify this error. Ask for assistance on the Unraid forums");
} */
}
}
#######################################################################
# check for HPA (addOther if on data drives, addError if parity disk) #
#######################################################################
function HPApresent() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$disks = my_parse_ini_file($fixPaths['disks.ini'],true);
foreach ($disks as $disk) {
if ( ! $disk['device'] ) { continue; }
if ( $disk['name'] == "flash" ) { continue; }
if ( ! startsWith($disk['name'],"parity") ) { continue; } # only test for parity disks
if ( $fixSettings['disableSpinUp'] == "true" ) {
if ( stripos($disk['color'],"blink") || $disk['spundown'] == "1") {
continue;
}
}
$deviceID = $disk['device'];
$command = "/sbin/hdparm -N /dev/$deviceID 2>&1";
unset($output);
exec($command,$output);
foreach ($output as $line) {
if ( strpos($line,"bad/missing") ) { break; }
if ( strpos($line,"questionable") ) { break; }
if ( strpos($line,"incorrect") ) { break; }
if ( strpos($line,"HPA is enabled") ) {
if ( $disk['name'] == "parity" || $disk['name'] == "parity2" ) {
$func = "addError";
} else {
$func = "addOther";
}
$func("Disk <b>".$disk['name']."</b> has an HPA partition enabled on it","If this is your parity disk, then you <b>must</b> remove the HPA partition, because its presence will impact the ability (<b>as in you may not be able to do it</b>) rebuild a disabled drive and/or expand your array. It is not so important if this is present on a data/cache disk. See assistance on unRaids forums for help with the commands to fix this issue. <a href='http://lime-technology.com/wiki/index.php/UnRAID_Topical_Index#HPA' target='_blank'>Sample of forum posts</a> This issue mainly affects hard drives that are currently installed in, or have been in a system with a Gigabyte motherboard");
break;
}
}
}
}
####################################
# Check for flash drive filling up #
####################################
function flashDriveFull() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$flashFree = disk_free_space("/boot");
$flashAvail = disk_total_space("/boot");
$percentage = ($flashFree / $flashAvail) * 100;
if ( $percentage < 10 ) {
addWarning("<b>Flash Drive</b> is > 90% full","As very little information is stored on the flash drive in a properly configured system, you may have an improperly configured application which is storing an excessive amount of data onto the flash drive. On a properly configured system with no extraneous files on the flash drive, it should only use at most 1G");
}
}
#####################################################
# Check for improper entry into cacheFloor Settings #
#####################################################
function cacheFloorTests() {
global $fixPaths, $fixSettings, $autoUpdateOverride, $developerMode, $communityApplicationsInstalled, $dockerRunning, $ignoreList, $shareList;
$vars = my_parse_ini_file($fixPaths['var.ini']);
$suffix = strtolower(preg_replace('/[0-9]+/', '', $vars['shareCacheFloor']));
if ( ( $suffix!= "" ) && ($suffix != "kb") && ($suffix != "mb") && ($suffix != "gb") && ($suffix != "tb") ) {
addError("An improper suffix <b>$suffix</b> was use in the cache floor settings","The only valid suffixes allowed are KB, MB, GB, TB. Fix it here: ".addLinkButton("Global Share Settings","/Settings/ShareSettings"));
}
# Check for cache drive exceeding its floor space ( and cache floor larger than cache drive )
if ( is_dir("/mnt/cache") ) {
$vars = my_parse_ini_file($fixPaths['var.ini']);
$cacheFloor = $vars['shareCacheFloor'];
$cacheFloorSuffix = strtolower(preg_replace('/[0-9]+/', '', $vars['shareCacheFloor']));
$cacheFloor = str_replace($cacheFloorSuffix,"",$cacheFloor);
$cacheFloor = $cacheFloor ? $cacheFloor : 0;
switch ( $cacheFloorSuffix ) {
case "":
$multiplier = 1024;
break;
case "kb":
$multiplier = 1000;
break;
case "mb":
$multiplier = 1000000;
break;
case "gb":
$multiplier = 1000000000;
break;
case "tb":
$multiplier = 1000000000000;
break;
default:
$multiplier = 1;
break;