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, #sections, #stage1
Constructor Details
Returns a new instance of ConsoleWidget.
532
533
534
535
536
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 532
def initialize
textdomain "bootloader"
super
end
|
Instance Method Details
#contents ⇒ Object
538
539
540
541
542
543
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 538
def contents
VBox(
graphical_console_frame,
serial_console_frame
)
end
|
#handle(event) ⇒ Object
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 614
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
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 545
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
561
562
563
564
565
566
567
568
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 561
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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 592
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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
|
# File 'src/lib/bootloader/grub2_widgets.rb', line 570
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
|