password function

This commit is contained in:
farhan 2022-03-03 18:03:56 +00:00
parent 8fb6610ee9
commit f7888d5f12
1 changed files with 17 additions and 29 deletions

View File

@ -16,6 +16,20 @@ set_option() {
fi
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
}
# 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.
#
@ -153,22 +167,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
@ -251,20 +252,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
}