Diagnostics Update to #408

More generalized.  Actually itemize which disks the share is stored on.
This commit is contained in:
Squidly271
2018-11-02 13:35:35 -04:00
committed by GitHub
parent db29575de7
commit e69f2cdd1f

View File

@@ -28,6 +28,13 @@ function exert($cmd, &$save=null) {
return implode("\n",$save);
}
function shareDisks($share) {
foreach ( array_diff(glob("/mnt/*"),array("/mnt/disks","/mnt/user","/mnt/user0","/mnt/RecycleBin")) as $disk) {
if ( is_dir("$disk/$share") ) $disks .= pathinfo($disk,PATHINFO_FILENAME).", ";
}
return rtrim($disks,", ");
}
function anonymize($text,$select) {
global $all;
if ($all) return $text;
@@ -152,16 +159,16 @@ foreach ($files as $file) {
@copy($file, $dest);
if (!$all) exert("sed -ri 's/^(share(Comment|ReadList|WriteList)=\")[^\"]+/\\1.../' ".escapeshellarg($dest)." 2>/dev/null");
$share = pathinfo(basename($file),PATHINFO_FILENAME);
if ( is_dir("/mnt/user0/$share") ) { file_put_contents($dest,"# Share exists on array\r\n",FILE_APPEND); }
if ( is_dir("/mnt/cache/$share") ) { file_put_contents($dest,"# Share exists on cache drive\r\n",FILE_APPEND); }
file_put_contents($dest,"# share Exists on: ".shareDisks($share),FILE_APPEND);
}
// create default user shares information
$shares = file_exists("$get/shares.ini") ? parse_ini_file("$get/shares.ini", true) : [];
foreach ($shares as $share) {
$name = $share['name'];
if (!in_array("/boot/config/shares/$name.cfg",$files)) file_put_contents(anonymize("/$diag/shares/$name.cfg",2),"# This share has default settings.\r\n");
if ( is_dir("/mnt/user0/$name") ) { file_put_contents($dest,"# Share exists on array\r\n",FILE_APPEND); }
if ( is_dir("/mnt/cache/$name") ) { file_put_contents($dest,"# Share exists on cache drive\r\n",FILE_APPEND); }
if (!in_array("/boot/config/shares/$name.cfg",$files)) {
file_put_contents(anonymize("/$diag/shares/$name.cfg",2),"# This share has default settings.\r\n");
file_put_contents("/$diag/shares/$name.cfg","# share exists on: ".shareDisks($name),FILE_APPEND);
}
}
// copy docker information (if existing)
$max = 1*1024*1024; //=1MB