feat(installation): allow to abort installation if sentinel file is present

Signed-off-by: mudler <mudler@localai.io>
This commit is contained in:
mudler
2024-08-21 09:25:10 +02:00
parent f3601ef61d
commit 75ff3cbdd4
4 changed files with 87 additions and 64 deletions

View File

@@ -609,3 +609,15 @@ func SystemdBootConfWriter(fs v1.FS, filePath string, conf map[string]string) er
return writer.Flush()
}
// CheckFailedInstallation checks if the state file if present, and if it is, it will return true and the error with the file content indicating why we should abort the installation
func CheckFailedInstallation(stateFile string) (bool, error) {
if _, err := os.Stat(stateFile); err == nil {
content, err := os.ReadFile(stateFile)
if err != nil {
return true, err
}
return true, fmt.Errorf("Installation failed: %s", string(content))
}
return false, nil
}