From 34737af104bf1a2a287e8a4650abd59e64294a3c Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Fri, 23 Jan 2026 08:26:02 -0600 Subject: feat(archsetup): add config file support for unattended installs - Add --config-file PATH CLI flag - Add load_config() function to source config variables - Support USERNAME, PASSWORD, AUTOLOGIN, NO_GPU_DRIVERS config options - Create archsetup.conf.example with documented options Follows same pattern as archzfs project for consistency. --- archsetup | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'archsetup') diff --git a/archsetup b/archsetup index 76abe85..1ccfcf4 100755 --- a/archsetup +++ b/archsetup @@ -29,6 +29,7 @@ fi ### Parse Arguments +config_file="" fresh_install=false show_status_only=false skip_gpu_drivers=false @@ -36,6 +37,15 @@ enable_autologin="" # empty=auto-detect, true=force enable, false=skip while [ $# -gt 0 ]; do case "$1" in + --config-file) + if [[ -n "$2" && ! "$2" =~ ^- ]]; then + config_file="$2" + shift 2 + else + echo "Error: --config-file requires a path argument" + exit 1 + fi + ;; --fresh) fresh_install=true shift @@ -60,26 +70,52 @@ while [ $# -gt 0 ]; do echo "Usage: $0 [OPTIONS]" echo "" echo "Options:" + echo " --config-file PATH Use config file for unattended installation" echo " --fresh Start fresh, ignore previous progress" echo " --status Show installation progress and exit" echo " --no-gpu-drivers Skip GPU driver detection/installation" echo " --autologin Enable automatic console login" echo " --no-autologin Disable automatic console login" echo " --help, -h Show this help message" + echo "" + echo "See archsetup.conf.example for config file template." exit 0 ;; *) echo "Unknown option: $1" - echo "Usage: $0 [--fresh] [--status] [--no-gpu-drivers] [--autologin] [--no-autologin]" + echo "Usage: $0 [--config-file PATH] [--fresh] [--status] [--autologin]" exit 1 ;; esac done -### Constants +### Load Config File + +load_config() { + local config_path="$1" + if [[ ! -f "$config_path" ]]; then + echo "Error: Config file not found: $config_path" + exit 1 + fi + echo "Loading config from: $config_path" + # shellcheck disable=SC1090 + source "$config_path" + + # Map config variables to script variables + [[ -n "$USERNAME" ]] && username="$USERNAME" + [[ -n "$PASSWORD" ]] && password="$PASSWORD" + [[ "$AUTOLOGIN" == "yes" ]] && enable_autologin=true + [[ "$AUTOLOGIN" == "no" ]] && enable_autologin=false + [[ "$NO_GPU_DRIVERS" == "yes" ]] && skip_gpu_drivers=true +} + +# Load config if specified +[[ -n "$config_file" ]] && load_config "$config_file" + +### Constants (defaults, may be overridden by config file) -username="cjennings" -password="welcome" # will be changed on first login. :) +username="${username:-cjennings}" +password="${password:-welcome}" # will be changed on first login. :) archsetup_dir="$(dirname "$(readlink -f "$0")")" dotfiles_dir="$archsetup_dir/dotfiles" -- cgit v1.2.3