From ec8af49991fb8a9dae348f0c531e602d9b58b2ce Mon Sep 17 00:00:00 2001 From: Markus Reisner Date: Wed, 22 Nov 2023 11:44:34 +0100 Subject: [PATCH] Refs #36833 - New PXE loader "Grub2 UEFI SecureBoot (target OS)" --- modules/tftp/server.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/tftp/server.rb b/modules/tftp/server.rb index ede0f60ce..af0e0f63c 100644 --- a/modules/tftp/server.rb +++ b/modules/tftp/server.rb @@ -110,11 +110,16 @@ def pxeconfig_file(mac) class Pxegrub2targetos < Server def setup_bootloader(mac, os) + bootloader_directory = Proxy::TFTP::Plugin.settings.bootloader_universe + raise "Bootloader directory not configured in TFTP seetings." if bootloader_directory.blank? + grub_binary_path = "#{bootloader_directory}/#{os}/grubx64.efi" + raise "File #{grub_binary_path} not found." unless File.exist?(grub_binary_path) + shim_binary_path = "#{bootloader_directory}/#{os}/shimx64.efi" + raise "File #{shim_binary_path} not found." unless File.exist?(shim_binary_path) pxeconfig_dir_mac = pxeconfig_dir(mac) FileUtils.mkdir_p(pxeconfig_dir_mac) - bootloader_directory = (Proxy::TFTP::Plugin.settings.bootloader_universe || "/usr/local/share/bootloader-universe") - FileUtils.cp("#{bootloader_directory}/#{os}/grubx64.efi", "#{pxeconfig_dir_mac}/grubx64.efi") - FileUtils.cp("#{bootloader_directory}/#{os}/shimx64.efi", "#{pxeconfig_dir_mac}/shimx64.efi") + FileUtils.cp("#{grub_binary_path}", "#{pxeconfig_dir_mac}/grubx64.efi") + FileUtils.cp("#{shim_binary_path}", "#{pxeconfig_dir_mac}/shimx64.efi") File.write(File.join(pxeconfig_dir_mac, 'targetos'), os) end