From 3f62efe64c447821f2fbd6759d52534c275bbffc Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 09:23:56 +0200 Subject: [PATCH 01/11] Fix array status report takes disk individual temperature thresholds in consideration --- plugins/dynamix/scripts/statuscheck | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/dynamix/scripts/statuscheck b/plugins/dynamix/scripts/statuscheck index ccc6401c6..e33a6f713 100755 --- a/plugins/dynamix/scripts/statuscheck +++ b/plugins/dynamix/scripts/statuscheck @@ -12,17 +12,18 @@ */ ?> =$max) { $fail = ' (disk is overheated'; $error0++; - } else if ($temp>=$hot) { + } elseif ($temp>=$hot) { $fail = ' (disk is hot'; $error1++; } else { @@ -162,9 +165,9 @@ if ($mdResync>0) { if ($var['sbSyncExit']!=0) { $data[] = "Last check incomplete on ".my_time($sbSynced2).", finding $sbSyncErrs error".($sbSyncErrs==1?'.':'s.'); $data[] = "Error code: ".$var['sbSyncExit']; - } else if ($sbSynced==0) { + } elseif ($sbSynced==0) { $data[] = "Parity has not been checked yet"; - } else if ($sbSynced2>0) { + } elseif ($sbSynced2>0) { if (strstr($var['mdResyncAction'],"recon")) { $data[] = 'Parity or Data is invalid'; } else { From f00238ff4345532424b37e2429b448f9a336d9ff Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 09:24:54 +0200 Subject: [PATCH 02/11] Updated PHP to preferred "elseif" single statement --- plugins/dynamix/DashboardApps.page | 2 +- plugins/dynamix/PageMap.page | 2 +- plugins/dynamix/ShareEdit.page | 2 +- plugins/dynamix/include/DashUpdate.php | 2 +- plugins/dynamix/include/DeviceList.php | 2 +- plugins/dynamix/include/SmartInfo.php | 4 ++-- plugins/dynamix/scripts/monitor | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/dynamix/DashboardApps.page b/plugins/dynamix/DashboardApps.page index a6e719052..86b4be4f5 100644 --- a/plugins/dynamix/DashboardApps.page +++ b/plugins/dynamix/DashboardApps.page @@ -148,7 +148,7 @@ foreach ($allVMs as $name) { if (!empty($vmtemplateicon)) { if (file_exists($vmtemplateicon)) { $vmicon = $vmtemplateicon; - } else if (file_exists("$docroot/plugins/dynamix.vm.manager/templates/images/" . $vmtemplateicon)) { + } elseif (file_exists("$docroot/plugins/dynamix.vm.manager/templates/images/" . $vmtemplateicon)) { $vmicon = '/plugins/dynamix.vm.manager/templates/images/' . $vmtemplateicon; } } diff --git a/plugins/dynamix/PageMap.page b/plugins/dynamix/PageMap.page index 0ffa34e5b..03aba2d19 100644 --- a/plugins/dynamix/PageMap.page +++ b/plugins/dynamix/PageMap.page @@ -34,7 +34,7 @@ function show_map($menu, $level) { $link="{$page['name']}"; if ($page['Type'] == "menu") { echo "{$level} ({$link}) - {$page['Title']}
"; - } else if ($page['Type'] == "xmenu") { + } elseif ($page['Type'] == "xmenu") { echo "{$level} [{$link}] - {$page['Title']}
"; } else { echo "{$level} {$link} - {$page['Title']}
"; diff --git a/plugins/dynamix/ShareEdit.page b/plugins/dynamix/ShareEdit.page index eb39d7695..0ac83634b 100644 --- a/plugins/dynamix/ShareEdit.page +++ b/plugins/dynamix/ShareEdit.page @@ -27,7 +27,7 @@ if ($name == "") { "exclude" => "", "useCache" => "no", "cow" => "auto"]; -} else if (array_key_exists($name, $shares)) { +} elseif (array_key_exists($name, $shares)) { /* edit existing share */ $share = $shares[$name]; } else { diff --git a/plugins/dynamix/include/DashUpdate.php b/plugins/dynamix/include/DashUpdate.php index e7a3e01ac..ec72a7350 100644 --- a/plugins/dynamix/include/DashUpdate.php +++ b/plugins/dynamix/include/DashUpdate.php @@ -181,7 +181,7 @@ case 'port': $mtu = file_get_contents("/sys/class/net/$port/mtu"); if (substr($port,0,4)=='bond') { $ports[$i++] = exec("grep -Pom1 '^Bonding Mode: \K.+' /proc/net/bonding/$port").", mtu $mtu"; - } else if ($port=='lo') { + } elseif ($port=='lo') { $ports[$i++] = str_replace('yes','loopback',exec("ethtool lo|grep -Pom1 '^\s+Link detected: \K.+'")); } else { unset($info); diff --git a/plugins/dynamix/include/DeviceList.php b/plugins/dynamix/include/DeviceList.php index 049ea2c5c..b7ee15006 100644 --- a/plugins/dynamix/include/DeviceList.php +++ b/plugins/dynamix/include/DeviceList.php @@ -92,7 +92,7 @@ function fs_info(&$disk) { if ($disk['fsStatus']=='-') { echo ""; return; - } else if ($disk['fsStatus']=='Mounted') { + } elseif ($disk['fsStatus']=='Mounted') { echo "{$disk['fsType']}"; echo "".my_scale($disk['fsSize']*1024,$unit)." $unit"; if ($display['text']%10==0) { diff --git a/plugins/dynamix/include/SmartInfo.php b/plugins/dynamix/include/SmartInfo.php index 0caf6c9dd..3b902b2a5 100644 --- a/plugins/dynamix/include/SmartInfo.php +++ b/plugins/dynamix/include/SmartInfo.php @@ -69,8 +69,8 @@ case "attributes": $color = ""; $highlight = strpos($info[8],'FAILING_NOW')!==false || ($select ? $info[5]>0 && $info[3]<=$info[5]*$level : $info[9]>0); if (in_array($info[0], $events) && $highlight) $color = " class='warn'"; - else if (in_array($info[0], $temps)) { - if ($info[9]>=$max) $color = " class='alert'"; else if ($info[9]>=$hot) $color = " class='warn'"; + elseif (in_array($info[0], $temps)) { + if ($info[9]>=$max) $color = " class='alert'"; elseif ($info[9]>=$hot) $color = " class='warn'"; } if ($info[8]=='-') $info[8] = 'Never'; if ($info[0]==9 && is_numeric($info[9])) duration($info[9]); diff --git a/plugins/dynamix/scripts/monitor b/plugins/dynamix/scripts/monitor index 8ae2ca3be..d3af5db7d 100755 --- a/plugins/dynamix/scripts/monitor +++ b/plugins/dynamix/scripts/monitor @@ -338,7 +338,7 @@ if ($retval===0) { exec("$notify -e \"Docker critical image disk utilization\" -s \"Alert [$server] - Docker image disk utilization of ${warn}%\" -d \"$info\" -i \"alert\""); $saved[$item][$name] = $warn; } - } else if ($warn>=$high2 && $high2>0) { + } elseif ($warn>=$high2 && $high2>0) { if ($warn>$last) { exec("$notify -e \"Docker high image disk utilization\" -s \"Warning [$server] - Docker image disk utilization of ${warn}%\" -d \"$info\" -i \"warning\""); $saved[$item][$name] = $warn; From 951abbc9bae638cc362f4aca53335d04a095266e Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 09:30:21 +0200 Subject: [PATCH 03/11] Updated PHP to preferred "elseif" sinlge statement --- .../DockerContainers.page | 2 +- .../include/CreateDocker.php | 4 +-- .../include/DockerClient.php | 36 +++++++++---------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/plugins/dynamix.docker.manager/DockerContainers.page b/plugins/dynamix.docker.manager/DockerContainers.page index 149e02419..f773647c1 100644 --- a/plugins/dynamix.docker.manager/DockerContainers.page +++ b/plugins/dynamix.docker.manager/DockerContainers.page @@ -150,7 +150,7 @@ img.stopped{opacity:0.3;} $updateStatus = $info[$ct['Name']]['updated']; if ($updateStatus == "false") { echo " update ready"; - } else if ($updateStatus == "true") { + } elseif ($updateStatus == "true") { echo " up-to-date"; echo ""; } else { diff --git a/plugins/dynamix.docker.manager/include/CreateDocker.php b/plugins/dynamix.docker.manager/include/CreateDocker.php index e88c05c91..c8cbebf43 100644 --- a/plugins/dynamix.docker.manager/include/CreateDocker.php +++ b/plugins/dynamix.docker.manager/include/CreateDocker.php @@ -224,12 +224,12 @@ function postToXML($post, $setOwnership = false) { $port->HostPort = $post['confValue'][$i]; $port->ContainerPort = $post['confTarget'][$i]; $port->Protocol = $post['confMode'][$i]; - } else if ($Type == "Path") { + } elseif ($Type == "Path") { $path = $xml->Data->addChild("Volume"); $path->HostDir = $post['confValue'][$i]; $path->ContainerDir = $post['confTarget'][$i]; $path->Mode = $post['confMode'][$i]; - } else if ($Type == "Variable") { + } elseif ($Type == "Variable") { $variable = $xml->Environment->addChild("Variable"); $variable->Value = $post['confValue'][$i]; $variable->Name = $post['confTarget'][$i]; diff --git a/plugins/dynamix.docker.manager/include/DockerClient.php b/plugins/dynamix.docker.manager/include/DockerClient.php index 331df8906..0b29d4560 100644 --- a/plugins/dynamix.docker.manager/include/DockerClient.php +++ b/plugins/dynamix.docker.manager/include/DockerClient.php @@ -80,9 +80,9 @@ class DockerTemplates { if ($type == "all") { $dirs[] = $dockerManPaths['templates-user']; $dirs[] = $dockerManPaths['templates-storage']; - } else if ($type == "user") { + } elseif ($type == "user") { $dirs[] = $dockerManPaths['templates-user']; - } else if ($type == "default") { + } elseif ($type == "default") { $dirs[] = $dockerManPaths['templates-storage']; } else { $dirs[] = $type; @@ -102,7 +102,7 @@ class DockerTemplates { $this->removeDir(realpath($path) . '/' . $file); } return rmdir($path); - } else if (is_file($path)) { + } elseif (is_file($path)) { return unlink($path); } return false; @@ -526,20 +526,20 @@ class DockerUpdate{ $changed = false; $DockerTemplates = new DockerTemplates(); $validElements = [ - "Support", - "Overview", - "Category", - "WebUI", - "Icon" + 0 => "Support", + 1 => "Overview", + 2 => "Category", + 3 => "WebUI", + 4 => "Icon" ]; $validAttributes = [ - "Name", - "Default", - "Description", - "Display", - "Required", - "Mask" + 0 => "Name", + 1 => "Default", + 2 => "Description", + 3 => "Display", + 4 => "Required", + 5 => "Mask" ]; // Get user template file and abort if fail @@ -575,12 +575,12 @@ class DockerUpdate{ $value = $this->xml_decode($local_element); // Values changed, updating. if ($value != $rvalue) { - $local_element[0] = $this->xml_encode($rvalue); + $local_element->{0} = $this->xml_encode($rvalue); $this->debug("Updating $name from [$value] to [$rvalue]"); $changed = true; } // Compare atributes on Config if they are in the validAttributes list - } else if ($name == "Config") { + } elseif ($name == "Config") { $type = $this->xml_decode($remote_element['Type']); $target = $this->xml_decode($remote_element['Target']); if ($type == "Port") { @@ -618,8 +618,6 @@ class DockerUpdate{ $dom->formatOutput = true; $dom->loadXML($template->asXML()); file_put_contents($file, $dom->saveXML()); - } else { - $this->debug("Template is up to date."); } } } @@ -969,7 +967,7 @@ class DockerUtil { if (strpos($strRepo, 'sha256:') === 0) { // sha256 was provided instead of actual repo name so truncate it for display: $strRepo = substr(str_replace('sha256:', '', $strRepo), 0, 12); - } else if (strpos($strRepo, '/') === false) { + } elseif (strpos($strRepo, '/') === false) { // Prefix library/ if there's no author (maybe a Docker offical image?) $strRepo = 'library/'.$strRepo; } From 429ec85b184491ebe5ab057d338bada6c344f54a Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 09:31:42 +0200 Subject: [PATCH 04/11] Updated PHP to preferred "elseif" single statement --- plugins/dynamix.plugin.manager/scripts/plugin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix.plugin.manager/scripts/plugin b/plugins/dynamix.plugin.manager/scripts/plugin index a99772aa7..ac5095f2f 100755 --- a/plugins/dynamix.plugin.manager/scripts/plugin +++ b/plugins/dynamix.plugin.manager/scripts/plugin @@ -245,7 +245,7 @@ function plugin($method, $plugin_file, &$error) { // skip if not our $method if (isset($file->attributes()->Method)) { if (!in_array($method, explode(" ", $file->attributes()->Method))) continue; - } else if ($method != "install") continue; + } elseif ($method != "install") continue; $name = $file->attributes()->Name; // bergware - check unRAID version dependency (if present) $min = $file->attributes()->Min; From eed3b9e3167e0e3e604e3f8e11cc2b2d6e6f3580 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 09:36:59 +0200 Subject: [PATCH 05/11] Updated PHP to preferred "elseif" single statement --- plugins/dynamix.vm.manager/VMMachines.page | 2 +- plugins/dynamix.vm.manager/VMajax.php | 18 +++++++++--------- plugins/dynamix.vm.manager/VMedit.php | 2 +- plugins/dynamix.vm.manager/classes/libvirt.php | 2 +- .../classes/libvirt_helpers.php | 2 +- .../templates/Custom.form.php | 2 +- .../templates/LibreELEC.form.php | 14 +++++++------- .../templates/OpenELEC.form.php | 14 +++++++------- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/plugins/dynamix.vm.manager/VMMachines.page b/plugins/dynamix.vm.manager/VMMachines.page index 235e5b0a8..22d540fd2 100644 --- a/plugins/dynamix.vm.manager/VMMachines.page +++ b/plugins/dynamix.vm.manager/VMMachines.page @@ -196,7 +196,7 @@ if ($action) { if (!empty($vmtemplateicon)) { if (file_exists($vmtemplateicon)) { $vmicon = $vmtemplateicon; - } else if (file_exists("$docroot/plugins/dynamix.vm.manager/templates/images/".$vmtemplateicon)) { + } elseif (file_exists("$docroot/plugins/dynamix.vm.manager/templates/images/".$vmtemplateicon)) { $vmicon = "/plugins/dynamix.vm.manager/templates/images/".$vmtemplateicon; } } diff --git a/plugins/dynamix.vm.manager/VMajax.php b/plugins/dynamix.vm.manager/VMajax.php index e261e1880..72fddb480 100644 --- a/plugins/dynamix.vm.manager/VMajax.php +++ b/plugins/dynamix.vm.manager/VMajax.php @@ -293,7 +293,7 @@ switch ($action) { $arrResponse['dirty-flag'] = $json_info['dirty-flag']; $arrResponse['resizable'] = true; } - } else if (is_block($file)) { + } elseif (is_block($file)) { $strDevSize = trim(shell_exec("blockdev --getsize64 " . escapeshellarg($file))); if (!empty($strDevSize) && is_numeric($strDevSize)) { $arrResponse['actual-size'] = (int)$strDevSize; @@ -459,9 +459,9 @@ switch ($action) { if (empty($arrDownloadVirtIO)) { $arrResponse = ['error' => 'Unknown version: ' . $_POST['download_version']]; - } else if (empty($_POST['download_path'])) { + } elseif (empty($_POST['download_path'])) { $arrResponse = ['error' => 'Specify a ISO storage path first']; - } else if (!is_dir($_POST['download_path'])) { + } elseif (!is_dir($_POST['download_path'])) { $arrResponse = ['error' => 'ISO storage path doesn\'t exist, please create the user share (or empty folder) first']; } else { @mkdir($_POST['download_path'], 0777, true); @@ -539,12 +539,12 @@ switch ($action) { $arrResponse['status'] = 'Downloading ... ' . $strPercent . '%'; - } else if (pgrep($strVerifyPgrep)) { + } elseif (pgrep($strVerifyPgrep)) { // Status = running md5 check $arrResponse['status'] = 'Verifying ... '; - } else if (file_exists($strMD5StatusFile)) { + } elseif (file_exists($strMD5StatusFile)) { // Status = running extract $arrResponse['status'] = 'Cleanup ... '; @@ -560,7 +560,7 @@ switch ($action) { } - } else if (!file_exists($strMD5File)) { + } elseif (!file_exists($strMD5File)) { // Status = running md5 check $arrResponse['status'] = 'Downloading ... 100%'; @@ -578,7 +578,7 @@ switch ($action) { } - } else if (!$boolCheckOnly) { + } elseif (!$boolCheckOnly) { if (!pgrep($strInstallScriptPgrep)) { @@ -608,9 +608,9 @@ switch ($action) { if (empty($arrDownloadVirtIO)) { $arrResponse = ['error' => 'Unknown version: ' . $_POST['download_version']]; - } else if (empty($_POST['download_path'])) { + } elseif (empty($_POST['download_path'])) { $arrResponse = ['error' => 'ISO storage path was empty']; - } else if (!is_dir($_POST['download_path'])) { + } elseif (!is_dir($_POST['download_path'])) { $arrResponse = ['error' => 'ISO storage path doesn\'t exist']; } else { $strInstallScriptPgrep = '-f "VirtIOWin_' . $strKeyName . '_install.sh"'; diff --git a/plugins/dynamix.vm.manager/VMedit.php b/plugins/dynamix.vm.manager/VMedit.php index 07591ff8a..827d9f41d 100644 --- a/plugins/dynamix.vm.manager/VMedit.php +++ b/plugins/dynamix.vm.manager/VMedit.php @@ -43,7 +43,7 @@ if (!empty($_GET['uuid'])) { if (!empty($strIcon)) { if (is_file($strIcon)) { $strIconURL = $strIcon; - } else if (is_file("$docroot/plugins/dynamix.vm.manager/templates/images/" . $strIcon)) { + } elseif (is_file("$docroot/plugins/dynamix.vm.manager/templates/images/" . $strIcon)) { $strIconURL = '/plugins/dynamix.vm.manager/templates/images/' . $strIcon; } } else { diff --git a/plugins/dynamix.vm.manager/classes/libvirt.php b/plugins/dynamix.vm.manager/classes/libvirt.php index 11a51ed90..fd3184d31 100644 --- a/plugins/dynamix.vm.manager/classes/libvirt.php +++ b/plugins/dynamix.vm.manager/classes/libvirt.php @@ -309,7 +309,7 @@ foreach($domain['vcpu'] as $i => $vcpu) { $vcpupinstr .= ""; } - } else if (!empty($domain['vcpus'])) { + } elseif (!empty($domain['vcpus'])) { $vcpus = $domain['vcpus']; for ($i=0; $i < $vcpus; $i++) { $vcpupinstr .= ""; diff --git a/plugins/dynamix.vm.manager/classes/libvirt_helpers.php b/plugins/dynamix.vm.manager/classes/libvirt_helpers.php index 2ac532e5b..3020aeeb3 100644 --- a/plugins/dynamix.vm.manager/classes/libvirt_helpers.php +++ b/plugins/dynamix.vm.manager/classes/libvirt_helpers.php @@ -585,7 +585,7 @@ if (preg_match('/.+\[(?P.+)\]/', $arrMatch['productname'], $arrGPUMatch)) { $arrMatch['productname'] = $arrGPUMatch['gpuname']; } - } else if (preg_match($arrWhitelistAudioClassIDregex, $arrMatch['typeid'])) { + } elseif (preg_match($arrWhitelistAudioClassIDregex, $arrMatch['typeid'])) { $strClass = 'audio'; } diff --git a/plugins/dynamix.vm.manager/templates/Custom.form.php b/plugins/dynamix.vm.manager/templates/Custom.form.php index 4017a0f11..9039508e8 100644 --- a/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1007,7 +1007,7 @@ $extra = ''; if (count(array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) { $extra .= ' checked="checked"'; - } else if (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { + } elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { //$extra .= ' disabled="disabled"'; continue; } diff --git a/plugins/dynamix.vm.manager/templates/LibreELEC.form.php b/plugins/dynamix.vm.manager/templates/LibreELEC.form.php index f9df0128a..7471d8a6c 100644 --- a/plugins/dynamix.vm.manager/templates/LibreELEC.form.php +++ b/plugins/dynamix.vm.manager/templates/LibreELEC.form.php @@ -83,7 +83,7 @@ if (empty($arrDownloadLibreELEC)) { $arrResponse = ['error' => 'Unknown version: ' . $_POST['download_version']]; - } else if (empty($_POST['download_path'])) { + } elseif (empty($_POST['download_path'])) { $arrResponse = ['error' => 'Please choose a folder the LibreELEC image will download to']; } else { @mkdir($_POST['download_path'], 0777, true); @@ -162,7 +162,7 @@ } } - } else if (file_exists($strTempFile)) { + } elseif (file_exists($strTempFile)) { if (pgrep($strDownloadPgrep)) { @@ -175,12 +175,12 @@ $arrResponse['status'] = 'Downloading ... ' . $strPercent . '%'; - } else if (pgrep($strVerifyPgrep)) { + } elseif (pgrep($strVerifyPgrep)) { // Status = running md5 check $arrResponse['status'] = 'Verifying ... '; - } else if (file_exists($strMD5StatusFile)) { + } elseif (file_exists($strMD5StatusFile)) { // Status = running extract $arrResponse['status'] = 'Extracting ... '; @@ -198,7 +198,7 @@ } } - } else if (!file_exists($strMD5File)) { + } elseif (!file_exists($strMD5File)) { // Status = running md5 check $arrResponse['status'] = 'Downloading ... 100%'; @@ -214,7 +214,7 @@ } - } else if (!$boolCheckOnly) { + } elseif (!$boolCheckOnly) { if (!pgrep($strInstallScriptPgrep)) { @@ -898,7 +898,7 @@ $extra = ''; if (count(array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) { $extra .= ' checked="checked"'; - } else if (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { + } elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { //$extra .= ' disabled="disabled"'; continue; } diff --git a/plugins/dynamix.vm.manager/templates/OpenELEC.form.php b/plugins/dynamix.vm.manager/templates/OpenELEC.form.php index 252bc2286..3a359f475 100644 --- a/plugins/dynamix.vm.manager/templates/OpenELEC.form.php +++ b/plugins/dynamix.vm.manager/templates/OpenELEC.form.php @@ -83,7 +83,7 @@ if (empty($arrDownloadOpenELEC)) { $arrResponse = ['error' => 'Unknown version: ' . $_POST['download_version']]; - } else if (empty($_POST['download_path'])) { + } elseif (empty($_POST['download_path'])) { $arrResponse = ['error' => 'Please choose a folder the OpenELEC image will download to']; } else { @mkdir($_POST['download_path'], 0777, true); @@ -162,7 +162,7 @@ } } - } else if (file_exists($strTempFile)) { + } elseif (file_exists($strTempFile)) { if (pgrep($strDownloadPgrep)) { @@ -175,12 +175,12 @@ $arrResponse['status'] = 'Downloading ... ' . $strPercent . '%'; - } else if (pgrep($strVerifyPgrep)) { + } elseif (pgrep($strVerifyPgrep)) { // Status = running md5 check $arrResponse['status'] = 'Verifying ... '; - } else if (file_exists($strMD5StatusFile)) { + } elseif (file_exists($strMD5StatusFile)) { // Status = running extract $arrResponse['status'] = 'Extracting ... '; @@ -198,7 +198,7 @@ } } - } else if (!file_exists($strMD5File)) { + } elseif (!file_exists($strMD5File)) { // Status = running md5 check $arrResponse['status'] = 'Downloading ... 100%'; @@ -214,7 +214,7 @@ } - } else if (!$boolCheckOnly) { + } elseif (!$boolCheckOnly) { if (!pgrep($strInstallScriptPgrep)) { @@ -898,7 +898,7 @@ $extra = ''; if (count(array_filter($arrConfig['pci'], function($arr) use ($arrDev) { return ($arr['id'] == $arrDev['id']); }))) { $extra .= ' checked="checked"'; - } else if (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { + } elseif (!in_array($arrDev['driver'], ['pci-stub', 'vfio-pci'])) { //$extra .= ' disabled="disabled"'; continue; } From fb69a23201127e709403b0a16f499cc2f0642bb8 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 10:54:34 +0200 Subject: [PATCH 06/11] Added User Shares selection to NewPerm utility Note: default setting is changed to "nothing selected" --- plugins/dynamix/NewPerms.page | 48 +++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/plugins/dynamix/NewPerms.page b/plugins/dynamix/NewPerms.page index 336a7adc6..60912f1fd 100644 --- a/plugins/dynamix/NewPerms.page +++ b/plugins/dynamix/NewPerms.page @@ -20,30 +20,40 @@ function data_disks($disk) { ?> -This is a one-time action to be taken after upgrading from a pre-5.0 unRAID server -release to version 5.0. It is also useful for restoring default ownership/permissions on files and +This is a mandatory one-time action to be taken after upgrading from a pre-5.0 unRAID server release to unRAID v5 or a later release. +Select **ALL DISKS** when performing this one-time action. + +This utility is also useful for restoring default ownership/permissions on files and directories when transitioning back from Active Directory to non-Active Directory integration. -This utility starts a background process that goes to each of your data disks and cache disk -and changes file and directory ownership to nobody/users (i.e., uid/gid to 99/100), and sets permissions +The utility starts a background process that goes to each of your data disks and cache disks and selected user shares +and changes file and directory ownership to *nobody/users* (i.e., uid/gid to 99/100), and sets permissions as follows: ~~~ For directories: @@ -60,16 +70,28 @@ Clicking **Start** will open another window and start the background process. Closing the window before completion will terminate the background process - so don't do that. This process can take a long time if you have many files.
+ +Disks    - + + + +User Shares + + +

Array must be Started to change permissions. From 4bf7fd559b0e18987623f57e4d5e6c68d2331f9a Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 11:44:22 +0200 Subject: [PATCH 07/11] Added Sync Errors to parity history --- plugins/dynamix/ArrayOperation.page | 14 +++++++------- plugins/dynamix/DashStats.page | 6 +++--- plugins/dynamix/include/DeviceList.php | 3 ++- plugins/dynamix/include/Helpers.php | 2 +- plugins/dynamix/include/ParityHistory.php | 8 ++++---- plugins/dynamix/scripts/monitor | 8 ++++---- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/plugins/dynamix/ArrayOperation.page b/plugins/dynamix/ArrayOperation.page index 371fb5b39..3ad59c54b 100644 --- a/plugins/dynamix/ArrayOperation.page +++ b/plugins/dynamix/ArrayOperation.page @@ -194,27 +194,27 @@ toggle_diskio(true); if ($var['sbSyncExit']!=0):?> - + Last check incomplete on , finding error.
Error code: - + Last checked on
Duration: - - + - Last checked on , finding error. + Last checked on , finding error.
Duration: - Last check incomplete on , finding error. + Last check incomplete on , finding error.
Error code: @@ -223,7 +223,7 @@ toggle_diskio(true); $speed = $duration?my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/sec":'';?> - + Last check completed on , finding error.
Duration: diff --git a/plugins/dynamix/DashStats.page b/plugins/dynamix/DashStats.page index f1fcc8962..eae40fd41 100644 --- a/plugins/dynamix/DashStats.page +++ b/plugins/dynamix/DashStats.page @@ -75,12 +75,12 @@ function parity_status() { } if ($var['sbSynced2']==0) { $idle = $var['mdResync']==0; - list($entry,$duration,$speed,$status) = explode('|', read_parity_log($var['sbSynced'],!$idle)); + list($entry,$duration,$speed,$status,$error) = explode('|', read_parity_log($var['sbSynced'],!$idle)); if ($status==0) { - echo "".($idle ? "Last checked on " : "Activity started on ")."".my_time($var['sbSynced']).day_count($var['sbSynced']).", finding {$var['sbSyncErrs']} error".($var['sbSyncErrs']==1?'.':'s.'); + echo "".($idle ? "Last checked on " : "Activity started on ")."".my_time($var['sbSynced']).day_count($var['sbSynced']).", finding $error error".($error==1?'.':'s.'); echo "
".($idle ? "Duration: " : "Last result: ").my_check($duration,$speed).""; } else { - echo "Last check incomplete on ".my_time($var['sbSynced']).day_count($var['sbSynced']).", finding {$var['sbSyncErrs']} error".($var['sbSyncErrs']==1?'.':'s.'); + echo "Last check incomplete on ".my_time($var['sbSynced']).day_count($var['sbSynced']).", finding $error error".($error==1?'.':'s.'); echo "
Error code: $status"; } } else { diff --git a/plugins/dynamix/include/DeviceList.php b/plugins/dynamix/include/DeviceList.php index b7ee15006..297407077 100644 --- a/plugins/dynamix/include/DeviceList.php +++ b/plugins/dynamix/include/DeviceList.php @@ -380,8 +380,9 @@ case 'parity': $duration = $var['sbSynced2'] - $var['sbSynced']; $status = $var['sbSyncExit']; $speed = ($status==0) ? my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/s" : "Unavailable"; + $error = $var['sbSyncErrs']; $year = date('Y',$var['sbSynced2']); - if ($status==0||file_exists($log)) file_put_contents($log,"$year $timestamp|$duration|$speed|$status\n",FILE_APPEND); + if ($status==0||file_exists($log)) file_put_contents($log,"$year $timestamp|$duration|$speed|$status|$error\n",FILE_APPEND); } break; } diff --git a/plugins/dynamix/include/Helpers.php b/plugins/dynamix/include/Helpers.php index 0ad30f35c..86a909e95 100644 --- a/plugins/dynamix/include/Helpers.php +++ b/plugins/dynamix/include/Helpers.php @@ -165,7 +165,7 @@ function read_parity_log($epoch,$busy=false) { } fclose($handle); } - return $line ?: ($last ?: '0|0|0|0'); + return $line ?: $last ?: '0|0|0|0|0'; } function urlencode_path($path) { return str_replace("%2F", "/", urlencode($path)); diff --git a/plugins/dynamix/include/ParityHistory.php b/plugins/dynamix/include/ParityHistory.php index 8511c45bb..8f9dcf6f8 100644 --- a/plugins/dynamix/include/ParityHistory.php +++ b/plugins/dynamix/include/ParityHistory.php @@ -33,23 +33,23 @@ function my_duration($time) { - +0||$status<>0) $list[] = ""; + if ($duration>0||$status<>0) $list[] = ""; } fclose($handle); } if ($list) for ($i=count($list); $i>=0; --$i) echo $list[$i]; else - echo ""; + echo ""; ?>
diff --git a/plugins/dynamix/scripts/monitor b/plugins/dynamix/scripts/monitor index d3af5db7d..204f0e1fe 100755 --- a/plugins/dynamix/scripts/monitor +++ b/plugins/dynamix/scripts/monitor @@ -70,7 +70,7 @@ function my_check($time,$speed) { $secs = $hmss%60; return plus($days,'day',($hour|$mins|$secs)==0).plus($hour,'hour',($mins|$secs)==0).plus($mins,'minute',$secs==0).plus($secs,'second',true).". Average speed: $speed"; } -function read_write_parity_log($epoch,$duration,$speed,$status) { +function read_write_parity_log($epoch,$duration,$speed,$status,$error) { $log = '/boot/config/parity-checks.log'; $timestamp = str_replace(['.0','.'],[' ',' '],date('M.d H:i:s',$epoch)); if (file_exists($log)) { @@ -82,7 +82,7 @@ function read_write_parity_log($epoch,$duration,$speed,$status) { } if (empty($line)) { $year = date('Y',$epoch); - $line = "$year $timestamp|$duration|$speed|$status"; + $line = "$year $timestamp|$duration|$speed|$status|$error"; if ($status==0||file_exists($log)) file_put_contents($log,"$line\n",FILE_APPEND); } return $line; @@ -295,10 +295,10 @@ if ($var['mdResync']>0) { $duration = $var['sbSynced2'] - $var['sbSynced']; $status = $var['sbSyncExit']; $speed = $status==0 ? my_scale($var['mdResyncSize']*1024/$duration,$unit,1)." $unit/s" : "Unavailable"; - list($entry,$duration,$speed,$status) = explode('|', read_write_parity_log($var['sbSynced2'],$duration,$speed,$status)); + list($entry,$duration,$speed,$status,$error) = explode('|', read_write_parity_log($var['sbSynced2'],$duration,$speed,$status,$var['sbSyncErrs'])); $info = $status==0 ? "Duration: ".my_check($duration, $speed) : ($status==-4 ? "Canceled" : "Error code: $status"); $level = ($status==0 && $var['sbSyncErrs']==0) ? "normal" : "warning"; - exec("$notify -e \"unRAID $last\" -s \"Notice [$server] - $last finished ({$var['sbSyncErrs']} errors)\" -d \"$info\" -i \"$level\""); + exec("$notify -e \"unRAID $last\" -s \"Notice [$server] - $last finished ($error errors)\" -d \"$info\" -i \"$level\""); unset($saved[$item][$name]); } } From b1abd0dce7850dd0dce6041be5d16e8e8f0aed92 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 12:21:45 +0200 Subject: [PATCH 08/11] Fix error message when RepoTags object doesn't exist --- plugins/dynamix.docker.manager/include/DockerClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/dynamix.docker.manager/include/DockerClient.php b/plugins/dynamix.docker.manager/include/DockerClient.php index 0b29d4560..7d3cea091 100644 --- a/plugins/dynamix.docker.manager/include/DockerClient.php +++ b/plugins/dynamix.docker.manager/include/DockerClient.php @@ -939,7 +939,7 @@ class DockerClient { $c["ParentId"] = substr(str_replace('sha256:', '', $obj['ParentId']), 0, 12); $c["Size"] = $this->formatBytes($obj['Size']); $c["VirtualSize"] = $this->formatBytes($obj['VirtualSize']); - $c["Tags"] = array_map("htmlentities", $obj['RepoTags']); + $c["Tags"] = isset($obj['RepoTags']) ? array_map("htmlentities", $obj['RepoTags']) : array(); $c["Repository"] = vsprintf('%1$s/%2$s', preg_split("#[:\/]#", DockerUtil::ensureImageTag($obj['RepoTags'][0]))); $c["usedBy"] = $this->usedBy($c["Id"]); From 313b047e34280dc74143aec2ffc932d4ad86038f Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 19:39:26 +0200 Subject: [PATCH 09/11] Change checkbox for popup window in NewPerms --- plugins/dynamix/NewPerms.page | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/dynamix/NewPerms.page b/plugins/dynamix/NewPerms.page index 60912f1fd..e6b699522 100644 --- a/plugins/dynamix/NewPerms.page +++ b/plugins/dynamix/NewPerms.page @@ -25,17 +25,15 @@ function setNewPerms(form) { if (item.selected) { if (dirs.length) dirs += '|'; dirs += item.value; - item.selected = false; } } for (var i=1,item; item=form.includeShare.options[i]; i++) { if (item.selected) { if (dirs.length) dirs += '|'; dirs += item.value; - item.selected = false; } } - if (dirs) openBox('/webGui/scripts/newperms&arg1='+dirs,'New Permissions',490,430); + if (dirs) swal({title:'Proceed?',text:'This will update folder & file permissions',type:'warning',showCancelButton:true},function(){openBox('/webGui/scripts/newperms&arg1='+dirs,'New Permissions',490,430);}); } $(function() { $('#s1').dropdownchecklist({emptyText:'None', width:131, firstItemChecksAll:true, explicitClose:'...close'}); @@ -69,7 +67,7 @@ Clicking **Start** will open another window and start the background process. Closing the window before completion will terminate the background process - so don't do that. This process can take a long time if you have many files. - + Disks

- - -Array must be Started to change permissions. + + -Yes I want to do this + Array must be Started to change permissions. From dc5e01849e84cad725a0ea3611aa0f6533bb224d Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 19:54:17 +0200 Subject: [PATCH 10/11] Change checkbox for popup window in NewPerms --- plugins/dynamix/NewPerms.page | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/dynamix/NewPerms.page b/plugins/dynamix/NewPerms.page index e6b699522..06770780d 100644 --- a/plugins/dynamix/NewPerms.page +++ b/plugins/dynamix/NewPerms.page @@ -33,7 +33,7 @@ function setNewPerms(form) { dirs += item.value; } } - if (dirs) swal({title:'Proceed?',text:'This will update folder & file permissions',type:'warning',showCancelButton:true},function(){openBox('/webGui/scripts/newperms&arg1='+dirs,'New Permissions',490,430);}); + if (dirs) swal({title:'Proceed?',text:'This will update folder & file permissions',type:'warning',showCancelButton:true},function(){openBox('/webGui/scripts/newperms&arg1='+dirs,'New Permissions',490,430,true);}); } $(function() { $('#s1').dropdownchecklist({emptyText:'None', width:131, firstItemChecksAll:true, explicitClose:'...close'}); @@ -91,8 +91,8 @@ Closing the window before completion will terminate the background process - so

- + - Array must be Started to change permissions. + Array must be Started to change permissions. From 7a93084653e9396a1a62ae481101be71a32fe720 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 29 Oct 2016 21:17:58 +0200 Subject: [PATCH 11/11] Improved VM/Docker text in network settings --- plugins/dynamix/Eth0.page | 6 +++--- plugins/dynamix/EthX.page | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/dynamix/Eth0.page b/plugins/dynamix/Eth0.page index ccb4ca2bd..ea6d51801 100644 --- a/plugins/dynamix/Eth0.page +++ b/plugins/dynamix/Eth0.page @@ -41,8 +41,8 @@ foreach ($ports as $port) { } } // enable interface only when VMs and Docker are stopped -$service = exec("pgrep libvirt") ? 'VMs' : ''; -$service .= exec("pgrep docker") ? ($service ? ' and ' : '').'Docker' : ''; +$service = exec("pgrep libvirt") ? 'VM manager' : ''; +$service .= exec("pgrep docker") ? ($service ? ' and ' : '').'Docker service' : ''; // eth0 port status $no_eth0 = exec("ip link show eth0|grep -Pom1 '(NO-CARRIER|state DOWN)'"); @@ -536,5 +536,5 @@ Network mask:   -: Stopped to change" : ""?> +: Stopped to change (see Settings)" : ""?> diff --git a/plugins/dynamix/EthX.page b/plugins/dynamix/EthX.page index af091294e..eab20b43f 100644 --- a/plugins/dynamix/EthX.page +++ b/plugins/dynamix/EthX.page @@ -263,5 +263,5 @@ Network mask:   -: Stopped to change"?> +: Stopped to change (see Settings)" : ""?>