Files
webgui/plugins/dynamix.plugin.manager/pre-hooks/pre_plugin_checks
2022-06-23 08:17:34 +02:00

35 lines
1.1 KiB
PHP
Executable File

#!/usr/bin/php -q
<?PHP
/* Copyright 2005-2022, Lime Technology
* Copyright 2012-2022, 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.
*/
?>
<?
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: "/usr/local/emhttp";
require_once "$docroot/plugins/dynamix.plugin.manager/include/PluginHelpers.php";
$method = $argv[1];
$plugin = $argv[2];
// validate plugin update (not applicable to OS updates)
if ($method == 'check' and $plugin != 'unRAIDServer.plg') {
$old_plugin = "/boot/config/plugins/$plugin";
$new_plugin = "/tmp/plugins/$plugin";
if (plugin('version', $new_plugin) > plugin('version', $old_plugin)) {
echo "Validating $plugin update\n";
if (($status = plugin('validate', $new_plugin)) != 'valid') {
echo "$status\n";
// restore original plugin and undo update
copy($old_plugin, $new_plugin);
}
}
}
?>