From b42511b6cf58a20305ccc2faf361126983126c47 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 25 May 2020 10:11:09 +0300 Subject: feat(grub): add timeout setting --- NEWS | 4 ++++ vmdb/plugins/grub.mdwn | 3 +++ vmdb/plugins/grub_plugin.py | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/NEWS b/NEWS index c31a725..2b620d7 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,10 @@ Version 0.15+git, not yet released * Add a `quiet` field to the grub step to configure the kernel boot to be quiet or not. Default is now not quiet, which is a change from before. +* Add a `timeout` field to the grub step to configure grub menu + timeout. Default is now zero seconds, which is a change from the + Debian default of five seconds. + Version 0.15, released 2020-05-05 ------------------------------------ diff --git a/vmdb/plugins/grub.mdwn b/vmdb/plugins/grub.mdwn index c2abe54..645caf0 100644 --- a/vmdb/plugins/grub.mdwn +++ b/vmdb/plugins/grub.mdwn @@ -27,6 +27,9 @@ Step keys: * `quiet` — OPTIONAL; should the kernel be configured to boot quietly? Default is no. +* `timeout` — OPTIONAL; set the grub menu timeout, in seconds. + Defaults to 0 seconds. + Example (in the .vmdb file): - grub: bios diff --git a/vmdb/plugins/grub_plugin.py b/vmdb/plugins/grub_plugin.py index e9501e4..29af435 100644 --- a/vmdb/plugins/grub_plugin.py +++ b/vmdb/plugins/grub_plugin.py @@ -95,6 +95,7 @@ class GrubStepRunner(vmdb.StepRunnerInterface): "tag": "", "image-dev": "", "quiet": False, + "timeout": 0, } def run(self, values, settings, state): @@ -174,6 +175,7 @@ class GrubStepRunner(vmdb.StepRunnerInterface): self.set_grub_cmdline_config(chroot, kernel_params) self.add_grub_crypto_disk(chroot) + self.set_grub_timeout(chroot, values["timeout"]) if console == "serial": self.add_grub_serial_console(chroot) @@ -277,3 +279,8 @@ class GrubStepRunner(vmdb.StepRunnerInterface): filename = self.chroot_path(chroot, "/etc/default/grub") with open(filename, "a") as f: f.write("GRUB_ENABLE_CRYPTODISK=y\n") + + def set_grub_timeout(self, chroot, timeout): + filename = self.chroot_path(chroot, "/etc/default/grub") + with open(filename, "a") as f: + f.write("GRUB_TIMEOUT={}\n".format(timeout)) -- cgit v1.2.1