Do not fail if we can't find a partition file

This commit is contained in:
Ettore Di Giacinto 2022-11-23 12:51:55 +01:00
parent 641fc6ffa7
commit 1c3a3ac510
2 changed files with 10 additions and 7 deletions

View File

@ -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

View File

@ -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() {