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
- AGENT_PATH =
Yast::Path.new(".sysconfig.bootloader")
- ATTR_VALUE_MAPPING =
{ bootloader: "LOADER_TYPE", secure_boot: "SECURE_BOOT", trusted_boot: "TRUSTED_BOOT" }.freeze
- PROPOSED_COMMENTS =
{ bootloader: "\n" \ "## Path:\tSystem/Bootloader\n" \ "## Description:\tBootloader configuration\n" \ "## Type:\tlist(grub,grub2,grub2-efi,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 UEFI Secure Boot support\n" \ "# This setting is only relevant to UEFI which supports Secure Boot. It won't\n" \ "# take effect on any other firmware type.\n" \ "#\n" \ "#\n", trusted_boot: "\n" \ "## Path:\tSystem/Bootloader\n" \ "## Description:\tBootloader configuration\n" \ "## Type:\tyesno\n" \ "## Default:\t\"no\"\n" \ "#\n" \ "# Enable Trusted Boot support\n" \ "# Only available for legacy (non-UEFI) boot.\n" \ "#\n" }.freeze
Instance Attribute Summary (collapse)
-
- (Object) bootloader
specifies bootloader in sysconfig.
-
- (Boolean) secure_boot
If secure boot should be used.
-
- (Boolean) trusted_boot
If trusted boot should be used.
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Sysconfig) initialize(bootloader: nil, secure_boot: false, trusted_boot: false)
constructor
A new instance of Sysconfig.
-
- (Object) pre_write
Specialized write before rpm install, that do not have switched SCR and work on blank system.
- - (Object) write
Constructor Details
- (Sysconfig) initialize(bootloader: nil, secure_boot: false, trusted_boot: false)
Returns a new instance of Sysconfig
23 24 25 26 27 28 |
# File 'src/lib/bootloader/sysconfig.rb', line 23 def initialize(bootloader: nil, secure_boot: false, trusted_boot: false) @sys_agent = AGENT_PATH @bootloader = bootloader @secure_boot = secure_boot @trusted_boot = trusted_boot end |
Instance Attribute Details
- (Object) bootloader
specifies bootloader in sysconfig
17 18 19 |
# File 'src/lib/bootloader/sysconfig.rb', line 17 def bootloader @bootloader end |
- (Boolean) secure_boot
Returns if secure boot should be used
19 20 21 |
# File 'src/lib/bootloader/sysconfig.rb', line 19 def secure_boot @secure_boot end |
- (Boolean) trusted_boot
Returns if trusted boot should be used
21 22 23 |
# File 'src/lib/bootloader/sysconfig.rb', line 21 def trusted_boot @trusted_boot end |
Class Method Details
+ (Object) from_system
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'src/lib/bootloader/sysconfig.rb', line 30 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 (bnc#984895) secure_boot = if Yast::Arch.x86_64 || Yast::Arch.i386 Yast::SCR.Read(AGENT_PATH + "SECURE_BOOT") != "no" else false end trusted_boot = Yast::SCR.Read(AGENT_PATH + "TRUSTED_BOOT") == "yes" new(bootloader: bootloader, secure_boot: secure_boot, trusted_boot: trusted_boot) end |
Instance Method Details
- (Object) pre_write
Specialized write before rpm install, that do not have switched SCR and work on blank system
47 48 49 50 51 52 |
# File 'src/lib/bootloader/sysconfig.rb', line 47 def pre_write ensure_file_exists_in_target temporary_target_agent do write end end |
- (Object) write
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'src/lib/bootloader/sysconfig.rb', line 90 def write log.info "Saving /etc/sysconfig/bootloader for #{bootloader}" write_option(:bootloader, bootloader) sb = secure_boot ? "yes" : "no" write_option(:secure_boot, sb) tb = trusted_boot ? "yes" : "no" write_option(:trusted_boot, tb) # flush write Yast::SCR.Write(sys_agent, nil) nil end |