Skip to content

Commit 6a9ac57

Browse files
authored
Add check for existing Grub config before writing default (#329)
1 parent 674d4f5 commit 6a9ac57

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/ops/iso.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,12 @@ func (b *BuildISOAction) prepareBootArtifacts(isoDir string) error {
347347
if err != nil {
348348
return err
349349
}
350-
return os.WriteFile(filepath.Join(isoDir, constants.GrubPrefixDir, constants.GrubCfg), constants.GrubLiveBiosCfg, constants.FilePerm)
350+
if _, exist := os.Stat(filepath.Join(isoDir, constants.GrubPrefixDir, constants.GrubCfg)); os.IsNotExist(exist) {
351+
return os.WriteFile(filepath.Join(isoDir, constants.GrubPrefixDir, constants.GrubCfg), constants.GrubLiveBiosCfg, constants.FilePerm)
352+
} else {
353+
b.cfg.Logger.Logger.Warn().Msgf("Grub config already exists at %s, skipping using default one", filepath.Join(isoDir, constants.GrubPrefixDir, constants.GrubCfg))
354+
}
355+
return nil
351356
}
352357

353358
func (b BuildISOAction) prepareISORoot(isoDir string, rootDir string) error {

0 commit comments

Comments
 (0)