28 lines
943 B
Bash
Executable File
28 lines
943 B
Bash
Executable File
#! /bin/bash
|
|
|
|
echo "-------------------------------------"
|
|
echo "Password Setup Script"
|
|
echo "-------------------------------------"
|
|
|
|
if gum confirm "Do you need to change your password?"; then
|
|
new_password=$(gum input --password --placeholder "Enter new password")
|
|
confirm_password=$(gum input --password --placeholder "Confirm new password")
|
|
|
|
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
|
|
if [[ ! -d /persist/passwords ]]; then
|
|
sudo mkdir -p /persist/passwords
|
|
fi
|
|
sudo sh -c 'mkpasswd -m sha-512 "$new_password" > /persist/passwords/chris'
|
|
echo
|
|
echo "New password written to /persist/passwords/chris"
|
|
echo "Password will become active next time you run:"
|
|
echo "sudo nixos-rebuild switch"e
|
|
echo "Password change skipped."
|
|
fi
|