mirror of
https://github.com/kairos-io/kcrypt.git
synced 2025-07-18 17:31:47 +00:00
Trigger udev events also on lock
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
7de640988f
commit
c936f74913
@ -2,15 +2,16 @@ package lib
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gofrs/uuid"
|
|
||||||
"github.com/jaypipes/ghw"
|
|
||||||
"github.com/jaypipes/ghw/pkg/block"
|
|
||||||
configpkg "github.com/kairos-io/kcrypt/pkg/config"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gofrs/uuid"
|
||||||
|
"github.com/jaypipes/ghw"
|
||||||
|
"github.com/jaypipes/ghw/pkg/block"
|
||||||
|
configpkg "github.com/kairos-io/kcrypt/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateLuks(dev, password, version string, cryptsetupArgs ...string) error {
|
func CreateLuks(dev, password, version string, cryptsetupArgs ...string) error {
|
||||||
@ -57,6 +58,13 @@ func Luksify(label, version string, tpm bool) (string, error) {
|
|||||||
return "", fmt.Errorf("version must be luks1 or luks2")
|
return "", fmt.Errorf("version must be luks1 or luks2")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure ghw will see all partitions correctly
|
||||||
|
out, err := SH("udevadm trigger --settle -v --type=all")
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("udevadm trigger failed: %w, out: %s", err, out)
|
||||||
|
}
|
||||||
|
SH("sync") //nolint:errcheck
|
||||||
|
|
||||||
part, b, err := FindPartition(label)
|
part, b, err := FindPartition(label)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -109,7 +117,7 @@ func Luksify(label, version string, tpm bool) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd := fmt.Sprintf("mkfs.ext4 -L %s %s", label, devMapper)
|
cmd := fmt.Sprintf("mkfs.ext4 -L %s %s", label, devMapper)
|
||||||
out, err := SH(cmd)
|
out, err = SH(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("mkfs err: %w, out: %s", err, out)
|
return "", fmt.Errorf("mkfs err: %w, out: %s", err, out)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user