diff options
Diffstat (limited to 'installer')
| -rwxr-xr-x | installer/archangel | 40 | ||||
| -rw-r--r-- | installer/lib/config.sh | 23 |
2 files changed, 28 insertions, 35 deletions
diff --git a/installer/archangel b/installer/archangel index e04b8d9..12f1cd0 100755 --- a/installer/archangel +++ b/installer/archangel @@ -34,32 +34,20 @@ source "$SCRIPT_DIR/lib/raid.sh" ############################# # Configuration ############################# - -# Filesystem selection (zfs or btrfs) -FILESYSTEM="zfs" # Default to ZFS, can be changed interactively or via config - -# These will be set interactively -HOSTNAME="" -TIMEZONE="" -LOCALE="en_US.UTF-8" -KEYMAP="us" -ROOT_PASSWORD="" -ZFS_PASSPHRASE="" -WIFI_SSID="" -WIFI_PASSWORD="" +# +# User-facing config variables (FILESYSTEM, LOCALE, KEYMAP, ENABLE_SSH, +# NO_ENCRYPT, HOSTNAME, TIMEZONE, SELECTED_DISKS, RAID_LEVEL, WIFI_*, +# ROOT_PASSWORD, ZFS_PASSPHRASE, LUKS_PASSPHRASE) are declared in +# lib/config.sh with their defaults. The monolith trusts those values. # ZFS Configuration POOL_NAME="zroot" COMPRESSION="zstd" ASHIFT="12" # 4K sectors (use 13 for 8K) -# Multi-disk RAID support -SELECTED_DISKS=() # Array of selected disk paths (/dev/sda, /dev/sdb, ...) -ROOT_PARTS=() # Array of root partition paths (populated by partition_disks) -EFI_PARTS=() # Array of EFI partition paths (populated by partition_disks) -RAID_LEVEL="" # "", "mirror", "raidz1", "raidz2", "raidz3" -ENABLE_SSH="yes" # Enable SSH with root login (default yes for headless) -NO_ENCRYPT="no" # Skip ZFS encryption (for testing only) +# Partition arrays populated by partition_disks +ROOT_PARTS=() +EFI_PARTS=() # Logging — initialized by init_logging() at install time only. Sourcing # this script (e.g. from a bats test) loads the function definitions @@ -117,12 +105,6 @@ gather_input() { if [[ -z "$ROOT_PASSWORD" ]]; then error "Config missing required: ROOT_PASSWORD"; fi if [[ ${#SELECTED_DISKS[@]} -eq 0 ]]; then error "Config missing required: DISKS"; fi - # Set defaults for optional values - [[ -z "$FILESYSTEM" ]] && FILESYSTEM="zfs" || true - [[ -z "$LOCALE" ]] && LOCALE="en_US.UTF-8" || true - [[ -z "$KEYMAP" ]] && KEYMAP="us" || true - [[ -z "$ENABLE_SSH" ]] && ENABLE_SSH="yes" || true - # ZFS-specific validation if [[ "$FILESYSTEM" == "zfs" ]]; then if [[ "$NO_ENCRYPT" != "yes" && -z "$ZFS_PASSPHRASE" ]]; then @@ -137,11 +119,6 @@ gather_input() { fi fi - # Validate filesystem choice - if [[ "$FILESYSTEM" != "zfs" && "$FILESYSTEM" != "btrfs" ]]; then - error "Invalid FILESYSTEM: $FILESYSTEM (must be 'zfs' or 'btrfs')" - fi - # Determine RAID level if not specified if [[ -z "$RAID_LEVEL" && ${#SELECTED_DISKS[@]} -gt 1 ]]; then RAID_LEVEL="mirror" @@ -1384,6 +1361,7 @@ main() { parse_args "$@" preflight_checks check_config + validate_filesystem gather_input filesystem_preflight diff --git a/installer/lib/config.sh b/installer/lib/config.sh index fefc838..65703d0 100644 --- a/installer/lib/config.sh +++ b/installer/lib/config.sh @@ -9,12 +9,18 @@ CONFIG_FILE="" UNATTENDED=false -# These get populated by config file or interactive prompts -FILESYSTEM="" # "zfs" or "btrfs" +# These get populated by config file or interactive prompts. +# Optional fields carry their default value here so config.sh is the +# single source of truth — gather_input trusts what's loaded. +FILESYSTEM="zfs" # "zfs" or "btrfs" +LOCALE="en_US.UTF-8" +KEYMAP="us" +ENABLE_SSH="yes" # SSH with root login (default yes for headless) +NO_ENCRYPT="no" # Skip filesystem encryption (testing only) + +# Required fields — installer errors out if any are still empty at install time. HOSTNAME="" TIMEZONE="" -LOCALE="" -KEYMAP="" SELECTED_DISKS=() RAID_LEVEL="" WIFI_SSID="" @@ -134,3 +140,12 @@ validate_config() { fi info "Config validation passed" } + +# Catches a typo in FILESYSTEM= from a config file before the install +# starts. Called from main() after check_config so a bad value never +# reaches gather_input or filesystem_preflight. +validate_filesystem() { + if [[ "$FILESYSTEM" != "zfs" && "$FILESYSTEM" != "btrfs" ]]; then + error "Invalid FILESYSTEM: $FILESYSTEM (must be 'zfs' or 'btrfs')" + fi +} |
