main
parent
14c1c4d54b
commit
29376ab546
|
@ -1484,7 +1484,6 @@ public function createBootFile(Request $request): JsonResponse
|
|||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
|
||||
|
||||
$data = json_decode($request->getContent(), true);
|
||||
|
||||
$templateName = $data['template_name'] ?? null;
|
||||
$mac = $this->validateAndFormatMac($data['mac'] ?? null);
|
||||
//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));
|
||||
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';
|
||||
$this->logger->info(json_encode([
|
||||
'severity' => 'INFO',
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
#!ipxe
|
||||
|
||||
# Configuración inicial
|
||||
set ISODIR __OGLIVE__
|
||||
set default 0
|
||||
set kernelargs __INFOHOST__
|
||||
:bios_boot_cache
|
||||
echo "Booting ogLive from cache..."
|
||||
# Detectar si se está ejecutando en modo UEFI o BIOS
|
||||
iseq ${platform} efi && goto uefi_boot || goto bios_boot
|
||||
|
||||
chain tftp://__SERVERIP__/tftpboot/grub.exe --config-file="
|
||||
timeout 0
|
||||
set ISODIR=${ISODIR};
|
||||
find --set-root --ignore-floppies --ignore-cd /boot/${ISODIR}/ogvmlinuz;
|
||||
kernel /boot/${ISODIR}/ogvmlinuz ${kernelargs};
|
||||
initrd /boot/${ISODIR}/oginitrd.img;
|
||||
boot;
|
||||
" || echo "Failed to boot ogLive from cache."
|
||||
:bios_boot
|
||||
echo "Running in BIOS mode"
|
||||
# Si el cliente es BIOS, arranca el grub.pxe
|
||||
chain http://__SERVERIP__/tftpboot/grub.pxe
|
||||
exit
|
||||
|
||||
:uefi_boot
|
||||
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