From 966d31c6a8ae03d739dd8cdda9fbc89b78f9463c Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 22 Mar 2026 14:01:11 +0000 Subject: [PATCH] Script to set password --- .local/bin/station-setup-password | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.local/bin/station-setup-password b/.local/bin/station-setup-password index 4cb896c..496a330 100755 --- a/.local/bin/station-setup-password +++ b/.local/bin/station-setup-password @@ -5,18 +5,20 @@ echo "Password Setup Script" echo "-------------------------------------" if gum confirm "Do you need to change your password?"; then - while true; do - if passwd; then - echo "Password successfully updated." - break - else - echo "Failed to update password." + new_password=$(gum input --password --placeholder "Enter new password") + confirm_password=$(gum input --password --placeholder "Confirm new password") - if ! gum confirm "Would you like to try again?"; then - break - fi - fi - done -else + if [ "$new_password" != "$confirm_password" ]; then + echo "Passwords do not match." + exit 1 + elif [[ $new_password == "" ]]; then + echo "Password cannot be empty." + exit 1 + fi + sudo sh -c 'mkpasswd -m sha-512 "$new_password" > /persist/passwords/user' + echo + echo "New password written to /persist/passwords/user" + echo "Password will become active next time you run:" + echo "sudo nixos-rebuild switch"e echo "Password change skipped." fi