mirror of
https://github.com/unraid/webgui.git
synced 2026-03-14 15:01:42 -05:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -58,9 +58,14 @@ function run($cmd, &$save=null) {
|
||||
exec("timeout -s9 30 $cmd", $save);
|
||||
return implode("\n",$save);
|
||||
}
|
||||
|
||||
function newline($file) {
|
||||
exec("echo|todos >>".escapeshellarg($file));
|
||||
$tmp_file = "/tmp/".basename($file);
|
||||
copy($file, $tmp_file);
|
||||
exec("/usr/bin/todos < ".escapeshellarg($tmp_file)." > ".escapeshellarg($file));
|
||||
unlink($tmp_file);
|
||||
}
|
||||
|
||||
function shareDisks($share) {
|
||||
return str_replace(',',', ',exec("shopt -s dotglob; getfattr --no-dereference --absolute-names --only-values -n system.LOCATIONS ".escapeshellarg("/mnt/user/$share")." 2>/dev/null") ?: "");
|
||||
}
|
||||
@@ -97,13 +102,19 @@ function anonymize($text, $select) {
|
||||
return dirname($text)."/$name.cfg";
|
||||
}
|
||||
}
|
||||
|
||||
function maskIP($file) {
|
||||
global $all;
|
||||
|
||||
if ($all) return;
|
||||
|
||||
// anonymize public IPv4 addresses
|
||||
$rfc1918 = "(127|10|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)((\.[0-9]{1,3}){2,3}([/\" .]|$))";
|
||||
run("sed -ri 's/([\"\[ ])${rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null");
|
||||
run("sed -ri 's/([\"\[ ]){$rfc1918}/\\1@@@\\2\\3/g; s/([\"\[ ][0-9]{1,3}\.)([0-9]{1,3}\.){2}([0-9]{1,3})([/\" .]|$)/\\1XXX.XXX.\\3\\4/g; s/@@@//g' ".escapeshellarg($file)." 2>/dev/null");
|
||||
// anonymize full IPv6 addresses
|
||||
run("sed -ri 's/([\"\[ ]([0-9a-f]{1,4}:){4})(([0-9a-f]{1,4}:){3}|:)([0-9a-f]{1,4})([/\" .]|$)/\\1XXXX:XXXX:XXXX:\\5\\6/g' ".escapeshellarg($file)." 2>/dev/null");
|
||||
}
|
||||
|
||||
function prefix($key) {
|
||||
return preg_replace('/\d+$/','',$key);
|
||||
}
|
||||
@@ -355,7 +366,8 @@ if (file_exists($changes)) {
|
||||
$previous_version = "Previous Version: ".$version;
|
||||
file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\n".$previous_version."\r\n", FILE_APPEND);
|
||||
|
||||
$upgraded = "Upgraded on: ".date("F d Y", filemtime($changes));
|
||||
$file_stat = stat("/$diag/unraid-".$unraid['version'].".txt");
|
||||
$upgraded = "Upgraded on: ".date("F d Y", $file_stat[9]);
|
||||
file_put_contents("/$diag/unraid-".$unraid['version'].".txt", $upgraded."\r\n", FILE_APPEND);
|
||||
} else {
|
||||
file_put_contents("/$diag/unraid-".$unraid['version'].".txt", "\r\nNo Previous Version Found\r\n", FILE_APPEND);
|
||||
@@ -672,6 +684,22 @@ $testparm = run("testparm -s 2>/dev/null");
|
||||
if (!$all)
|
||||
$testparm = preg_replace("/(?<=\[.)(.*)(?=.\])|(?<=(write list = .)|(comment = .)|(valid users = .)|(path = \/mnt\/addons\/.)|(path = \/mnt\/remotes\/.)|(path = \/mnt\/disks\/.)|(path = \/mnt\/user\/.)).*(?=.)/","...",$testparm);
|
||||
file_put_contents("/$diag/system/testparm.txt",str_replace("\n","\r\n",$testparm));
|
||||
maskIP("/$diag/system/testparm.txt");
|
||||
|
||||
// copy ntp.conf
|
||||
copy("/etc/ntp.conf", "/$diag/system/ntp.txt");
|
||||
maskIP("/$diag/system/ntp.txt");
|
||||
newline("/$diag/system/ntp.txt");
|
||||
|
||||
// copy sshd_config
|
||||
copy("/etc/ssh/sshd_config", "/$diag/system/sshd.txt");
|
||||
maskIP("/$diag/system/sshd.txt");
|
||||
newline("/$diag/system/sshd.txt");
|
||||
|
||||
// copy servers.conf
|
||||
copy("/etc/nginx/conf.d/servers.conf", "/$diag/system/servers.conf.txt");
|
||||
maskIP("/$diag/system/servers.conf.txt");
|
||||
newline("/$diag/system/servers.conf.txt");
|
||||
|
||||
// BEGIN - third party plugins diagnostics
|
||||
// list third party packages in /boot/config/plugins/*/packages/
|
||||
|
||||
Reference in New Issue
Block a user