sparkles: Add kcrypt to images (#195)

*  Add kcrypt to images

This adds the dracut module and the binary to the images.

Related to https://github.com/kairos-io/kairos/issues/184

*  Add Kcrypt post-install hook

Fixes https://github.com/kairos-io/kairos/issues/184
This commit is contained in:
Ettore Di Giacinto
2022-10-07 13:36:32 +02:00
committed by Itxaka
parent a8875f6b4f
commit 78bcb65cb6
2 changed files with 29 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ var All = []Interface{
&RunStage{}, // Shells out to stages defined from the container image
&GrubOptions{}, // Set custom GRUB options
&BundleOption{},
&Kcrypt{},
&Lifecycle{}, // Handles poweroff/reboot by config options
}

View File

@@ -0,0 +1,28 @@
package hook
import (
"fmt"
"time"
config "github.com/kairos-io/kairos/pkg/config"
"github.com/kairos-io/kairos/pkg/utils"
)
type Kcrypt struct{}
func (k Kcrypt) Run(c config.Config) error {
for _, p := range c.Install.Encrypt {
out, err := utils.SH(fmt.Sprintf("kcrypt encrypt %s", p))
if err != nil {
fmt.Printf("could not encrypt partition: %s\n", out+err.Error())
if c.FailOnBundleErrors {
return err
}
// Give time to show the error
time.Sleep(10 * time.Second)
return nil // do not error out
}
}
return nil
}