Class: Bootloader::Sysconfig
- Inherits:
-
Object
- Object
- Bootloader::Sysconfig
- Includes:
- Yast::Logger
- Defined in:
- src/lib/bootloader/sysconfig.rb
Overview
Represents sysconfig file for bootloader usually located in /etc/sysconfig/bootloader
Constant Summary collapse
- AGENT_PATH =
Yast::Path.new(".sysconfig.bootloader")
- ATTR_VALUE_MAPPING =
{ bootloader: "LOADER_TYPE", secure_boot: "SECURE_BOOT", update_nvram: "UPDATE_NVRAM" }.freeze
- PROPOSED_COMMENTS =
{ bootloader: "\n" \ "## Path:\tSystem/Bootloader\n" \ "## Description:\tBootloader configuration\n" \ "## Type:\tlist(grub,grub2,grub2-efi,grub2-bls,systemd-boot,none)\n" \ "## Default:\tgrub2\n" \ "#\n" \ "# Type of bootloader in use.\n" \ "# For making the change effect run bootloader configuration tool\n" \ "# and configure newly selected bootloader\n" \ "#\n" \ "#\n", secure_boot: "\n" \ "## Path:\tSystem/Bootloader\n" \ "## Description:\tBootloader configuration\n" \ "## Type:\tyesno\n" \ "## Default:\t\"no\"\n" \ "#\n" \ "# Enable Secure Boot support\n" \ "# Only available on UEFI systems and IBM z15+.\n" \ "#\n" \ "#\n", update_nvram: "\n" \ "## Path:\tSystem/Bootloader\n" \ "## Description:\tBootloader configuration\n" \ "## Type:\tyesno\n" \ "## Default:\t\"yes\"\n" \ "#\n" \ "# Update nvram boot settings (UEFI, OF)\n" \ "# Unset to preserve specific settings or workaround firmware issues.\n" \ "#\n" }.freeze
Instance Attribute Summary collapse
-
#bootloader ⇒ Object
specifies bootloader in sysconfig.
-
#secure_boot ⇒ Boolean
If secure boot should be used.
-
#update_nvram ⇒ Boolean
If nvram should be updated.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(bootloader: nil, secure_boot: false, update_nvram: true) ⇒ Sysconfig
constructor
A new instance of Sysconfig.
-
#pre_write ⇒ Object
Specialized write before rpm install, that do not have switched SCR and work on blank system.
- #write ⇒ Object
Constructor Details
#initialize(bootloader: nil, secure_boot: false, update_nvram: true) ⇒ Sysconfig
Returns a new instance of Sysconfig.
26 27 28 29 30 31 |
# File 'src/lib/bootloader/sysconfig.rb', line 26 def initialize(bootloader: nil, secure_boot: false, update_nvram: true) @sys_agent = AGENT_PATH @bootloader = bootloader @secure_boot = secure_boot @update_nvram = update_nvram end |
Instance Attribute Details
#bootloader ⇒ Object
specifies bootloader in sysconfig
20 21 22 |
# File 'src/lib/bootloader/sysconfig.rb', line 20 def bootloader @bootloader end |
#secure_boot ⇒ Boolean
Returns if secure boot should be used.
22 23 24 |
# File 'src/lib/bootloader/sysconfig.rb', line 22 def secure_boot @secure_boot end |
#update_nvram ⇒ Boolean
Returns if nvram should be updated.
24 25 26 |
# File 'src/lib/bootloader/sysconfig.rb', line 24 def update_nvram @update_nvram end |
Class Method Details
.from_system ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'src/lib/bootloader/sysconfig.rb', line 33 def self.from_system bootloader = Yast::SCR.Read(AGENT_PATH + "LOADER_TYPE") # propose secure boot always to true (bnc#872054), otherwise respect user choice # but only on architectures that support it secure_boot = Yast::SCR.Read(AGENT_PATH + "SECURE_BOOT") != "no" update_nvram = Yast::SCR.Read(AGENT_PATH + "UPDATE_NVRAM") != "no" new(bootloader: bootloader, secure_boot: secure_boot, update_nvram: update_nvram) end |
Instance Method Details
#pre_write ⇒ Object
Specialized write before rpm install, that do not have switched SCR and work on blank system
46 47 48 49 50 51 |
# File 'src/lib/bootloader/sysconfig.rb', line 46 def pre_write ensure_file_exists_in_target temporary_target_agent do write end end |
#write ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'src/lib/bootloader/sysconfig.rb', line 88 def write log.info "Saving /etc/sysconfig/bootloader for #{bootloader}" write_option(:bootloader, bootloader) sb = secure_boot ? "yes" : "no" write_option(:secure_boot, sb) un = update_nvram ? "yes" : "no" write_option(:update_nvram, un) # flush write Yast::SCR.Write(sys_agent, nil) nil end |