From cd5eaf94e30a3965068a904d0fa6cae1ab9c217c Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Wed, 25 Mar 2026 15:09:40 +0100 Subject: [PATCH] =?UTF-8?q?-=20Nuevo=20webhook=20`START=5FSCRIPT`=20en=20S?= =?UTF-8?q?tatusController=20que=20permite=20crear=20autom=C3=A1ticamente?= =?UTF-8?q?=20una=20entidad=20Trace=20y=20poner=20el=20equipo=20local=20en?= =?UTF-8?q?=20estado=20`BUSY`=20cuando=20un=20cliente=20inicia=20sus=20pro?= =?UTF-8?q?pios=20scripts=20de=20forma=20aut=C3=B3noma=20(ej:=20men=C3=BAs?= =?UTF-8?q?=20locales=20de=20ogLive).=20-=20Se=20ha=20corregido=20un=20bug?= =?UTF-8?q?=20en=20RunScriptAction=20que=20provocaba=20que=20al=20enviar?= =?UTF-8?q?=20la=20orden=20de=20ejecutar=20un=20script=20desde=20la=20web?= =?UTF-8?q?=20de=20administraci=C3=B3n,=20la=20interfaz=20no=20cambiara=20?= =?UTF-8?q?visualmente=20el=20estado=20del=20cliente=20a=20ocupado=20(rojo?= =?UTF-8?q?),=20unificando=20as=C3=AD=20el=20comportamiento=20con=20el=20r?= =?UTF-8?q?esto=20de=20comandos=20(como=20crear=20o=20restaurar=20imagen).?= =?UTF-8?q?=20-=20En=20StatusController=20ahora=20se=20restablece=20autom?= =?UTF-8?q?=C3=A1ticamente=20el=20estado=20del=20cliente=20a=20`OG=5FLIVE`?= =?UTF-8?q?=20cuando=20se=20recibe=20el=20webhook=20de=20finalizaci=C3=B3n?= =?UTF-8?q?=20`RESPUESTA=5FEjecutarScript`,=20reflejando=20visualmente=20q?= =?UTF-8?q?ue=20el=20equipo=20ha=20terminado=20de=20trabajar.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 12 ++++++++++ src/Controller/OgAgent/RunScriptAction.php | 4 ++++ .../OgAgent/Webhook/StatusController.php | 22 +++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b2da4f..e55a867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,16 @@ # Changelog +## [1.2.9] - 2026-03-25 +### Added +- Nuevo webhook `START_SCRIPT` en StatusController que permite crear automáticamente una entidad Trace y poner el equipo local en estado `BUSY` cuando un cliente inicia sus propios scripts de forma autónoma (ej: menús locales de ogLive). +### Fixed +- Se ha corregido un bug en RunScriptAction que provocaba que al enviar la orden de ejecutar un script desde la web de administración, la interfaz no cambiara visualmente el estado del cliente a ocupado (rojo), unificando así el comportamiento con el resto de comandos (como crear o restaurar imagen). +### Improved +- En StatusController ahora se restablece automáticamente el estado del cliente a `OG_LIVE` cuando se recibe el webhook de finalización `RESPUESTA_EjecutarScript`, reflejando visualmente que el equipo ha terminado de trabajar. + +## [1.2.8] - 2026-03-20 +### Added +- Modificado MenuBrowserController para permitir la edición de las plantillas de menú en "raw", permitiendo modificar el código twig en lugar del html ya compilado por twig, de esta forma podemos editar el fichero twig y aplicar cambios para ver el resultado antes de guardar la plantilla. + ## [1.2.7] - 2026-03-17 ### Fixed - Se ha corregido la lectura de la variable `OGCLIENT_API_KEY` desde `env.json` para inyectarla correctamente en la plantilla PXE generada por `ogBoot`. diff --git a/src/Controller/OgAgent/RunScriptAction.php b/src/Controller/OgAgent/RunScriptAction.php index 6d0ae99..c72352a 100644 --- a/src/Controller/OgAgent/RunScriptAction.php +++ b/src/Controller/OgAgent/RunScriptAction.php @@ -147,6 +147,10 @@ class RunScriptAction extends AbstractOgAgentController $jobId = $response['job_id']; $inputData = ['script' => $input->script]; + if (!$this->isLinuxOrWindows($client) && !$this->isLinuxOrWindowsSession($client)) { + $client->setStatus(ClientStatus::BUSY); + } + $this->entityManager->persist($client); $this->entityManager->flush(); diff --git a/src/Controller/OgAgent/Webhook/StatusController.php b/src/Controller/OgAgent/Webhook/StatusController.php index d3132f6..2647972 100644 --- a/src/Controller/OgAgent/Webhook/StatusController.php +++ b/src/Controller/OgAgent/Webhook/StatusController.php @@ -81,6 +81,21 @@ class StatusController extends AbstractController $this->entityManager->persist($client); $this->entityManager->flush(); } + + if (isset($data['nfn']) && $data['nfn'] === 'START_SCRIPT') { + $trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]); + if (!$trace) { + $clientIp = $data['iph'] ?? $request->getClientIp(); + $client = $this->entityManager->getRepository(Client::class)->findOneBy(['ip' => $clientIp]); + if ($client) { + $this->createService->__invoke($client, CommandTypes::RUN_SCRIPT, TraceStatus::IN_PROGRESS, $data['job_id'], ['script' => $data['command'] ?? 'Local script']); + $this->logger->info('Trace automatically created for local script', ['job_id' => $data['job_id']]); + $client->setStatus(ClientStatus::BUSY); + $this->entityManager->persist($client); + $this->entityManager->flush(); + } + } + } if (isset($data['progress'])){ $trace = $this->entityManager->getRepository(Trace::class)->findOneBy(['jobId' => $data['job_id']]); @@ -242,6 +257,13 @@ class StatusController extends AbstractController $trace->setStatus(TraceStatus::SUCCESS); $trace->setFinishedAt(new \DateTime()); $this->entityManager->persist($trace); + + $client = $trace->getClient(); + if ($client && $client->getStatus() === ClientStatus::BUSY) { + $client->setStatus(ClientStatus::OG_LIVE); + $this->entityManager->persist($client); + } + $this->entityManager->flush(); } }