diff options
| author | Craig Jennings <c@cjennings.net> | 2026-01-25 13:50:20 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-01-25 13:50:20 -0600 |
| commit | cf05aee4ba2028d9148878298d13023340bf2b1f (patch) | |
| tree | 479b97742fb172ef38a1c802e6d84e8987cce974 | |
| parent | fdb9731ff01f056d66d7ff30f9689856f5acfa64 (diff) | |
feat(archsetup): add interactive username/password prompts
Replace hardcoded "welcome" password with interactive prompts during
preflight checks. Fixes gnome-keyring password mismatch issue.
- Username validation (lowercase, starts with letter, alphanumeric)
- Password confirmation (enter twice, must match)
- Remove forced password change on first login (chage -d 0)
| -rwxr-xr-x | archsetup | 58 | ||||
| -rw-r--r-- | archsetup.conf.example | 13 |
2 files changed, 57 insertions, 14 deletions
@@ -128,8 +128,8 @@ load_config() { ### Configuration Defaults # These can be overridden via --config-file -username="${username:-cjennings}" -password="${password:-welcome}" # CHANGE ON FIRST LOGIN +username="${username:-}" # prompted if not set +password="${password:-}" # prompted if not set locale="${locale:-}" # set via prompt if not configured desktop_env="${desktop_env:-hyprland}" # options: dwm, hyprland, none @@ -146,7 +146,7 @@ dotemacs_repo="${dotemacs_repo:-https://git.cjennings.net/dotemacs.git}" archsetup_repo="${archsetup_repo:-https://git.cjennings.net/archsetup.git}" logfile="/var/log/archsetup-$(date +'%Y-%m-%d-%H-%M-%S').log" -source_dir="/home/$username/.local/src" # aur/git source goes here +source_dir="" # set in preflight_checks after username is known packages_before="/var/log/archsetup-preexisting-package-list.txt" packages_after="/var/log/archsetup-post-install-package-list.txt" archsetup_packages="/var/log/archsetup-installed-packages.txt" @@ -315,6 +315,51 @@ preflight_checks() { echo " [OK] Locale: $locale (selected)" fi + # Prompt for username if not set + if [[ -z "$username" ]]; then + echo "" + read -r -p "Enter username for primary account: " username + if [[ -z "$username" ]]; then + echo "ERROR: Username cannot be empty" + exit 1 + fi + # Validate username (lowercase, starts with letter, alphanumeric + underscore) + if [[ ! "$username" =~ ^[a-z][a-z0-9_]*$ ]]; then + echo "ERROR: Invalid username" + echo " Must start with lowercase letter, contain only lowercase letters, numbers, underscores" + exit 1 + fi + echo " [OK] Username: $username" + else + echo " [OK] Username: $username (from config)" + fi + + # Prompt for password if not set + if [[ -z "$password" ]]; then + echo "" + while true; do + read -r -s -p "Enter password for $username: " password + echo "" + read -r -s -p "Confirm password: " password_confirm + echo "" + if [[ "$password" != "$password_confirm" ]]; then + echo " Passwords do not match. Try again." + continue + fi + if [[ -z "$password" ]]; then + echo " Password cannot be empty. Try again." + continue + fi + break + done + echo " [OK] Password: set" + else + echo " [OK] Password: (from config)" + fi + + # Set paths that depend on username + source_dir="/home/$username/.local/src" + echo "Pre-flight checks passed." echo "" } @@ -1267,9 +1312,7 @@ hyprland() { pacman_install gammastep # night light (replaces redshift) pacman_install brightnessctl # brightness control pacman_install pamixer # audio control - - # st terminal still works on Wayland via XWayland - git_install "$st_repo" + pacman_install foot # native Wayland terminal } ### Display Server (conditional) @@ -1845,9 +1888,6 @@ outro() { action="Cleanup" && display "title" "$action" - action="forcing user password change on first login" && display "task" "$action" - chage -d 0 "$username" >> "$logfile" 2>&1 || error_warn "$action" "$?" - display "subtitle" "Statistics" action="identifying newly installed packages" && display "task" "$action" pacman -Q > "$packages_after" || error_warn "$action" "$?" diff --git a/archsetup.conf.example b/archsetup.conf.example index 0fff4d8..fe8cd26 100644 --- a/archsetup.conf.example +++ b/archsetup.conf.example @@ -12,11 +12,14 @@ # User Configuration ############################# -# Username for the primary user account (default: cjennings) -USERNAME=cjennings - -# Initial password - CHANGE ON FIRST LOGIN (default: welcome) -PASSWORD=welcome +# Username for the primary user account +# If not set, you will be prompted during installation +#USERNAME=myusername + +# Password for the primary user account +# If not set, you will be prompted during installation (recommended) +# For automated installs, set this to your desired password +#PASSWORD=mysecurepassword ############################# # System Options |
