From 2dc2cd6107b628ab84ebf01cb5c8eb7afb289ebe Mon Sep 17 00:00:00 2001 From: "Ward Nakchbandi (Cosmic Fusion)" <83735213+CosmicFusion@users.noreply.github.com> Date: Thu, 31 Aug 2023 13:32:01 +0300 Subject: [PATCH] Update postinst --- debian/postinst | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/debian/postinst b/debian/postinst index dc24eb0..43fc99a 100644 --- a/debian/postinst +++ b/debian/postinst @@ -25,16 +25,24 @@ ln -sf /usr/lib/x86_64-linux-gnu/libdevmapper-event.so.1.02.1 /usr/lib/libdevmap touch /etc/vconsole.conf -# Use the first crypttab entry as luks for booster (valid for calamares and probably most installers) -if cat /etc/crypttab | grep -v '^#' | head -n1 | cut -f2 | grep -i "UUID=" +# Check if there are entries in crypttab +if [[ $(cat /etc/crypttab | grep -v '^#') ]] then - if cat /boot/refind_linux.conf | grep -i 'rd.luks' - then - sed -i "s#root=#rd.luks.name="$(cat /etc/crypttab | grep -v '^#' | head -n1 | cut -f2 | sed "s#UUID=##")"="$(cat /etc/crypttab | grep -v '^#' | head -n1 | cut -f1)" root=#" /boot/refind_linux.conf - fi + # Do nothing + true else - echo -e "ERROR 1: /etc/crypttab is invalid!\nFirst crypttab entry (presumed to be root luks) is not defined via UUID\nPlease make sure to define luks for root as the first entry in /etc/crypttab via UUID (use blkid)" - exit 1 + # Use the first crypttab entry as luks for booster (valid for calamares and probably most installers) + if cat /etc/crypttab | grep -v '^#' | head -n1 | cut -f2 | grep -i "UUID=" + then + # Check if luks is already configured in refind + if cat /boot/refind_linux.conf | grep -i 'rd.luks' + then + sed -i "s#root=#rd.luks.name="$(cat /etc/crypttab | grep -v '^#' | head -n1 | cut -f2 | sed "s#UUID=##")"="$(cat /etc/crypttab | grep -v '^#' | head -n1 | cut -f1)" root=#" /boot/refind_linux.conf + fi + else + echo -e "ERROR 1: /etc/crypttab is invalid!\nFirst crypttab entry (presumed to be root luks) is not defined via UUID\nPlease make sure to define luks for root as the first entry in /etc/crypttab via UUID (use blkid)" + exit 1 + fi fi