Class: Bootloader::Sections

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
src/lib/bootloader/sections.rb

Overview

Represents available sections and handling of default boot entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grub_cfg = nil) ⇒ Sections

or nil if not available yet



23
24
25
26
27
# File 'src/lib/bootloader/sections.rb', line 23

def initialize(grub_cfg = nil)
  @data = grub_cfg ? grub_cfg.boot_entries : []
  @all = @data.map { |e| e[:title] }
  @default = grub_cfg ? read_default : ""
end

Instance Attribute Details

#allArray<String> (readonly)



15
16
17
# File 'src/lib/bootloader/sections.rb', line 15

def all
  @all
end

#defaultString



19
20
21
# File 'src/lib/bootloader/sections.rb', line 19

def default
  @default
end

Instance Method Details

#writeObject

writes default to system making it persistent



45
46
47
48
49
# File 'src/lib/bootloader/sections.rb', line 45

def write
  return if default.empty?

  Yast::Execute.on_target("/usr/sbin/grub2-set-default", title_to_path(default))
end