From e2bbb5d09a9f8fc5af92b97dc15fdf465502ad9f Mon Sep 17 00:00:00 2001 From: Squidly271 Date: Wed, 21 Jul 2021 11:15:54 -0400 Subject: [PATCH] Diagnostics: Include current plugin versions --- plugins/dynamix/scripts/diagnostics | 39 ++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/plugins/dynamix/scripts/diagnostics b/plugins/dynamix/scripts/diagnostics index 29284ddc3..e9c556981 100755 --- a/plugins/dynamix/scripts/diagnostics +++ b/plugins/dynamix/scripts/diagnostics @@ -88,6 +88,24 @@ function cache_filter($disks) { function pools_filter($disks) { return array_unique(array_map('prefix',array_keys(cache_filter($disks)))); } +function download_url($url, $path = "", $bg = false, $timeout = 15) { + $ch = curl_init(); + curl_setopt($ch,CURLOPT_URL,$url); + curl_setopt($ch,CURLOPT_FRESH_CONNECT,true); + curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10); + curl_setopt($ch,CURLOPT_TIMEOUT,$timeout); + curl_setopt($ch,CURLOPT_ENCODING,""); + curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + + $out = curl_exec($ch); + curl_close($ch); + if ( $path ) + file_put_contents($path,$out); + + return $out ?: false; +} if ($cli) { // script is called from CLI @@ -277,9 +295,28 @@ foreach (pools_filter($disks) as $pool) { } } // create installed plugin information +$pluginList = json_decode(download_url("https://raw.githubusercontent.com/Squidly271/AppFeed/master/pluginList.json"),true); +if ( ! $pluginList ) + $installedPlugins = "Could not download current plugin versions\r\n\r\n"; + $plugins = glob("/var/log/plugins/*.plg"); foreach ($plugins as $plugin) { - $installedPlugins .= basename($plugin)." - ".exert("plugin version ".escapeshellarg($plugin))."\r\n"; + $plgVer = exert("plugin version ".escapeshellarg($plugin)); + $plgURL = exert("plugin pluginURL ".escapeshellarg($plugin)); + + $installedPlugins .= basename($plugin)." - $plgVer"; + if ( ! $pluginList[$plgURL] && basename($plugin) !== "unRAIDServer.plg") + $installedPlugins .= " (Unknown to Community Applications)"; + if ( $pluginList[$plgURL]['blacklist'] ) + $installedPlugins .= " (Blacklisted)"; + if ( $pluginList[$plgURL]['deprecated'] ) + $installedPlugins .= " (Deprecated)"; + if ( $pluginList[$plgURL]['version'] > $plgVer ) + $installedPlugins .= " (Update available: {$pluginList[$plgURL]['version']})"; + elseif ($pluginList[$plgURL]) + $installedPlugins .= " (Up to date)"; + + $installedPlugins .= "\r\n"; } $installedPlugins = $installedPlugins ?: "No additional Plugins Installed"; file_put_contents("/$diag/system/plugins.txt",$installedPlugins);