feat: Implement default partition selections for Seed, Sprout, and EFI devices, allowing users to accept them by pressing Enter.

This commit is contained in:
Zeev Diukman 2026-01-18 08:47:41 +02:00
parent f5025dfb39
commit 747085e5fd
2 changed files with 23 additions and 13 deletions

View file

@ -81,9 +81,9 @@ echo "--- Starting z.sh in Mock Environment ---"
# Run z.sh and provide sequence of inputs for test scenario 1 (Default settings)
# Input sequence:
# 1 (Enter) - Select Disk 1
# 1 (Enter) - Select Seed
# 1 (Enter) - Select Sprout
# 1 (Enter) - Select EFI
# (Enter) - Select Seed (should default to /dev/vda1)
# (Enter) - Select Sprout (should default to /dev/vda2)
# (Enter) - Select EFI (should default to /dev/vda3)
# yes - Confirm formatting
# (Enter) - Default packages
# Yes - Confirm installation

30
z.sh
View file

@ -2,10 +2,10 @@
set -e
# Configuration variables (will be populated via user selection)
seed_device=""
sprout_device=""
efi_device=""
# Configuration variables (will be populated via user selection or defaults if user press enter for each input)
seed_device="/dev/vda1"
sprout_device="/dev/vda2"
efi_device="/dev/vda3"
# 1. Select Disk
echo "Available storage disks:"
@ -55,9 +55,19 @@ get_partition() {
done
while true; do
read -r -p "$ps3_val (default 1): " REPLY
REPLY=${REPLY:-1}
if [[ "$REPLY" -gt 0 && "$REPLY" -le "${#parts[@]}" ]]; then
local def_idx=1
if [[ -n "$default_val" ]]; then
for i in "${!parts[@]}"; do
if [[ "${parts[i]}" == "$default_val"* ]]; then
def_idx=$((i+1))
break
fi
done
fi
read -r -p "$ps3_val (default $def_idx): " REPLY
REPLY=${REPLY:-$def_idx}
if [[ "$REPLY" =~ ^[0-9]+$ ]] && [[ "$REPLY" -gt 0 && "$REPLY" -le "${#parts[@]}" ]]; then
selection="${parts[$((REPLY-1))]}"
eval "$var_name=$(echo "$selection" | cut -d' ' -f1)"
break
@ -67,9 +77,9 @@ get_partition() {
done
}
get_partition "--- Select Seed Partition ---" "Seed device: " seed_device
get_partition "--- Select Sprout Partition ---" "Sprout device: " sprout_device
get_partition "--- Select EFI Partition ---" "EFI device: " efi_device
get_partition "--- Select Seed Partition ---" "Seed device: " seed_device "$seed_device"
get_partition "--- Select Sprout Partition ---" "Sprout device: " sprout_device "$sprout_device"
get_partition "--- Select EFI Partition ---" "EFI device: " efi_device "$efi_device"
echo ""
echo "Configuration Summary:"