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) # Run z.sh and provide sequence of inputs for test scenario 1 (Default settings)
# Input sequence: # Input sequence:
# 1 (Enter) - Select Disk 1 # 1 (Enter) - Select Disk 1
# 1 (Enter) - Select Seed # (Enter) - Select Seed (should default to /dev/vda1)
# 1 (Enter) - Select Sprout # (Enter) - Select Sprout (should default to /dev/vda2)
# 1 (Enter) - Select EFI # (Enter) - Select EFI (should default to /dev/vda3)
# yes - Confirm formatting # yes - Confirm formatting
# (Enter) - Default packages # (Enter) - Default packages
# Yes - Confirm installation # Yes - Confirm installation

30
z.sh
View file

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