Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
|
6954cd3447 | |
|
20463d3f16 | |
|
bfe5bb55cd | |
|
fec97eca8f | |
|
a4fd473a57 | |
|
fdaf263255 | |
|
f9124d3163 | |
|
f95869a35b | |
|
79d077590d | |
|
60c4746906 | |
|
52b2e645fa |
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -2,6 +2,21 @@
|
|||
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.8.1] - 2024-06-18
|
||||
### Changed
|
||||
- Añade nuevos modulos al grubx64.efi
|
||||
|
||||
## [0.8.0] - 2024-06-18
|
||||
### Changed
|
||||
- Actualiza a 0.8.0 para incluir los cambios de la versión 0.7.2
|
||||
|
||||
## [0.7.2] - 2024-06-05
|
||||
### Changed
|
||||
- Añade scripts de grub y menu.lst para el arranque por disco y partición
|
||||
- Añade plantilla ogliveadmin con permisos de administracion como parametro del kernel
|
||||
- Añade plantilla de menú para el arranque por disco y partición y caché
|
||||
|
||||
## [0.7.1] - 2024-05-19
|
||||
### Changed
|
||||
- Añade scripts de grub y menu.lst para el arranque del Oglive por cache
|
||||
|
|
|
@ -1447,6 +1447,7 @@ public function getBootFiles(): JsonResponse
|
|||
* @OA\Property(property="mac", type="string", example="00:50:56:22:11:12"),
|
||||
* @OA\Property(property="template_name", type="string", example="mi_plantilla.ipxe"),
|
||||
* @OA\Property(property="server_ip", type="string", example="192.168.2.1"),
|
||||
* @OA\Property(property="server_pxe_port", type="string", example="8082"),
|
||||
* @OA\Property(property="oglivedir", type="string", example="ogLive")
|
||||
* )
|
||||
* ),
|
||||
|
@ -1491,6 +1492,14 @@ public function createBootFile(Request $request): JsonResponse
|
|||
if ($serverIp && strpos($serverIp, ':') !== false) {
|
||||
$serverIp = explode(':', $serverIp)[0];
|
||||
}
|
||||
//Declaramos serverPxePort que lo usaremos para la llamada por http
|
||||
$serverPxePort = $data['server_pxe_port'] ?? null;
|
||||
|
||||
$serverIpPort = $serverIp;
|
||||
if (!empty($serverPxePort)) {
|
||||
$serverIpPort .= ':' . $serverPxePort;
|
||||
}
|
||||
|
||||
$ogLiveDir = $data['oglivedir'] ?? 'ogLive';
|
||||
|
||||
// Verificación de los campos obligatorios
|
||||
|
@ -1528,6 +1537,7 @@ public function createBootFile(Request $request): JsonResponse
|
|||
$parameters = [
|
||||
'LANG' => $data['lang'] ?? 'es_ES.UTF-8',
|
||||
'ip' => $data['ip'] ?? '',
|
||||
'server_pxe_port' => $data['server_pxe_port'] ?? '',
|
||||
'router' => $data['router'] ?? '',
|
||||
'netmask' => $data['netmask'] ?? '',
|
||||
'computer_name' => $data['computer_name'] ?? '',
|
||||
|
@ -1580,7 +1590,7 @@ public function createBootFile(Request $request): JsonResponse
|
|||
}
|
||||
|
||||
// Construcción de los argumentos del kernel
|
||||
$kernelArgs = 'ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogactiveadmin=true ogdebug=true ogtmpfs=15 ' .
|
||||
$kernelArgs = 'ro boot=oginit quiet splash irqpoll acpi=on og2nd=sqfs ogprotocol=smb ogdebug=true ogtmpfs=15 ' .
|
||||
'oglivedir=${ISODIR}' . ' ' .
|
||||
'LANG=' . $parameters['LANG'] . ' ' .
|
||||
'ip=' . $parameters['ip'] . ':' . $serverIp . ':' . $parameters['router'] . ':' . $parameters['netmask'] . ':' . $parameters['computer_name'] . ':' . $parameters['netiface'] . ':none ' .
|
||||
|
@ -1599,12 +1609,7 @@ public function createBootFile(Request $request): JsonResponse
|
|||
(is_numeric($parameters['resolution']) && $parameters['resolution'] <= 999 ? 'vga=' . $parameters['resolution'] :
|
||||
(strpos($parameters['resolution'], ':') !== false ? 'video=' . $parameters['resolution'] : ' ' . $parameters['resolution']));
|
||||
|
||||
// Esta será llamada a http para arrancar kernel e imagen de inicialización
|
||||
// Si lo requiriese debe llevar puerto ya que se comunica con nginx
|
||||
$serverIpPort = $this->ogBootIP;
|
||||
if (!empty($this->ogBootPort)) {
|
||||
$serverIpPort .= ':' . $this->ogBootPort;
|
||||
}
|
||||
|
||||
// Extraer solo el nombre del directorio si contiene una ruta completa PROVISIONAL
|
||||
if (strpos($ogLiveDir, '/') !== false) {
|
||||
$ogLiveDir = basename($ogLiveDir);
|
||||
|
@ -1642,45 +1647,61 @@ public function createBootFile(Request $request): JsonResponse
|
|||
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
|
||||
);
|
||||
$pxeFileName = '01-' . $mac;
|
||||
$pxeFilePath = $templateCacheDir . '/' . $pxeFileName;
|
||||
|
||||
// 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);
|
||||
// Generar archivo si la plantilla es oglives cache o menu
|
||||
if ($templateName === 'ogliveCache' || $templateName === 'menu') {
|
||||
if ($templateName === 'ogliveCache') {
|
||||
$templateCachePath = $templateCacheDir . '/templateCache';
|
||||
} elseif ($templateName === 'menu') {
|
||||
$templateCachePath = $templateCacheDir . '/templateMenu';
|
||||
}
|
||||
$templateCacheContent = file_get_contents($templateCachePath);
|
||||
$grubContent = str_replace(
|
||||
['__INFOHOST__', '__OGLIVE__'],
|
||||
[$kernelArgs, basename($ogLiveDir)],
|
||||
$templateCacheContent
|
||||
);
|
||||
}
|
||||
// Generar archivo si la plantilla es de tipo disco/partición
|
||||
elseif (in_array($templateName, ['firstDisk_firstPartition', 'firstDisk_secondPartition', 'firstDisk_thirdPartition'])) {
|
||||
$templateDiskPath = $templateCacheDir . '/templateDisk';
|
||||
$templateDiskContent = file_get_contents($templateDiskPath);
|
||||
|
||||
// Determinar DISK, PART y DISKPART en función del templateName
|
||||
$map = [
|
||||
'firstDisk_firstPartition' => ['disk' => '01', 'part' => '01', 'diskpart' => '(hd0,gpt1)'],
|
||||
'firstDisk_secondPartition' => ['disk' => '01', 'part' => '02', 'diskpart' => '(hd0,gpt1)'],
|
||||
'firstDisk_thirdPartition' => ['disk' => '01', 'part' => '03', 'diskpart' => '(hd0,gpt1)'],
|
||||
];
|
||||
|
||||
$diskInfo = $map[$templateName];
|
||||
|
||||
// Sustituir variables en plantilla
|
||||
$grubContent = str_replace(
|
||||
['__DISK__', '__PART__', '__DISKPART__'],
|
||||
[$diskInfo['disk'], $diskInfo['part'], $diskInfo['diskpart']],
|
||||
$templateDiskContent
|
||||
);
|
||||
}
|
||||
// En cualquier otro caso, no se hace nada
|
||||
else {
|
||||
return new JsonResponse(['success' => 'NO_TEMPLATE_ACTION', 'message' => 'No se requiere generar archivo PXE'], Response::HTTP_OK);
|
||||
}
|
||||
|
||||
|
||||
// Creación de fichero de arranque por cache
|
||||
$cacheFilePath = $this->tftpbootDir . '/menu.lst/' . $pxeFileName;
|
||||
if (file_put_contents($cacheFilePath, $grubContent) === false) {
|
||||
// Escribir el archivo PXE final (común a ambos casos)
|
||||
if (file_put_contents($pxeFilePath, $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.'
|
||||
'desc' => 'Failed to create PXE boot 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);
|
||||
return new JsonResponse(['error' => 'FAILED_TO_CREATE_PXE_FILE', 'message' => 'Error al crear el archivo de arranque PXE'], Response::HTTP_INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
cat grub.cfg
|
||||
##NO-TOCAR-ESTA-LINEA ogLive
|
||||
set timeout=0
|
||||
set timeout_style=hidden
|
||||
|
||||
echo ">>> GRUB lanzador detectando MAC..."
|
||||
sleep 1
|
||||
|
||||
echo ">>> MAC detectada: ${net_default_mac}"
|
||||
sleep 1
|
||||
|
||||
echo ">>> Intentando cargar menú específico: /menu.lst/01-${net_default_mac}"
|
||||
sleep 1
|
||||
|
||||
configfile /menu.lst/01-${net_default_mac}
|
||||
|
||||
echo ">>> No se pudo cargar /menu.lst/01-${net_default_mac}"
|
||||
sleep 5
|
||||
reboot
|
Binary file not shown.
|
@ -10,6 +10,6 @@ exit
|
|||
|
||||
:uefi_boot
|
||||
echo "Running in UEFI mode - Booting first disk, first partition"
|
||||
sanboot --no-describe --drive 0 --filename \EFI\Part-01-01\Boot\ogloader.efi || echo "Failed to boot in UEFI mode"
|
||||
chain http://__SERVERIP__/tftpboot/grubx64.efi
|
||||
exit
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ exit
|
|||
|
||||
:uefi_boot
|
||||
echo "Running in UEFI mode - Booting first disk, second partition"
|
||||
sanboot --no-describe --drive 0 --filename \EFI\Part-01-02\Boot\ogloader.efi || echo "Failed to boot in UEFI mode"
|
||||
chain http://__SERVERIP__/tftpboot/grubx64.efi
|
||||
exit
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ exit
|
|||
|
||||
:uefi_boot
|
||||
echo "Running in UEFI mode - Booting first disk, third partition"
|
||||
sanboot --no-describe --drive 0 --filename \EFI\Part-01-03\Boot\ogloader.efi || echo "Failed to boot in UEFI mode"
|
||||
chain http://__SERVERIP__/tftpboot/grubx64.efi
|
||||
exit
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#!ipxe
|
||||
|
||||
# Detectar si se está ejecutando en modo UEFI o BIOS
|
||||
iseq ${platform} efi && goto uefi_boot || goto bios_boot
|
||||
|
||||
:bios_boot
|
||||
echo "Running in BIOS mode - Booting Menu WIP"
|
||||
chain http://__SERVERIP__/tftpboot/grub.exe --config-file="timeout 0; title menu WIP;root (hd0,0);chainloader (hd0,0)+1;boot" || echo "Failed to boot in BIOS mode"
|
||||
exit
|
||||
|
||||
:uefi_boot
|
||||
echo "Running in UEFI mode - Booting Menu"
|
||||
chain http://__SERVERIP__/tftpboot/grubx64.efi
|
||||
exit
|
|
@ -0,0 +1,19 @@
|
|||
#!ipxe
|
||||
set timeout 0
|
||||
set timeout-style hidden
|
||||
|
||||
set ISODIR __OGLIVE__
|
||||
set default 0
|
||||
set kernelargs __INFOHOST__
|
||||
# Menú de entrada para seleccionar OgLive
|
||||
:try_iso
|
||||
kernel http://__SERVERIP__/tftpboot/${ISODIR}/ogvmlinuz ogactiveadmin=true ${kernelargs} || goto fallback
|
||||
initrd http://__SERVERIP__/tftpboot/${ISODIR}/oginitrd.img
|
||||
boot
|
||||
|
||||
:fallback
|
||||
echo "OgLive default"
|
||||
set ISODIR ogLive
|
||||
kernel http://__SERVERIP__/tftpboot/${ISODIR}/ogvmlinuz ogactiveadmin=true ${kernelargs}
|
||||
initrd http://__SERVERIP__/tftpboot/${ISODIR}/oginitrd.img
|
||||
boot
|
|
@ -0,0 +1,3 @@
|
|||
search --file --set root /EFI/Part-__DISK__-__PART__/Boot/ogloader.efi
|
||||
chainloader /EFI/Part-__DISK__-__PART__/Boot/ogloader.efi
|
||||
boot
|
|
@ -0,0 +1,87 @@
|
|||
set timeout=30
|
||||
|
||||
set detectado='no'
|
||||
# Compruebo si existen distintos cargadores.
|
||||
echo "Searching Grub"
|
||||
set ISODIR=__OGLIVE__
|
||||
search --file --set rootGrub /EFI/grub/Boot/grubx64.efi
|
||||
if [ "$rootGrub" != "" ]; then
|
||||
set detectado='si'
|
||||
menuentry "Grub" {
|
||||
root="$rootGrub"
|
||||
chainloader /EFI/grub/Boot/grubx64.efi
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Searching rEFInd"
|
||||
search --file --set rootRefind /EFI/refind/shimx64.efi.signed
|
||||
if [ "$rootRefind" != "" ]; then
|
||||
menuentry "rEFInd" {
|
||||
root="$rootRefind"
|
||||
chainloader /EFI/refind/shimx64.efi.signed
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Searching Part-01-02"
|
||||
search --file --set rootP2 /EFI/Part-01-02/Boot/ogloader.efi
|
||||
if [ "$rootP2" != "" ]; then
|
||||
set detectado='si'
|
||||
menuentry "Part-01-02" {
|
||||
root="$rootP2"
|
||||
chainloader /EFI/Part-01-02/Boot/ogloader.efi
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Searching Part-01-03"
|
||||
search --file --set rootP3 /EFI/Part-01-03/Boot/ogloader.efi
|
||||
if [ "$rootP3" != "" ]; then
|
||||
set detectado='si'
|
||||
menuentry "Part-01-03" {
|
||||
root="$rootP3"
|
||||
chainloader /EFI/Part-01-03/Boot/ogloader.efi
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Searching Windows"
|
||||
search --file --set rootMS /EFI/Microsoft/Boot/bootmgfw.efi
|
||||
if [ "$rootMS" != "" ]; then
|
||||
set detectado='si'
|
||||
menuentry "Windows" {
|
||||
root="$rootMS"
|
||||
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
|
||||
}
|
||||
fi
|
||||
|
||||
echo "Searching Ubuntu"
|
||||
search --file --set rootUb /EFI/ubuntu/grubx64.efi
|
||||
if [ "$rootUb" != "" ]; then
|
||||
set detectado='si'
|
||||
menuentry "Ubuntu"{
|
||||
root="$rootUb"
|
||||
chainloader /EFI/ubuntu/grubx64.efi
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
echo "Buscando ogvmlinuz en particiones locales..."
|
||||
search --file --set=rootOgCache /boot/$ISODIR/ogvmlinuz
|
||||
if [ "$rootOgCache" != "" ]; then
|
||||
set detectado='si'
|
||||
menuentry "Oglive Cache"{
|
||||
root="$rootOgCache"
|
||||
linux /boot/$ISODIR/ogvmlinuz __INFOHOST__
|
||||
initrd /boot/$ISODIR/oginitrd.img
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Si no hay ningún sistema operativo muestro mensaje.
|
||||
if [ $detectado == 'no' ]; then
|
||||
menuentry "OpenGnsys no ha detectado ningún sistema operativo" {
|
||||
# para evitar mensajes de error.
|
||||
set root="(hd0,gpt1)"
|
||||
}
|
||||
fi
|
Loading…
Reference in New Issue