Class: Bootloader::Grub2Base
- Inherits:
-
BootloaderBase
- Object
- BootloaderBase
- Bootloader::Grub2Base
- Includes:
- Yast::I18n, Yast::Logger
- Defined in:
- src/lib/bootloader/grub2base.rb
Overview
Common base for GRUB2 specialized classes
Constant Summary
Instance Attribute Summary (collapse)
-
- (Object) grub_default
Returns the value of attribute grub_default.
-
- (Object) password
Returns the value of attribute password.
-
- (Object) pmbr_action
Returns the value of attribute pmbr_action.
-
- (Object) sections
readonly
Returns the value of attribute sections.
Instance Method Summary (collapse)
- - (Object) disable_serial_console
- - (Object) enable_serial_console(console)
-
- (Grub2Base) initialize
constructor
A new instance of Grub2Base.
- - (Object) merge(other)
-
- (Object) pmbr_setup(*devices)
set pmbr flags on boot disks TODO: move it to own place.
- - (Object) propose
- - (Object) read
- - (Object) write
Methods inherited from BootloaderBase
#packages, #proposed?, #read?, #summary, #write_sysconfig
Constructor Details
- (Grub2Base) initialize
Returns a new instance of Grub2Base
46 47 48 49 50 51 52 53 54 |
# File 'src/lib/bootloader/grub2base.rb', line 46 def initialize super textdomain "bootloader" @password = ::Bootloader::GRUB2Pwd.new @grub_default = ::CFA::Grub2::Default.new @sections = ::Bootloader::Sections.new @pmbr_action = :nothing end |
Instance Attribute Details
- (Object) grub_default
Returns the value of attribute grub_default
42 43 44 |
# File 'src/lib/bootloader/grub2base.rb', line 42 def grub_default @grub_default end |
- (Object) password
Returns the value of attribute password
37 38 39 |
# File 'src/lib/bootloader/grub2base.rb', line 37 def password @password end |
- (Object) pmbr_action
Returns the value of attribute pmbr_action
44 45 46 |
# File 'src/lib/bootloader/grub2base.rb', line 44 def pmbr_action @pmbr_action end |
- (Object) sections (readonly)
Returns the value of attribute sections
39 40 41 |
# File 'src/lib/bootloader/grub2base.rb', line 39 def sections @sections end |
Instance Method Details
- (Object) disable_serial_console
144 145 146 147 |
# File 'src/lib/bootloader/grub2base.rb', line 144 def disable_serial_console grub_default.kernel_params.remove_parameter(serial_console_matcher) grub_default.serial_console = "" end |
- (Object) enable_serial_console(console)
133 134 135 136 137 138 139 140 141 142 |
# File 'src/lib/bootloader/grub2base.rb', line 133 def enable_serial_console(console) console = SerialConsole.load_from_console_args(console) raise "Invalid console parameters" unless console grub_default.serial_console = console.console_args placer = CFA::ReplacePlacer.new(serial_console_matcher) kernel_params = grub_default.kernel_params kernel_params.add_parameter("console", console.kernel_args, placer) end |
- (Object) merge(other)
124 125 126 127 128 129 130 131 |
# File 'src/lib/bootloader/grub2base.rb', line 124 def merge(other) super merge_grub_default(other) merge_password(other) merge_pmbr_action(other) merge_sections(other) end |
- (Object) pmbr_setup(*devices)
set pmbr flags on boot disks TODO: move it to own place
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'src/lib/bootloader/grub2base.rb', line 60 def pmbr_setup(*devices) return if @pmbr_action == :nothing action_parted = case @pmbr_action when :add then "on" when :remove then "off" else raise "invalid action #{action}" end devices.each do |dev| Yast::Execute.locally("parted", "-s", dev, "disk_set", "pmbr_boot", action_parted) end end |
- (Object) propose
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'src/lib/bootloader/grub2base.rb', line 100 def propose super propose_os_probing propose_terminal propose_timeout propose_encrypted if grub_default.kernel_params.empty? kernel_line = Yast::BootArch.DefaultKernelParams(propose_resume) grub_default.kernel_params.replace(kernel_line) end grub_default.gfxmode ||= "auto" grub_default.recovery_entry.disable unless grub_default.recovery_entry.defined? grub_default.distributor ||= "" grub_default.default = "saved" # always propose true as grub2 itself detect if btrfs used grub_default.generic_set("SUSE_BTRFS_SNAPSHOT_BOOTING", "true") propose_serial nil end |
- (Object) read
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'src/lib/bootloader/grub2base.rb', line 74 def read super grub_default.load grub_cfg = CFA::Grub2::GrubCfg.new begin grub_cfg.load rescue Errno::ENOENT # raise error only outside of first stage, as there may not need to be # grub.cfg generated (bnc#976534) raise unless Yast::Stage.initial end @sections = ::Bootloader::Sections.new(grub_cfg) log.info "grub sections: #{@sections.all}" end |
- (Object) write
90 91 92 93 94 95 96 97 98 |
# File 'src/lib/bootloader/grub2base.rb', line 90 def write super log.info "writing /etc/default/grub #{grub_default.inspect}" grub_default.save @sections.write @password.write Yast::Execute.on_target("/usr/sbin/grub2-mkconfig", "-o", "/boot/grub2/grub.cfg") end |