mirror of
https://github.com/kairos-io/kcrypt.git
synced 2025-08-01 15:37:10 +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"
|
||||
|
||||
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
|
||||
{
|
||||
echo "[Unit]"
|
||||
echo "DefaultDependencies=no"
|
||||
echo "Description=kcrypt online mount"
|
||||
echo "Before=cos-immutable-rootfs.service"
|
||||
echo "Conflicts=initrd-switch-root.target"
|
||||
if getargbool 0 $neednet; then
|
||||
if getargbool 0 rd.neednet; then
|
||||
echo "Wants=network-online.target"
|
||||
echo "After=network-online.target"
|
||||
echo "Description=kcrypt online mount"
|
||||
else
|
||||
echo "Description=kcrypt mount"
|
||||
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
|
||||
if [ -n "${oem_label}" ]; then
|
||||
@ -37,4 +38,4 @@ if [ ! -e "$GENERATOR_DIR/initrd-fs.target.requires/kcrypt.service" ]; then
|
||||
mkdir -p "$GENERATOR_DIR"/initrd-fs.target.requires
|
||||
ln -s "$GENERATOR_DIR"/kcrypt.service \
|
||||
"$GENERATOR_DIR"/initrd-fs.target.requires/kcrypt.service
|
||||
fi
|
||||
fi
|
||||
|
8
main.go
8
main.go
@ -283,7 +283,7 @@ func unlockAll() error {
|
||||
|
||||
partitionInfo, _, err := pi.NewPartitionInfoFromFile(pi.DefaultPartitionInfoFile)
|
||||
if err != nil {
|
||||
return err
|
||||
fmt.Printf("Partition file not found '%s' \n", pi.DefaultPartitionInfoFile)
|
||||
}
|
||||
|
||||
block, err := ghw.Block()
|
||||
@ -291,7 +291,9 @@ func unlockAll() error {
|
||||
for _, disk := range block.Disks {
|
||||
for _, p := range disk.Partitions {
|
||||
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)
|
||||
err = multierror.Append(err, unlockDisk(p))
|
||||
if err != nil {
|
||||
@ -302,7 +304,7 @@ func unlockAll() error {
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
Loading…
Reference in New Issue
Block a user