2022-10-07 11:36:32 +00:00
|
|
|
package hook
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2023-03-18 09:27:18 +00:00
|
|
|
"github.com/kairos-io/kairos-sdk/utils"
|
2023-05-08 07:43:47 +00:00
|
|
|
"github.com/kairos-io/kairos/v2/pkg/config"
|
2022-10-07 11:36:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Kcrypt struct{}
|
|
|
|
|
|
|
|
func (k Kcrypt) Run(c config.Config) error {
|
2022-10-18 05:45:07 +00:00
|
|
|
|
|
|
|
if len(c.Install.Encrypt) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-10-07 11:36:32 +00:00
|
|
|
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
|
|
|
|
}
|
2022-11-16 11:35:59 +00:00
|
|
|
|
2022-10-07 11:36:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|