Plugin system update

This commit is contained in:
bergware
2022-07-08 23:54:47 +02:00
parent e6de6372ac
commit c677dbdc89
3 changed files with 20 additions and 8 deletions

View File

@@ -25,6 +25,9 @@ require_once "$docroot/webGui/include/Translations.php";
$unit = ['B','kB','MB','GB','TB','PB','EB','ZB','YB'];
$list = [];
function done() {
write('_DONE_');
}
function write($message){
$nchan = curl_init();
curl_setopt_array($nchan,[
@@ -75,5 +78,5 @@ foreach ($list as $ct) {
$sum['log'] += $ct['log'];
}
write("<hr>".align(_('Total size'),42).align(autoscale($sum['total'])).align(autoscale($sum['writable'])).autoscale($sum['log'])."\n");
write('_DONE_');
done();
?>

View File

@@ -162,6 +162,12 @@ function error_desc($code) {
}
}
// Signal DONE to caller
//
function done() {
write('_DONE_');
}
// Function to write either to console (echo) or nchan (curl)
// Default output is console, use optional parameter "nchan" to write to nchan instead
//
@@ -479,7 +485,7 @@ if ($method == 'checkall') {
write("plugin: checking $plugin ...\n");
exec("$cmd check $plugin >/dev/null");
}
write('_DONE_');
done();
exit(0);
}
@@ -507,7 +513,7 @@ if ($method == 'updateall') {
exec("$cmd update $plugin >/dev/null");
}
}
write('_DONE_');
done();
exit(0);
}
@@ -528,7 +534,7 @@ if ($method == 'checkos') {
write("plugin: checking $plugin ...\n");
exec("$cmd check $plugin >/dev/null");
}
write('_DONE_');
done();
exit(0);
}
@@ -655,7 +661,7 @@ if ($method == 'install') {
}
// run hook scripts for post processing
post_hooks();
write('_DONE_');
done();
exit(0);
}
@@ -755,7 +761,7 @@ if ($method == 'update') {
logger("plugin: $plugin updated");
// run hook scripts for post processing
post_hooks();
write('_DONE_');
done();
exit(0);
}
@@ -789,7 +795,7 @@ if ($method == 'remove') {
exec("/usr/local/sbin/update_cron");
// run hook scripts for post processing
post_hooks();
write('_DONE_');
done();
exit(0);
}

View File

@@ -21,6 +21,9 @@
$console = $argv[$argc-1] != 'nchan'; // console or nchan output
if (!$console) unset($argv[$argc-1]); // remove nchan parameter
function done() {
write('_DONE_');
}
function write($message) {
global $console;
if ($console) {
@@ -73,5 +76,5 @@ $hours = floor($time/3600);
$mins = floor($time/60%60);
$secs = floor($time%60);
write("Completed, elapsed time: ".sprintf('%02d:%02d:%02d', $hours, $mins, $secs)."\n");
write('_DONE_');
done();
?>