From 0c48b19393da6d3c7c70ac37e81c88c47f6b013f Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Tue, 2 Jul 2024 16:24:58 -0400 Subject: [PATCH] Cleanup code --- linuxmint-postsetup.sh | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/linuxmint-postsetup.sh b/linuxmint-postsetup.sh index 6b180b2..95d25ed 100755 --- a/linuxmint-postsetup.sh +++ b/linuxmint-postsetup.sh @@ -92,15 +92,13 @@ function prepare_target() { for subvol in "${!SUBVOLS_DEFAULT[@]}" do - ${cmd} mkdir -p /target/"${SUBVOLS_DEFAULT[$subvol]}" + if [[ ! -d "/target/${SUBVOLS_DEFAULT[$subvol]}" || "$DEBUG" ]]; then + ${cmd} mkdir -p /target/"${SUBVOLS_DEFAULT[$subvol]}" + fi done #${cmd} mkdir -p /target/boot if [[ "$BootPart" == "@boot" ]]; then - ${cmd} mkdir /mnt/boot - ${cmd} mount -o noatime,space_cache=v2,ssd,subvol=@boot "$rootmount" /mnt/boot - ${cmd} rsync -avhHi --delete-after /target/boot/ /mnt/boot/ - ${cmd} umount /mnt/boot ${cmd} mount -o noatime,space_cache=v2,ssd,subvol=@boot "$rootmount" /target/boot else ${cmd} mount "$BootPart" /target/boot @@ -115,7 +113,9 @@ function prepare_target() { ${cmd} mount "$EFIPart" /target/boot/efi if [[ "$SWAP" ]]; then - ${cmd} mkdir -p /target/swap + if [[ ! -d "/target/swap" ]]; then + ${cmd} mkdir -p /target/swap + fi ${cmd} mount -o noatime,ssd,subvol=@swap "$rootmount" /target/swap ${cmd} btrfs filesystem mkswapfile --size "$(get_hibernate_size)g" --uuid clear /target/swap/hibernate.swp fi @@ -135,19 +135,14 @@ function expert_step() { if [[ "$DEBUG" ]]; then echo "genfstab -U /target >> /target/etc/fstab" + echo "==== genfstab result : begin ====" + genfstab -U /target + echo "==== genfstab result : end ====" + echo else genfstab -U /target >> /target/etc/fstab fi - if [[ "$ENCRYPTION" ]]; then - eval "$(blkid -p --output export "$RootPart" | grep UUID)" - if [[ "$DEBUG" ]]; then - echo "echo \"luksvol UUID=$UUID none luks\" >> /target/etc/crypttab" - else - echo "luksvol UUID=$UUID none luks" >> /target/etc/crypttab - fi - fi - if [[ "$SWAP" ]]; then if [[ "$DEBUG" ]]; then echo "echo \"/swap/hibernate.swp none swap defaults 0 0\" >> /target/etc/fstab"