mirror of
https://github.com/kairos-io/kcrypt.git
synced 2025-08-16 06:33:00 +00:00
Do not fail if we can't find a partition file
This commit is contained in:
parent
641fc6ffa7
commit
1c3a3ac510
@ -8,18 +8,19 @@ GENERATOR_DIR="$2"
|
|||||||
[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
|
[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
|
||||||
|
|
||||||
oem_label=$(getarg rd.cos.oemlabel=)
|
oem_label=$(getarg rd.cos.oemlabel=)
|
||||||
neednet="rd.neednet"
|
|
||||||
|
|
||||||
# See https://github.com/kairos-io/packages/blob/d12b12b043a71d8471454f7b4fc84c3181d2bf60/packages/system/dracut/immutable-rootfs/30cos-immutable-rootfs/cos-generator.sh#L29
|
# See https://github.com/kairos-io/packages/blob/d12b12b043a71d8471454f7b4fc84c3181d2bf60/packages/system/dracut/immutable-rootfs/30cos-immutable-rootfs/cos-generator.sh#L29
|
||||||
{
|
{
|
||||||
echo "[Unit]"
|
echo "[Unit]"
|
||||||
echo "DefaultDependencies=no"
|
echo "DefaultDependencies=no"
|
||||||
echo "Description=kcrypt online mount"
|
|
||||||
echo "Before=cos-immutable-rootfs.service"
|
echo "Before=cos-immutable-rootfs.service"
|
||||||
echo "Conflicts=initrd-switch-root.target"
|
echo "Conflicts=initrd-switch-root.target"
|
||||||
if getargbool 0 $neednet; then
|
if getargbool 0 rd.neednet; then
|
||||||
echo "Wants=network-online.target"
|
echo "Wants=network-online.target"
|
||||||
echo "After=network-online.target"
|
echo "After=network-online.target"
|
||||||
|
echo "Description=kcrypt online mount"
|
||||||
|
else
|
||||||
|
echo "Description=kcrypt mount"
|
||||||
fi
|
fi
|
||||||
# OEM is special as kcrypt plugins might need that in order to unlock other partitions and plugins can reside in /oem as well and kcrypt needs to find them
|
# OEM is special as kcrypt plugins might need that in order to unlock other partitions and plugins can reside in /oem as well and kcrypt needs to find them
|
||||||
if [ -n "${oem_label}" ]; then
|
if [ -n "${oem_label}" ]; then
|
||||||
|
8
main.go
8
main.go
@ -283,7 +283,7 @@ func unlockAll() error {
|
|||||||
|
|
||||||
partitionInfo, _, err := pi.NewPartitionInfoFromFile(pi.DefaultPartitionInfoFile)
|
partitionInfo, _, err := pi.NewPartitionInfoFromFile(pi.DefaultPartitionInfoFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
fmt.Printf("Partition file not found '%s' \n", pi.DefaultPartitionInfoFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
block, err := ghw.Block()
|
block, err := ghw.Block()
|
||||||
@ -291,7 +291,9 @@ func unlockAll() error {
|
|||||||
for _, disk := range block.Disks {
|
for _, disk := range block.Disks {
|
||||||
for _, p := range disk.Partitions {
|
for _, p := range disk.Partitions {
|
||||||
if p.Type == "crypto_LUKS" {
|
if p.Type == "crypto_LUKS" {
|
||||||
p.Label = partitionInfo.LookupLabelForUUID(p.UUID)
|
if partitionInfo != nil {
|
||||||
|
p.Label = partitionInfo.LookupLabelForUUID(p.UUID)
|
||||||
|
}
|
||||||
fmt.Printf("Unmounted Luks found at '%s' LABEL '%s' \n", p.Name, p.Label)
|
fmt.Printf("Unmounted Luks found at '%s' LABEL '%s' \n", p.Name, p.Label)
|
||||||
err = multierror.Append(err, unlockDisk(p))
|
err = multierror.Append(err, unlockDisk(p))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -302,7 +304,7 @@ func unlockAll() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user