diff --git a/CHANGELOG.md b/CHANGELOG.md index 673f905..f7d6155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [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 diff --git a/api/src/OgBootBundle/Controller/OgBootController.php b/api/src/OgBootBundle/Controller/OgBootController.php index bdf7031..f592159 100644 --- a/api/src/OgBootBundle/Controller/OgBootController.php +++ b/api/src/OgBootBundle/Controller/OgBootController.php @@ -1590,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 ' . @@ -1651,9 +1651,13 @@ public function createBootFile(Request $request): JsonResponse $pxeFileName = '01-' . $mac; $pxeFilePath = $templateCacheDir . '/' . $pxeFileName; - // Generar archivo si la plantilla es oglives cache - if ($templateName === 'ogliveCache') { - $templateCachePath = $templateCacheDir . '/templateCache'; + // 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__'], diff --git a/tftpboot/ipxe_scripts/templates/menu b/tftpboot/ipxe_scripts/templates/menu new file mode 100644 index 0000000..048cba6 --- /dev/null +++ b/tftpboot/ipxe_scripts/templates/menu @@ -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 diff --git a/tftpboot/ipxe_scripts/templates/ogliveAdmin b/tftpboot/ipxe_scripts/templates/ogliveAdmin new file mode 100644 index 0000000..4be9a1d --- /dev/null +++ b/tftpboot/ipxe_scripts/templates/ogliveAdmin @@ -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 diff --git a/tftpboot/menu.lst/templateDisk b/tftpboot/menu.lst/templateDisk index 4ce7f86..72a02e9 100755 --- a/tftpboot/menu.lst/templateDisk +++ b/tftpboot/menu.lst/templateDisk @@ -1 +1,3 @@ -configfile __DISKPART__/efi/Part-__DISK__-__PART__/Boot/grub.cfg \ No newline at end of file +search --file --set root /EFI/Part-__DISK__-__PART__/Boot/ogloader.efi +chainloader /EFI/Part-__DISK__-__PART__/Boot/ogloader.efi +boot \ No newline at end of file diff --git a/tftpboot/menu.lst/templateMenu b/tftpboot/menu.lst/templateMenu new file mode 100644 index 0000000..b1a6f30 --- /dev/null +++ b/tftpboot/menu.lst/templateMenu @@ -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