Plugin & Docker checks

This commit is contained in:
Squidly271
2020-07-09 13:35:00 -04:00
parent fc26e94838
commit 559dc2f8c3
2 changed files with 29 additions and 8 deletions

View File

@@ -12,8 +12,18 @@
*/
?>
<?
session_start();
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
$unraid = parse_plugin_cfg('dynamix', true);
// Multi-language support
$_SESSION['locale'] = $unraid['display']['locale'];
$_SERVER['REQUEST_URI'] = "scripts";
require_once "$docroot/webGui/include/Translations.php";
exec("pgrep docker", $pid);
if (count($pid) == 1) exit(0);
@@ -52,7 +62,10 @@ if (!isset($check)) {
$new = str_replace('sha256:', '', $updateStatus[$image]['remote']);
$new = substr($new, 0, 4).'..'.substr($new, -4, 4);
if ( ! isset($nonotify) ) {
exec("$notify -e ".escapeshellarg("Docker - $name [$new]")." -s ".escapeshellarg("Notice [$server] - Docker update $new")." -d ".escapeshellarg("A new version of $name is available")." -i ".escapeshellarg("normal $output")." -x");
$event = str_replace("&apos;","'",_("Docker")." - $name [$new]");
$subject = str_replace("&apos;","'",sprintf(_("Notice [%s] - Version update %s"),$server,$new));
$description = str_replace("&apos;","'",sprintf(_("A new version of %s is available"),$name));
exec("$notify -e ".escapeshellarg($event)." -s ".escapeshellarg($subject)." -d ".escapeshellarg($description)." -i ".escapeshellarg("normal $output")." -x");
}
}
}

View File

@@ -12,18 +12,22 @@
*/
?>
<?
// Multi-language support
if (!function_exists('_')) {
function _($text) {return $text;}
}
session_start();
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
require_once "$docroot/webGui/include/Wrappers.php";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
$var = parse_ini_file('/var/local/emhttp/var.ini');
$current = parse_ini_file('/etc/unraid-version');
$unraid = parse_plugin_cfg('dynamix', true);
// Multi-language support
$_SESSION['locale'] = $unraid['display']['locale'];
$_SERVER['REQUEST_URI'] = "scripts";
require_once "$docroot/webGui/include/Translations.php";
$current = parse_ini_file('/etc/unraid-version');
$server = strtoupper($var['NAME']);
$output = $unraid['notify']['plugin'];
$builtin = ['unRAIDServer','unRAIDServer-'];
@@ -41,7 +45,11 @@ foreach (glob("/$tmp/*.plg", GLOB_NOSORT) as $file) {
$min = plugin('min', $file) ?: $current['version'];
// silently suppress bad download of PLG file
if (strcmp($new, $old)>0 && !version_compare($min,$current['version'],">")) {
exec("$notify -e ".escapeshellarg("Plugin - $name [$new]")." -s ".escapeshellarg("Notice [$server] - Version update $new")." -d ".escapeshellarg("A new version of $name is available")." -i ".escapeshellarg("normal $output")." -x");
// So that "&apos;" doesn't show up in email
$event = str_replace("&apos;","'",_("Plugin")." - $name [$new]");
$subject = str_replace("&apos;","'",sprintf(_("Notice [%s] - Version update %s"),$server,$new));
$description = str_replace("&apos;","'",sprintf(_("A new version of %s is available"),$name));
exec("$notify -e ".escapeshellarg($event)." -s ".escapeshellarg($subject)." -d ".escapeshellarg($description)." -i ".escapeshellarg("normal $output")." -x");
}
}
exit(0);