From b6d737fc9e3cee641afe7b855c5356122537850b Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 19 May 2026 02:19:04 -0500 Subject: refactor: wire validate_config into the unattended install path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit validate_config in lib/config.sh was unreachable from main(). Its empty-field checks duplicated four lines in gather_input's unattended branch. validate_config also has two checks gather_input doesn't: that every entry in SELECTED_DISKS is a real block device, and that TIMEZONE exists under /usr/share/zoneinfo. Neither check ever ran. A config with a typo'd disk path slipped past gather_input and surfaced as an obscure sgdisk error inside the destructive partitioning step. I wired validate_config into main() after validate_filesystem, gated on UNATTENDED so it only runs against an already-loaded config. I dropped the four duplicate empty-field checks from gather_input's unattended branch. The filesystem-specific passphrase checks stay there because they're coupled to the FILESYSTEM branch logic. validate_config reports every missing field at once instead of dying on the first. A config with five missing fields tells you all five in one pass. I removed the four corresponding gather_input bats tests. validate_config's existing unit tests in test_config.bats already cover their assertions. Bats: 178 → 174. --- installer/archangel | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'installer') diff --git a/installer/archangel b/installer/archangel index beee692..939c686 100755 --- a/installer/archangel +++ b/installer/archangel @@ -99,11 +99,8 @@ filesystem_preflight() { gather_input() { if [[ "$UNATTENDED" == true ]]; then - # Validate required config values - if [[ -z "$HOSTNAME" ]]; then error "Config missing required: HOSTNAME"; fi - if [[ -z "$TIMEZONE" ]]; then error "Config missing required: TIMEZONE"; fi - if [[ -z "$ROOT_PASSWORD" ]]; then error "Config missing required: ROOT_PASSWORD"; fi - if [[ ${#SELECTED_DISKS[@]} -eq 0 ]]; then error "Config missing required: DISKS"; fi + # Required-field, disk, and timezone validation runs in main() + # via validate_config before this function is reached. # ZFS-specific validation if [[ "$FILESYSTEM" == "zfs" ]]; then @@ -1362,6 +1359,7 @@ main() { preflight_checks check_config validate_filesystem + [[ "$UNATTENDED" == true ]] && validate_config gather_input filesystem_preflight -- cgit v1.2.3