fix while loop

This commit is contained in:
mfgbhatti 2022-02-06 11:10:18 +00:00
parent cb3183dd2a
commit aab3d2a25c
1 changed files with 27 additions and 21 deletions

View File

@ -11,7 +11,9 @@ else
fi fi
make_boot() { make_boot() {
mkfs.vfat -F32 -n "$1" "$2" if [[ "$UEFI" -eq 1 ]]; then
mkfs.vfat -F32 -n "$BOOT" "$PART1"
fi
} }
something_failed() { something_failed() {
@ -47,7 +49,7 @@ do_format() {
} }
do_lvm() { do_lvm() {
i=1 i=0
while [[ "$i" -le "$LVM_PART_NUM" ]]; do while [[ "$i" -le "$LVM_PART_NUM" ]]; do
if [[ "$i" -eq "$LVM_PART_NUM" ]]; then if [[ "$i" -eq "$LVM_PART_NUM" ]]; then
lvcreate -l 100%FREE "$LVM_VG" -n "${LVM_NAMES[$i]}" lvcreate -l 100%FREE "$LVM_VG" -n "${LVM_NAMES[$i]}"
@ -60,7 +62,7 @@ do_lvm() {
lvm_mount() { lvm_mount() {
vgchange -ay &>/dev/null vgchange -ay &>/dev/null
i=1 i=0
while [[ "$i" -le "$LVM_PART_NUM" ]]; do while [[ "$i" -le "$LVM_PART_NUM" ]]; do
lvchange -ay /dev/"$LVM_VG"/"${LVM_NAMES[$i]}" &>/dev/null lvchange -ay /dev/"$LVM_VG"/"${LVM_NAMES[$i]}" &>/dev/null
do_format /dev/"$LVM_VG"/"${LVM_NAMES[$i]}" do_format /dev/"$LVM_VG"/"${LVM_NAMES[$i]}"
@ -75,13 +77,17 @@ lvm_mount() {
} }
do_partition() { do_partition() {
sgdisk -Z "$DISK" # zap all on disk if [[ "$UEFI" -eq 1 ]]; then
sgdisk -a 2048 -o "$DISK" # new gpt disk 2048 alignment sgdisk -Z "$DISK" # zap all on disk
sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:"BIOSBOOT" "$DISK" # partition 1 (BIOS Boot Partition) sgdisk -a 2048 -o "$DISK" # new gpt disk 2048 alignment
sgdisk -n 2::+300M --typecode=2:ef00 --change-name=2:"$BOOT" "$DISK" # partition 2 (UEFI Boot Partition) sgdisk -n 1::+300M --typecode=1:ef00 --change-name=1:"$BOOT" "$DISK" # partition 2 (UEFI Boot Partition)
sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:"$ROOT" "$DISK" # partition 3 (Root), default start, remaining sgdisk -n 2::-0 --typecode=2:8300 --change-name=2:"$ROOT" "$DISK" # partition 3 (Root), default start, remaining
if [[ "$UEFI" -eq 0 ]]; then else [[ "$UEFI" -eq 0 ]]
sgdisk -A 1:set:2 "$DISK" sgdisk -Z "$DISK" # zap all on disk
sgdisk -a 2048 -o "$DISK"
sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:"BIOSBOOT" "$DISK" # partition 1 (BIOS Boot Partition)
sgdisk -n 2::-0 --typecode=2:8300 --change-name=2:"$ROOT" "$DISK"
fi fi
} }
@ -102,36 +108,36 @@ mkdir /mnt &>/dev/null # Hiding error message if any
title "Partitioning disk" title "Partitioning disk"
if [[ "$SDD" -eq 1 ]]; then if [[ "$SDD" -eq 1 ]]; then
PART1=${DISK}p1
PART2=${DISK}p2 PART2=${DISK}p2
PART3=${DISK}p3
else else
PART1=${DISK}1
PART2=${DISK}2 PART2=${DISK}2
PART3=${DISK}3
fi fi
if [[ "$LAYOUT" -eq 1 ]]; then if [[ "$LAYOUT" -eq 1 ]]; then
do_partition do_partition
make_boot "$BOOT" "$PART2" make_boot
do_btrfs "$ROOT" "$PART3" do_btrfs "$ROOT" "$PART2"
elif [[ "$LVM" -eq 1 ]]; then elif [[ "$LVM" -eq 1 ]]; then
do_partition do_partition
sgdisk --typecode=3:8e00 "$DISK" sgdisk --typecode=2:8e00 "$DISK"
partprobe "$DISK" partprobe "$DISK"
make_boot "$BOOT" "$PART2" make_boot
pvcreate "$PART3" pvcreate "$PART2"
vgcreate "$LVM_VG" "$PART3" vgcreate "$LVM_VG" "$PART2"
do_lvm do_lvm
lvm_mount lvm_mount
elif [[ "$LUKS" -eq 1 ]]; then elif [[ "$LUKS" -eq 1 ]]; then
do_partition do_partition
make_boot "$BOOT" "$PART2" make_boot
# enter luks password to cryptsetup and format root partition # enter luks password to cryptsetup and format root partition
echo -n "$LUKS_PASSWORD" | cryptsetup -y -v luksFormat "$PART3" - echo -n "$LUKS_PASSWORD" | cryptsetup -y -v luksFormat "$PART2" -
# open luks container and ROOT will be place holder # open luks container and ROOT will be place holder
echo -n "$LUKS_PASSWORD" | cryptsetup open "$PART3" "$ROOT" - echo -n "$LUKS_PASSWORD" | cryptsetup open "$PART2" "$ROOT" -
pvcreate "$LUKS_PATH" pvcreate "$LUKS_PATH"
vgcreate "$LVM_VG" "$LUKS_PATH" vgcreate "$LVM_VG" "$LUKS_PATH"
do_lvm do_lvm