From a29c8dcce16e41a0c6abc3421991a91bb8afebc9 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Sat, 22 Jul 2017 11:59:57 -0500 Subject: [PATCH] Fix virtio iso, libreelec and openelec download progress display --- plugins/dynamix.vm.manager/VMajax.php | 14 +++++++------- .../templates/LibreELEC.form.php | 14 +++++++------- .../dynamix.vm.manager/templates/OpenELEC.form.php | 14 +++++++------- plugins/dynamix/include/Helpers.php | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/plugins/dynamix.vm.manager/VMajax.php b/plugins/dynamix.vm.manager/VMajax.php index da505dc47..6110ae58f 100644 --- a/plugins/dynamix.vm.manager/VMajax.php +++ b/plugins/dynamix.vm.manager/VMajax.php @@ -507,7 +507,7 @@ switch ($action) { if (!file_exists($strLogFile)) { - if (!pgrep($strDownloadPgrep)) { + if (!pgrep($strDownloadPgrep, false)) { // Status = done $arrResponse['status'] = 'Done'; @@ -523,7 +523,7 @@ switch ($action) { } else { - if (pgrep($strDownloadPgrep)) { + if (pgrep($strDownloadPgrep, false)) { // Get Download percent completed $intSize = filesize($strTargetFile); @@ -534,7 +534,7 @@ switch ($action) { $arrResponse['status'] = 'Downloading ... ' . $strPercent . '%'; - } elseif (pgrep($strVerifyPgrep)) { + } elseif (pgrep($strVerifyPgrep, false)) { // Status = running md5 check $arrResponse['status'] = 'Verifying ... '; @@ -560,7 +560,7 @@ switch ($action) { // Status = running md5 check $arrResponse['status'] = 'Downloading ... 100%'; - if (!pgrep($strInstallScriptPgrep) && !$boolCheckOnly) { + if (!pgrep($strInstallScriptPgrep, false) && !$boolCheckOnly) { // Run all commands file_put_contents($strInstallScript, $strAllCmd); @@ -575,7 +575,7 @@ switch ($action) { } elseif (!$boolCheckOnly) { - if (!pgrep($strInstallScriptPgrep)) { + if (!pgrep($strInstallScriptPgrep, false)) { // Run all commands file_put_contents($strInstallScript, $strAllCmd); @@ -588,7 +588,7 @@ switch ($action) { } - $arrResponse['pid'] = pgrep($strInstallScriptPgrep); + $arrResponse['pid'] = pgrep($strInstallScriptPgrep, false); } break; @@ -609,7 +609,7 @@ switch ($action) { $arrResponse = ['error' => 'ISO storage path doesn\'t exist']; } else { $strInstallScriptPgrep = '-f "VirtIOWin_' . $strKeyName . '_install.sh"'; - $pid = pgrep($strInstallScriptPgrep); + $pid = pgrep($strInstallScriptPgrep, false); if (!$pid) { $arrResponse = ['error' => 'Not running']; } else { diff --git a/plugins/dynamix.vm.manager/templates/LibreELEC.form.php b/plugins/dynamix.vm.manager/templates/LibreELEC.form.php index 8ce979f83..708324b31 100644 --- a/plugins/dynamix.vm.manager/templates/LibreELEC.form.php +++ b/plugins/dynamix.vm.manager/templates/LibreELEC.form.php @@ -149,7 +149,7 @@ $arrResponse['localfolder'] = dirname($strExtractedFile); } else { - if (pgrep($strExtractPgrep)) { + if (pgrep($strExtractPgrep, false)) { // Status = running extract $arrResponse['status'] = 'Extracting ... '; @@ -164,7 +164,7 @@ } elseif (file_exists($strTempFile)) { - if (pgrep($strDownloadPgrep)) { + if (pgrep($strDownloadPgrep, false)) { // Get Download percent completed $intSize = filesize($strTempFile); @@ -175,7 +175,7 @@ $arrResponse['status'] = 'Downloading ... ' . $strPercent . '%'; - } elseif (pgrep($strVerifyPgrep)) { + } elseif (pgrep($strVerifyPgrep, false)) { // Status = running md5 check $arrResponse['status'] = 'Verifying ... '; @@ -185,7 +185,7 @@ // Status = running extract $arrResponse['status'] = 'Extracting ... '; - if (!pgrep($strExtractPgrep)) { + if (!pgrep($strExtractPgrep, false)) { // Examine md5 status $strMD5StatusContents = file_get_contents($strMD5StatusFile); @@ -203,7 +203,7 @@ // Status = running md5 check $arrResponse['status'] = 'Downloading ... 100%'; - if (!pgrep($strInstallScriptPgrep) && !$boolCheckOnly) { + if (!pgrep($strInstallScriptPgrep, false) && !$boolCheckOnly) { // Run all commands file_put_contents($strInstallScript, $strAllCmd); @@ -216,7 +216,7 @@ } elseif (!$boolCheckOnly) { - if (!pgrep($strInstallScriptPgrep)) { + if (!pgrep($strInstallScriptPgrep, false)) { // Run all commands file_put_contents($strInstallScript, $strAllCmd); @@ -229,7 +229,7 @@ } - $arrResponse['pid'] = pgrep($strInstallScriptPgrep); + $arrResponse['pid'] = pgrep($strInstallScriptPgrep, false); } diff --git a/plugins/dynamix.vm.manager/templates/OpenELEC.form.php b/plugins/dynamix.vm.manager/templates/OpenELEC.form.php index 932575919..b640dd689 100644 --- a/plugins/dynamix.vm.manager/templates/OpenELEC.form.php +++ b/plugins/dynamix.vm.manager/templates/OpenELEC.form.php @@ -149,7 +149,7 @@ $arrResponse['localfolder'] = dirname($strExtractedFile); } else { - if (pgrep($strExtractPgrep)) { + if (pgrep($strExtractPgrep, false)) { // Status = running extract $arrResponse['status'] = 'Extracting ... '; @@ -164,7 +164,7 @@ } elseif (file_exists($strTempFile)) { - if (pgrep($strDownloadPgrep)) { + if (pgrep($strDownloadPgrep, false)) { // Get Download percent completed $intSize = filesize($strTempFile); @@ -175,7 +175,7 @@ $arrResponse['status'] = 'Downloading ... ' . $strPercent . '%'; - } elseif (pgrep($strVerifyPgrep)) { + } elseif (pgrep($strVerifyPgrep, false)) { // Status = running md5 check $arrResponse['status'] = 'Verifying ... '; @@ -185,7 +185,7 @@ // Status = running extract $arrResponse['status'] = 'Extracting ... '; - if (!pgrep($strExtractPgrep)) { + if (!pgrep($strExtractPgrep, false)) { // Examine md5 status $strMD5StatusContents = file_get_contents($strMD5StatusFile); @@ -203,7 +203,7 @@ // Status = running md5 check $arrResponse['status'] = 'Downloading ... 100%'; - if (!pgrep($strInstallScriptPgrep) && !$boolCheckOnly) { + if (!pgrep($strInstallScriptPgrep, false) && !$boolCheckOnly) { // Run all commands file_put_contents($strInstallScript, $strAllCmd); @@ -216,7 +216,7 @@ } elseif (!$boolCheckOnly) { - if (!pgrep($strInstallScriptPgrep)) { + if (!pgrep($strInstallScriptPgrep, false)) { // Run all commands file_put_contents($strInstallScript, $strAllCmd); @@ -229,7 +229,7 @@ } - $arrResponse['pid'] = pgrep($strInstallScriptPgrep); + $arrResponse['pid'] = pgrep($strInstallScriptPgrep, false); } diff --git a/plugins/dynamix/include/Helpers.php b/plugins/dynamix/include/Helpers.php index b88ec1a7f..42ea00499 100644 --- a/plugins/dynamix/include/Helpers.php +++ b/plugins/dynamix/include/Helpers.php @@ -170,8 +170,8 @@ function read_parity_log($epoch,$busy=false) { function urlencode_path($path) { return str_replace("%2F", "/", urlencode($path)); } -function pgrep($process_name) { - $pid = exec("pgrep ".escapeshellarg($process_name), $output, $retval); +function pgrep($process_name,$escape_arg=true) { + $pid = exec("pgrep ".($escape_arg?escapeshellarg($process_name):$process_name), $output, $retval); return $retval == 0 ? $pid : false; } function input_secure_users($sec) {