Update password handling in config_file function to use PW_CONFIG for clarity and improve validation checks

This commit is contained in:
Michel Roegl-Brunner 2025-05-16 11:09:29 +02:00
parent 8fb0cc90a7
commit bd5eeaca30

View File

@ -310,7 +310,7 @@ BRG="${BRG}"
APT_CACHER_IP="${APT_CACHER_IP}"
DISABLEIP6="${DISABLEIP6}"
TAGS="${TAGS}"
PW="${PW1}"
PW="${PW_CONFIG}"
SSH="${SSH}"
SSH_AUTHORIZED_KEY="${SSH_AUTHORIZED_KEY}"
VERBOSE="${VERBOSE}"
@ -334,7 +334,7 @@ BRG="${BRG}"
APT_CACHER_IP="${APT_CACHER_IP}"
DISABLEIP6="${DISABLEIP6}"
TAGS="${TAGS}"
PW="${PW1}"
PW="${PW_CONFIG}"
SSH="${SSH}"
SSH_AUTHORIZED_KEY="${SSH_AUTHORIZED_KEY}"
VERBOSE="${VERBOSE}"
@ -858,7 +858,11 @@ config_file() {
fi
fi
if [[ -n "${PW-}" ]]; then
if [[ "$PW" == "no" ]]; then
PW=""
else
if [[ "$PW" == *" "* ]]; then
msg_error "Password cannot be empty"
exit
@ -869,6 +873,7 @@ config_file() {
echo -e "${VERIFYPW}${BOLD}${DGN}Root Password: ${BGN}********${CL}"
fi
PW="-password $PW"
fi
else
while true; do
if PW1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --passwordbox "\nSet Root Password (needed for root ssh access)" 9 58 --title "PASSWORD (leave blank for automatic login)" 3>&1 1>&2 2>&3); then
@ -893,6 +898,7 @@ config_file() {
else
PW1="Automatic Login"
PW=""
PW_CONFIG="no"
echo -e "${VERIFYPW}${BOLD}${DGN}Root Password: ${BGN}$PW1${CL}"
break
fi