Script to set password

This commit is contained in:
2026-03-22 14:01:11 +00:00
parent 9e59127cb2
commit 966d31c6a8

View File

@@ -5,18 +5,20 @@ echo "Password Setup Script"
echo "-------------------------------------" echo "-------------------------------------"
if gum confirm "Do you need to change your password?"; then if gum confirm "Do you need to change your password?"; then
while true; do new_password=$(gum input --password --placeholder "Enter new password")
if passwd; then confirm_password=$(gum input --password --placeholder "Confirm new password")
echo "Password successfully updated."
break
else
echo "Failed to update password."
if ! gum confirm "Would you like to try again?"; then if [ "$new_password" != "$confirm_password" ]; then
break echo "Passwords do not match."
fi exit 1
fi elif [[ $new_password == "" ]]; then
done echo "Password cannot be empty."
else 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." echo "Password change skipped."
fi fi