Class: Bootloader::Grub2Widget::ConsoleWidget
- Inherits:
-
CWM::CustomWidget
- Object
- CWM::CustomWidget
- Bootloader::Grub2Widget::ConsoleWidget
show all
- Includes:
- Grub2Helper
- Defined in:
- src/lib/bootloader/grub2_widgets.rb
Overview
Represents graphical and serial console setup for bootloader
Allows to configure terminal for grub. It can configure grub
to use either graphical terminal, console or console over serial line.
Graphical or serial terminal has to be selected explicitly. Either
one of them or both at once.
Native console is configured as a fallback when nothing else is selected.
Instance Method Summary
collapse
#grub2, #grub_default, #password, #stage1
Constructor Details
Returns a new instance of ConsoleWidget.
340
341
342
343
344
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 340
def initialize
textdomain "bootloader"
super
end
|
Instance Method Details
#contents ⇒ Object
346
347
348
349
350
351
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 346
def contents
VBox(
graphical_console_frame,
serial_console_frame
)
end
|
#handle(event) ⇒ Object
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 422
def handle(event)
return if event["ID"] != :browsegfx
theme_dir = "/boot/grub2/themes/openSUSE"
theme_dir = "/boot/grub2" unless ::Dir.exist?(theme_dir)
file = Yast::UI.AskForExistingFile(
theme_dir,
"*.txt",
_("Choose new graphical theme file")
)
Yast::UI.ChangeWidget(Id(:theme), :Value, file) if file
nil
end
|
#help ⇒ Object
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 353
def help
_(
"<p><b>Graphical console</b> when checked it allows to use various " \
"display resolutions. The <tt>auto</tt> option tries to find " \
"the best one when booting starts.</p>\n" \
"<p><b>Serial console</b> when checked it redirects the boot output " \
"to a serial device like <tt>ttyS0</tt>. " \
"At least the <tt>--unit</tt> option has to be specified, " \
"and the complete syntax is <tt>%s</tt>. " \
"Other parts are optional and if not set, a default is used. " \
"<tt>NUM</tt> in commands stands for a positive number like 8. " \
"Example parameters are <tt>serial --speed=38400 --unit=0</tt>.</p>"
) % syntax
end
|
#init ⇒ Object
369
370
371
372
373
374
375
376
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 369
def init
init_console
init_gfxterm
Yast::UI.ChangeWidget(Id(:theme), :Value, grub_default.theme || "")
rescue RuntimeError
raise ::Bootloader::UnsupportedOption, "GRUB_TERMINAL"
end
|
#store ⇒ Object
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 400
def store
use_serial = Yast::UI.QueryWidget(Id(:console_frame), :Value)
use_gfxterm = Yast::UI.QueryWidget(Id(:gfxterm_frame), :Value)
use_console = !use_serial && !use_gfxterm
grub_default.terminal = []
grub_default.terminal = [:gfxterm] if use_gfxterm
if use_serial
console_value = Yast::UI.QueryWidget(Id(:console_args), :Value)
BootloaderFactory.current.enable_serial_console(console_value)
elsif use_console
grub_default.terminal = [:console]
end
mode = Yast::UI.QueryWidget(Id(:gfxmode), :Value)
grub_default.gfxmode = mode if mode != ""
theme = Yast::UI.QueryWidget(Id(:theme), :Value)
grub_default.theme = theme if theme != ""
end
|
#validate ⇒ Object
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 378
def validate
if Yast::UI.QueryWidget(Id(:console_frame), :Value)
console_value = Yast::UI.QueryWidget(Id(:console_args), :Value)
if console_value.strip.empty?
Yast::Report.Error(
_("To enable serial console you must provide the corresponding arguments.")
)
Yast::UI.SetFocus(Id(:console_args))
return false
end
if ::Bootloader::SerialConsole.load_from_console_args(console_value).nil?
msg = _("To enable the serial console you must provide the corresponding arguments.\n" \
"The \"unit\" argument is required, the complete syntax is:\n%s") % syntax
Yast::Report.Error(msg)
Yast::UI.SetFocus(Id(:console_args))
return false
end
end
true
end
|