mirror of
https://github.com/unraid/webgui.git
synced 2026-01-24 18:49:17 -06:00
@@ -28,9 +28,13 @@ function searchLink(&$db,$url) {
|
||||
}
|
||||
|
||||
$method = $argv[1];
|
||||
$plugin = "/boot/config/plugins/{$argv[2]}";
|
||||
$name = $argv[2];
|
||||
$error = $argv[3];
|
||||
$plugin = "/boot/config/plugins/$name";
|
||||
|
||||
if ($method == 'install' or $method == 'update') {
|
||||
// check if method successfully completed
|
||||
if ($error) die;
|
||||
// update support link in plugin file
|
||||
$info = readJson('/tmp/community.applications/tempFiles/templates.json');
|
||||
// find matching support link
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
$method = $argv[1];
|
||||
$plugins = explode('*',$argv[2]);
|
||||
$console = $argv[$argc-1] != 'nchan'; // console or nchan output
|
||||
$call = ['plg' => 'plugin', 'xml' => 'language'];
|
||||
|
||||
function write($message){
|
||||
global $console;
|
||||
@@ -36,9 +37,9 @@ function write($message){
|
||||
|
||||
usleep(50000);
|
||||
foreach ($plugins as $plugin) {
|
||||
if (!$plugin) continue;
|
||||
if (!$plugin || (!$cmd = $call[pathinfo($plugin)['extension']])) continue;
|
||||
$line = '';
|
||||
$run = popen("plugin $method $plugin",'r');
|
||||
$run = popen("$cmd $method $plugin",'r');
|
||||
while (!feof($run)) {
|
||||
$line .= fgetc($run);
|
||||
if (in_array($line[-1],["\r","\n"])) {write($line); $line = '';}
|
||||
|
||||
@@ -204,16 +204,16 @@ function pre_hooks() {
|
||||
}
|
||||
}
|
||||
|
||||
// Run hooked scripts after successful completion of "method"
|
||||
// Run hooked scripts after successful or failed completion of "method"
|
||||
// method = install, update, remove, check
|
||||
// hook programs receives two parameters: method and plugin-name
|
||||
// hook programs receives three parameters: method and plugin-name and error (empty if none)
|
||||
//
|
||||
function post_hooks() {
|
||||
function post_hooks($error='') {
|
||||
global $method, $plugin;
|
||||
$hooks = "/usr/local/emhttp/plugins/dynamix.plugin.manager/post-hooks";
|
||||
foreach (glob("$hooks/*") as $hook) if (is_executable($hook)) {
|
||||
write("Executing hook script: ".basename($hook)."\n");
|
||||
run("$hook $method $plugin");
|
||||
run("$hook $method $plugin $error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -619,6 +619,8 @@ if ($method == 'install') {
|
||||
$subject = "plugin: ".basename($plugin_file);
|
||||
$description = "Plugin failed to install";
|
||||
exec("$notify -e $event -s $subject -d $description) -i 2");
|
||||
// run hook scripts for post processing
|
||||
post_hooks($error);
|
||||
exit(1);
|
||||
}
|
||||
// remove symlink for re-install
|
||||
@@ -632,6 +634,8 @@ if ($method == 'install') {
|
||||
if (dirname($plugin_file) == "$boot") {
|
||||
move($plugin_file, "$boot-error");
|
||||
}
|
||||
// run hook scripts for post processing
|
||||
post_hooks($error);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -680,6 +684,8 @@ if ($method == 'check') {
|
||||
$version = plugin('version', $plugin_file, $error);
|
||||
if ($version === false) {
|
||||
write("plugin: $error\n");
|
||||
// run hook scripts for post processing
|
||||
post_hooks($error);
|
||||
exit(1);
|
||||
}
|
||||
write("$version\n");
|
||||
@@ -732,6 +738,8 @@ if ($method == 'update') {
|
||||
// install the updated plugin
|
||||
if (plugin('install', $plugin_file, $error) === false) {
|
||||
write("plugin: $error\n");
|
||||
// run hook scripts for post processing
|
||||
post_hooks($error);
|
||||
exit(1);
|
||||
}
|
||||
// install was successful, save the updated plugin so it installs again next boot
|
||||
@@ -764,6 +772,8 @@ if ($method == 'remove') {
|
||||
// but if can't remove, restore the symlink
|
||||
if (is_file($installed_plugin_file)) symlink($installed_plugin_file, $symlink);
|
||||
write("plugin: $error\n");
|
||||
// run hook scripts for post processing
|
||||
post_hooks($error);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user