Skip to content

Commit 00e27f2

Browse files
committed
install: support grub2/50_coreos.cfg for console replacement
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
1 parent 0e02b9f commit 00e27f2

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/install.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,17 @@ fn write_console(mountpoint: &Path, platform: Option<&str>, consoles: &[Console]
636636

637637
// set grub commands
638638
if grub_commands != metal_spec.grub_commands {
639-
let path = mountpoint.join("grub2/grub.cfg");
640-
let grub_cfg = fs::read_to_string(&path).context("reading grub.cfg")?;
639+
// prefer the new grub2/50_coreos.cfg, but fallback to grub2/grub.cfg
640+
let mut name = "grub2/50_coreos.cfg";
641+
let mut path = mountpoint.join(name);
642+
if !path.exists() {
643+
name = "grub2/grub.cfg";
644+
path = mountpoint.join(name);
645+
}
646+
let grub_cfg = fs::read_to_string(&path).context(format!("reading {}", name))?;
641647
let new_grub_cfg = update_grub_cfg_console_settings(&grub_cfg, &grub_commands)
642-
.context("updating grub.cfg")?;
643-
fs::write(&path, new_grub_cfg).context("writing grub.cfg")?;
648+
.context(format!("updating {}", name))?;
649+
fs::write(&path, new_grub_cfg).context(format!("writing {}", name))?;
644650
}
645651
Ok(())
646652
}

0 commit comments

Comments
 (0)