Merge pull request #267 from mfgbhatti/password

Password function
This commit is contained in:
Chris Titus 2022-07-30 10:06:22 -05:00 committed by GitHub
commit 9c5f7947a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 29 deletions

View File

@ -23,6 +23,19 @@ set_option() {
echo "${1}=${2}" >>$CONFIG_FILE # add option
}
set_password() {
read -rs -p "Please enter password: " PASSWORD1
echo -ne "\n"
read -rs -p "Please re-enter password: " PASSWORD2
echo -ne "\n"
if [[ "$PASSWORD1" == "$PASSWORD2" ]]; then
set_option "$1" "$PASSWORD1"
else
echo -ne "ERROR! Passwords do not match. \n"
set_password
fi
}
root_check() {
if [[ "$(id -u)" != "0" ]]; then
echo -ne "ERROR! This script must be run under the 'root' user!\n"
@ -61,6 +74,7 @@ background_checks() {
pacman_check
docker_check
}
# Renders a text based list of options that can be selected by the
# user using up, down and enter keys and returns the chosen option.
#
@ -200,22 +214,9 @@ case $? in
0) set_option FS btrfs;;
1) set_option FS ext4;;
2)
while true; do
echo -ne "Please enter your luks password: \n"
read -s luks_password # read password without echo
echo -ne "Please repeat your luks password: \n"
read -s luks_password2 # read password without echo
if [ "$luks_password" = "$luks_password2" ]; then
set_option LUKS_PASSWORD $luks_password
set_password "LUKS_PASSWORD"
set_option FS luks
break
else
echo -e "\nPasswords do not match. Please try again. \n"
fi
done
;;
;;
3) exit ;;
*) echo "Wrong option please select again"; filesystem;;
esac
@ -303,20 +304,7 @@ drivessd
userinfo () {
read -p "Please enter your username: " username
set_option USERNAME ${username,,} # convert to lower case as in issue #109
while true; do
echo -ne "Please enter your password: \n"
read -s password # read password without echo
echo -ne "Please repeat your password: \n"
read -s password2 # read password without echo
if [ "$password" = "$password2" ]; then
set_option PASSWORD $password
break
else
echo -e "\nPasswords do not match. Please try again. \n"
fi
done
set_password "PASSWORD"
read -rep "Please enter your hostname: " nameofmachine
set_option NAME_OF_MACHINE $nameofmachine
}