Remove the need for prompting the user for a password (#12)

Relates to issue #9
This commit is contained in:
Jason Hee authored and GitHub committed 2021-08-15 21:47:26 +08:00
1 parent ce73240765
commit 153087929c
4 files changed
+5 -27

No files matched your search

+1 -20
View File
@@ -20,12 +20,10 @@ output_file="output.log"
function main() {
read -rp "Enter the username of the new user account:" username
promptForPassword
# Run setup functions
trap cleanup EXIT SIGHUP SIGINT SIGTERM
addUserAccount "${username}" "${password}"
addUserAccount "${username}"
read -rp $'Paste in the public SSH key for the new user:\n' sshKey
echo 'Running setup script...'
@@ -89,21 +87,4 @@ function setupTimezone() {
echo "Timezone is set to $(cat /etc/timezone)" >&3
}
# Keep prompting for the password and password confirmation
function promptForPassword() {
PASSWORDS_MATCH=0
while [ "${PASSWORDS_MATCH}" -eq "0" ]; do
read -s -rp "Enter new UNIX password:" password
printf "\n"
read -s -rp "Retype new UNIX password:" password_confirmation
printf "\n"
if [[ "${password}" != "${password_confirmation}" ]]; then
echo "Passwords do not match! Please try again."
else
PASSWORDS_MATCH=1
fi
done
}
main