main
parent
14c1c4d54b
commit
29376ab546
|
@ -1484,7 +1484,6 @@ public function createBootFile(Request $request): JsonResponse
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||||
|
|
||||||
$data = json_decode($request->getContent(), true);
|
$data = json_decode($request->getContent(), true);
|
||||||
|
|
||||||
$templateName = $data['template_name'] ?? null;
|
$templateName = $data['template_name'] ?? null;
|
||||||
$mac = $this->validateAndFormatMac($data['mac'] ?? null);
|
$mac = $this->validateAndFormatMac($data['mac'] ?? null);
|
||||||
//Si nos pasan el puerto se lo quitamos ya que server_ip siempre tirara por Samba
|
//Si nos pasan el puerto se lo quitamos ya que server_ip siempre tirara por Samba
|
||||||
|
@ -1642,6 +1641,49 @@ public function createBootFile(Request $request): JsonResponse
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||||
return new JsonResponse(['error' => 'FAILED_TO_CREATE_PXE_FILE', 'message' => 'Error al crear el archivo PXE'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
return new JsonResponse(['error' => 'FAILED_TO_CREATE_PXE_FILE', 'message' => 'Error al crear el archivo PXE'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sustituir en la plantilla los marcadores
|
||||||
|
$templateCacheDir = $this->tftpbootDir . '/menu.lst';
|
||||||
|
$templateCachePath = $templateCacheDir . '/templateCache';
|
||||||
|
$templateCacheContent = file_get_contents($templateCachePath);
|
||||||
|
$grubContent = str_replace(
|
||||||
|
['__INFOHOST__', '__OGLIVE__'],
|
||||||
|
[$kernelArgs, basename($ogLiveDir)],
|
||||||
|
$templateCacheContent
|
||||||
|
);
|
||||||
|
|
||||||
|
// Nombre del archivo de arranque por cache
|
||||||
|
$pxeFileNameCache = '01-' . $mac;
|
||||||
|
$pxeFilePathCache = $templateCacheDir . '/' . $pxeFileNameCache;
|
||||||
|
// Crear el archivo de arranque por cache
|
||||||
|
if (file_put_contents($pxeFilePathCache, $grubContent) === false) {
|
||||||
|
$httpCode = '500';
|
||||||
|
$this->logger->error(json_encode([
|
||||||
|
'severity' => 'ERROR',
|
||||||
|
'operation' => $operation,
|
||||||
|
'component' => $component,
|
||||||
|
'http_code' => $httpCode,
|
||||||
|
'desc' => 'Failed to create cache PXE file.'
|
||||||
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||||
|
return new JsonResponse(['error' => 'FAILED_TO_CREATE_CACHE_PXE_FILE', 'message' => 'Error al crear el archivo de caché PXE'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Creación de fichero de arranque por cache
|
||||||
|
$cacheFilePath = $this->tftpbootDir . '/menu.lst/' . $pxeFileName;
|
||||||
|
if (file_put_contents($cacheFilePath, $grubContent) === false) {
|
||||||
|
$httpCode = '500';
|
||||||
|
$this->logger->error(json_encode([
|
||||||
|
'severity' => 'ERROR',
|
||||||
|
'operation' => $operation,
|
||||||
|
'component' => $component,
|
||||||
|
'http_code' => $httpCode,
|
||||||
|
'desc' => 'Failed to create cache PXE file.'
|
||||||
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||||
|
return new JsonResponse(['error' => 'FAILED_TO_CREATE_CACHE_PXE_FILE', 'message' => 'Error al crear el archivo de caché PXE'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$httpCode = '200';
|
$httpCode = '200';
|
||||||
$this->logger->info(json_encode([
|
$this->logger->info(json_encode([
|
||||||
'severity' => 'INFO',
|
'severity' => 'INFO',
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
#!ipxe
|
#!ipxe
|
||||||
|
|
||||||
# Configuración inicial
|
# Detectar si se está ejecutando en modo UEFI o BIOS
|
||||||
set ISODIR __OGLIVE__
|
iseq ${platform} efi && goto uefi_boot || goto bios_boot
|
||||||
set default 0
|
|
||||||
set kernelargs __INFOHOST__
|
|
||||||
:bios_boot_cache
|
|
||||||
echo "Booting ogLive from cache..."
|
|
||||||
|
|
||||||
chain tftp://__SERVERIP__/tftpboot/grub.exe --config-file="
|
:bios_boot
|
||||||
timeout 0
|
echo "Running in BIOS mode"
|
||||||
set ISODIR=${ISODIR};
|
# Si el cliente es BIOS, arranca el grub.pxe
|
||||||
find --set-root --ignore-floppies --ignore-cd /boot/${ISODIR}/ogvmlinuz;
|
chain http://__SERVERIP__/tftpboot/grub.pxe
|
||||||
kernel /boot/${ISODIR}/ogvmlinuz ${kernelargs};
|
exit
|
||||||
initrd /boot/${ISODIR}/oginitrd.img;
|
|
||||||
boot;
|
:uefi_boot
|
||||||
" || echo "Failed to boot ogLive from cache."
|
echo "Running in UEFI mode"
|
||||||
|
# Si el cliente es UEFI, arranca el grubx64.efi
|
||||||
|
chain http://__SERVERIP__/tftpboot/grubx64.efi
|
||||||
|
exit
|
||||||
|
|
Loading…
Reference in New Issue