diff options
| -rwxr-xr-x | archsetup | 44 | ||||
| -rw-r--r-- | archsetup.conf.example | 32 |
2 files changed, 72 insertions, 4 deletions
@@ -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" diff --git a/archsetup.conf.example b/archsetup.conf.example new file mode 100644 index 0000000..969079a --- /dev/null +++ b/archsetup.conf.example @@ -0,0 +1,32 @@ +# archsetup.conf - Configuration for unattended installation +# +# Copy this file and edit values for your setup: +# cp archsetup.conf.example archsetup.conf +# +# Then run: +# ./archsetup --config-file archsetup.conf +# +# All fields have defaults - only specify what you want to change. + +############################# +# User Configuration +############################# + +# Username for the primary user account (default: cjennings) +USERNAME=cjennings + +# Initial password - should be changed on first login (default: welcome) +PASSWORD=welcome + +############################# +# System Options +############################# + +# Automatic console login after disk decryption (default: prompt on encrypted systems) +# Options: yes, no +# Only relevant for systems with encrypted root (LUKS or ZFS native encryption) +#AUTOLOGIN=yes + +# Skip GPU driver auto-detection and installation (default: no) +# Set to "yes" if you want to handle GPU drivers manually +#NO_GPU_DRIVERS=no |
