i'm too stupid for bash...

This commit is contained in:
lulzette 2021-01-24 17:56:08 +03:00
parent 55514aca5b
commit 31649a6948

View File

@ -107,7 +107,7 @@ echo "=> /boot"
mkfs.vfat $targetDrive"2"
echo "=> rootfs"
if $encryptedDevice then
if $encryptedDevice ; then
cryptsetup luksFormat -v $targetDrive"3"
cryptsetup open $targetDrive"3" targetLuks
mkfs.ext4 -q /dev/mapper/targetLuks
@ -120,14 +120,14 @@ sleep 15
##get disk's uuid
echo "==> Got UUIDs!"
UUIDS=($(blkid $targetDrive"1" $targetDrive"2" $targetDrive"3" -o value -s UUID))
if $encryptedDevice then
if $encryptedDevice ; then
UUIDS[3]=UUIDS[2]
UUIDS[2]=`blkid /dev/mapper/targetLuks -o value -s UUID`
fi
##mount disks
echo "==> Mounting..."
if $encryptedDevice then
if $encryptedDevice ; then
mount /dev/mapper/targetLuks /mnt
else
mount $targetDrive"3" /mnt
@ -156,7 +156,7 @@ rm /mnt/etc/fstab.orig #TODO OFC we need to check mountpoint, not only type of F
echo "==> Result:"
cat /mnt/etc/fstab
##update grub linux options
if $encryptedDevice then
if $encryptedDevice ; then
cat /mnt/etc/default/grub | sed 's/cryptdevice=UUID=[A-Fa-f0-9-]*:cryptroot /cryptdevice=UUID='${UUIDS[3]}':cryptroot/' > /mnt/etc/default/grub
else
cat /mnt/etc/default/grub | sed 's/cryptdevice=UUID=[A-Fa-f0-9-]*:cryptroot //' > /mnt/etc/default/grub