Files
webgui/plugins/dynamix.plugin.manager/scripts/plugincheck

46 lines
1.7 KiB
PHP
Executable File

#!/usr/bin/php -q
<?PHP
/* Copyright 2015, Bergware International.
* Copyright 2015, Lime Technology
*
* 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.
*/
?>
<?
require_once '/usr/local/emhttp/webGui/include/Wrappers.php';
exec("wget -qO /dev/null 127.0.0.1:$(lsof -lbnPi4 -sTCP:LISTEN|grep -Pom1 '^emhttp.*:\K[\d]+')/update.htm?cmdStatus=apply");
$current = parse_ini_file('/etc/unraid-version');
$notify = "/usr/local/emhttp/webGui/scripts/notify";
$plugin = "/usr/local/emhttp/plugins/dynamix.plugin.manager/scripts/plugin";
$var = parse_ini_file("/var/local/emhttp/var.ini");
$unraid = parse_plugin_cfg("dynamix",true);
$server = strtoupper($var['NAME']);
$output = $unraid['notify']['plugin'];
exec("$plugin checkall >/dev/null");
foreach (glob("/tmp/plugins/*.plg", GLOB_NOSORT) as $file) {
$plg = basename($file);
$old = exec("$plugin version '/var/log/plugins/$plg'");
unset($new);
exec("$plugin version '$file'", $new, $error);
// silently suppress bad download of PLG file
if ($error) continue;
$new = $new[0];
if (strcmp($new, $old) > 0) {
exec("$plugin unRAID '$file'", $unRAID);
$unRAID = $unRAID[0];
if (empty($unRAID) || strcmp($current['version'], $unRAID) >= 0) {
$name = basename($file, '.plg');
exec("$notify -e 'Plugin - $name [$new]' -s 'Notice [$server] - Version update $new' -d 'A new version of $name is available' -i 'normal $output' -x");
}
}
}
exit(0);
?>