feat: version 2.15.0 -- instalador del agente GLPI, filtro de componentes y token recuperable

Instalador .bat generado en el navegador, casilla para ocultar actualizaciones/drivers/componentes
en Software, buscador por pestaña en el detalle, GUIDs como componentes y tokens de ingesta
cifrados (migraciones 024 y 025).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Milton Gonzalez
2026-10-20 08:17:53 -05:00
parent e25c2c3b35
commit d5f09dc91b
15 changed files with 151 additions and 12 deletions
@@ -0,0 +1,56 @@
// Genera en el navegador el instalador (.bat) del agente GLPI con el servidor y el token ya
// puestos. No pasa por el backend: el token en claro solo existe en la pantalla (en BD queda su hash).
export const GLPI_AGENT_VERSION = '1.21';
export function buildInstallerBat({ serverUrl, token, tag }) {
const ver = GLPI_AGENT_VERSION;
const msiName = `GLPI-Agent-${ver}-x64.msi`;
const safeTag = String(tag || '').replace(/[^\w .-]/g, '').trim();
const lines = [
'@echo off',
'setlocal',
`title Instalador GLPI Agent ${ver} - Project`,
`rem Generado por Project (${serverUrl}). Si el .msi esta junto a este archivo se usa; si no, se descarga.`,
'net session >nul 2>&1',
'if %errorlevel% neq 0 (',
' echo Solicitando permisos de administrador...',
` powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"`,
' exit /b',
')',
`set "MSI=%~dp0${msiName}"`,
'if exist "%MSI%" goto instalar',
`set "MSI=%TEMP%\\${msiName}"`,
'if exist "%MSI%" goto instalar',
`echo Descargando GLPI Agent ${ver}...`,
`powershell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -UseBasicParsing 'https://github.com/glpi-project/glpi-agent/releases/download/${ver}/${msiName}' -OutFile '%MSI%'"`,
'if errorlevel 1 (',
` echo ERROR: no se pudo descargar. Copie ${msiName} junto a este archivo y ejecute de nuevo.`,
' pause',
' exit /b 1',
')',
':instalar',
'echo Instalando y configurando el agente...',
`start /wait msiexec /i "%MSI%" /qn /norestart SERVER="${serverUrl}" USER="project" PASSWORD="${token}"${safeTag ? ` TAG="${safeTag}"` : ''} RUNNOW=1`,
'set RC=%errorlevel%',
'if %RC% neq 0 if %RC% neq 3010 (',
' echo ERROR: la instalacion fallo ^(codigo %RC%^).',
' pause',
' exit /b %RC%',
')',
'echo.',
'sc query glpi-agent | find "RUNNING" >nul && (echo Listo: el agente esta instalado y en ejecucion. El equipo aparecera en Project en unos minutos.) || (echo Instalado, pero el servicio no esta en ejecucion. Revise services.msc.)',
'pause',
];
return lines.join('\r\n') + '\r\n';
}
export function downloadTextFile(filename, content) {
const url = URL.createObjectURL(new Blob([content], { type: 'application/octet-stream' }));
const a = document.createElement('a');
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(url);
}