Skip to content

Commit

Permalink
install: support grub2/50_coreos.cfg for console replacement
Browse files Browse the repository at this point in the history
Upstream we are starting to use grub configs that are partially
baked into bootupd [1] and partially baked into the image via
the OS vendor (in our case a grub2/50_coreos.cfg file [2]). Let's
look first to see if grub2/50_coreos.cfg exists when trying to
write new console settings before falling back to grub2/grub.cfg.

[1] coreos/bootupd#543
[2] coreos/fedora-coreos-config#2769
  • Loading branch information
dustymabe committed Dec 15, 2023
1 parent 0e02b9f commit 93ef156
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ nav_order: 8

Major changes:

- Support alternative grub2/50_coreos.cfg location for grub console configuration

Minor changes:

Expand Down
14 changes: 10 additions & 4 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,17 @@ fn write_console(mountpoint: &Path, platform: Option<&str>, consoles: &[Console]

// set grub commands
if grub_commands != metal_spec.grub_commands {
let path = mountpoint.join("grub2/grub.cfg");
let grub_cfg = fs::read_to_string(&path).context("reading grub.cfg")?;
// prefer the new grub2/50_coreos.cfg, but fallback to grub2/grub.cfg
let mut name = "grub2/50_coreos.cfg";
let mut path = mountpoint.join(name);
if !path.exists() {
name = "grub2/grub.cfg";
path = mountpoint.join(name);
}
let grub_cfg = fs::read_to_string(&path).context(format!("reading {}", name))?;
let new_grub_cfg = update_grub_cfg_console_settings(&grub_cfg, &grub_commands)
.context("updating grub.cfg")?;
fs::write(&path, new_grub_cfg).context("writing grub.cfg")?;
.context(format!("updating {}", name))?;
fs::write(&path, new_grub_cfg).context(format!("writing {}", name))?;
}
Ok(())
}
Expand Down

0 comments on commit 93ef156

Please sign in to comment.