sbctl/create-keys: Rework output and keypath handling

In the future we might want to initialize a new set of keys. It makes
sense to pass the output directory so we can create new keys directly in
an alternative path and overwrite, e.g for key rotation.

Signed-off-by: Morten Linderud <morten@linderud.pw>
This commit is contained in:
Morten Linderud 2021-06-01 00:53:55 +02:00
parent 1bf2810228
commit d04e117cbc
No known key found for this signature in database
GPG Key ID: E742683BA08CB2FF
1 changed files with 4 additions and 2 deletions

View File

@ -19,13 +19,15 @@ var createKeysCmd = &cobra.Command{
if err != nil {
return err
}
logging.Print("Using Owner UUID %s\n", uuid)
logging.Print("Created Owner UUID %s\n", uuid)
if !sbctl.CheckIfKeysInitialized(sbctl.KeysPath) {
logging.Print("Creating secure boot keys...")
err := sbctl.InitializeSecureBootKeys(sbctl.DatabasePath)
err := sbctl.InitializeSecureBootKeys(sbctl.KeysPath)
if err != nil {
logging.NotOk("")
return fmt.Errorf("couldn't initialize secure boot: %w", err)
}
logging.Ok("\nSecure boot keys created!")
} else {
logging.Ok("Secure boot keys has already been created!")
}