Files
webgui/plugins/dynamix.plugin.manager/scripts/plugincheck
2020-09-20 07:18:07 -04:00

57 lines
2.1 KiB
PHP
Executable File

#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
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');
$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-'];
$notify = "$docroot/webGui/scripts/notify";
$tmp = '/tmp/plugins';
$plugins = '/var/log/plugins';
plugin('checkall');
foreach (glob("/$tmp/*.plg", GLOB_NOSORT) as $file) {
$name = basename($file,'.plg');
// skip OS related updates
if (in_array($name,$builtin)) continue;
$new = plugin('version', $file);
$old = plugin('version', "$plugins/$name.plg");
$min = plugin('min', $file) ?: $current['version'];
// silently suppress bad download of PLG file
if (strcmp($new, $old)>0 && !version_compare($min,$current['version'],">")) {
// 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")." -l '/Plugins' -x");
}
}
exit(0);
?>