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.
395
396
397
398
399
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 395
def initialize
textdomain "bootloader"
super
end
|
Instance Method Details
#contents ⇒ Object
401
402
403
404
405
406
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 401
def contents
VBox(
graphical_console_frame,
serial_console_frame
)
end
|
#handle(event) ⇒ Object
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 477
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
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 408
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
424
425
426
427
428
429
430
431
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 424
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 455
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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 433
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
|