Merge pull request #2310 from unraid/refactor-nchan-publish

refactor: use shared nchan publish function
This commit is contained in:
tom mortensen
2025-07-27 13:40:01 -07:00
committed by GitHub
11 changed files with 28 additions and 110 deletions

View File

@@ -21,20 +21,12 @@ require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
$_SERVER['REQUEST_URI'] = '';
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/publish.php";
function write(...$messages) {
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/vmaction?buffer_length=1',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
]);
foreach ($messages as $message) {
curl_setopt($com, CURLOPT_POSTFIELDS, $message);
curl_exec($com);
publish('vmaction', $message);
}
curl_close($com);
}
function execCommand_nchan($command,$idx) {

View File

@@ -21,20 +21,12 @@ require_once "$docroot/plugins/dynamix.vm.manager/include/libvirt_helpers.php";
$_SERVER['REQUEST_URI'] = '';
$login_locale = _var($display,'locale');
require_once "$docroot/webGui/include/Translations.php";
require_once "$docroot/webGui/include/publish.php";
function write(...$messages) {
$com = curl_init();
curl_setopt_array($com,[
CURLOPT_URL => 'http://localhost/pub/vmaction?buffer_length=1',
CURLOPT_UNIX_SOCKET_PATH => '/var/run/nginx.socket',
CURLOPT_POST => 1,
CURLOPT_RETURNTRANSFER => true
]);
foreach ($messages as $message) {
curl_setopt($com, CURLOPT_POSTFIELDS, $message);
curl_exec($com);
publish('vmaction', $message);
}
curl_close($com);
}
function execCommand_nchan_clone($command,$idx,$refcmd=false) {