fix: redirect whiptail input from /dev/tty for piped execution
This commit is contained in:
@ -22,28 +22,28 @@ fi
|
|||||||
echo "Interrogating user for configuration..."
|
echo "Interrogating user for configuration..."
|
||||||
|
|
||||||
# 1.1 Hostname
|
# 1.1 Hostname
|
||||||
HOSTNAME=$(whiptail --inputbox "Enter Hostname (e.g. mpvj)" 8 45 "mpvj" --title "Hostname Configuration" 3>&1 1>&2 2>&3) || exit 1
|
HOSTNAME=$(whiptail --inputbox "Enter Hostname (e.g. mpvj)" 8 45 "mpvj" --title "Hostname Configuration" 3>&1 1>&2 2>&3 < /dev/tty) || exit 1
|
||||||
HOSTNAME=${HOSTNAME:-mpvj}
|
HOSTNAME=${HOSTNAME:-mpvj}
|
||||||
|
|
||||||
# 1.2 SSID
|
# 1.2 SSID
|
||||||
WIFI_SSID=$(whiptail --inputbox "Enter WiFi SSID (e.g. MPVJ-AP)" 8 45 "MPVJ-AP" --title "WiFi SSID Configuration" 3>&1 1>&2 2>&3) || exit 1
|
WIFI_SSID=$(whiptail --inputbox "Enter WiFi SSID (e.g. MPVJ-AP)" 8 45 "MPVJ-AP" --title "WiFi SSID Configuration" 3>&1 1>&2 2>&3 < /dev/tty) || exit 1
|
||||||
WIFI_SSID=${WIFI_SSID:-MPVJ-AP}
|
WIFI_SSID=${WIFI_SSID:-MPVJ-AP}
|
||||||
|
|
||||||
# 1.3 Country Code & Password Validation
|
# 1.3 Country Code & Password Validation
|
||||||
while true; do
|
while true; do
|
||||||
WIFI_COUNTRY=$(whiptail --inputbox "Enter 2-letter Country Code (e.g. US, GB, DE)" 8 45 "US" --title "WiFi Country Configuration" 3>&1 1>&2 2>&3) || exit 1
|
WIFI_COUNTRY=$(whiptail --inputbox "Enter 2-letter Country Code (e.g. US, GB, DE)" 8 45 "US" --title "WiFi Country Configuration" 3>&1 1>&2 2>&3 < /dev/tty) || exit 1
|
||||||
WIFI_COUNTRY=$(echo "$WIFI_COUNTRY" | tr '[:lower:]' '[:upper:]')
|
WIFI_COUNTRY=$(echo "$WIFI_COUNTRY" | tr '[:lower:]' '[:upper:]')
|
||||||
if [[ ! "$WIFI_COUNTRY" =~ ^[A-Z]{2}$ ]]; then
|
if [[ ! "$WIFI_COUNTRY" =~ ^[A-Z]{2}$ ]]; then
|
||||||
whiptail --msgbox "Error: Country Code must be exactly 2 letters (e.g., US)." 8 45
|
whiptail --msgbox "Error: Country Code must be exactly 2 letters (e.g., US)." 8 45 < /dev/tty
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
WIFI_PASS=$(whiptail --passwordbox "Enter WiFi Password (minimum 8 characters)" 8 45 --title "WiFi Password Configuration" 3>&1 1>&2 2>&3) || exit 1
|
WIFI_PASS=$(whiptail --passwordbox "Enter WiFi Password (minimum 8 characters)" 8 45 --title "WiFi Password Configuration" 3>&1 1>&2 2>&3 < /dev/tty) || exit 1
|
||||||
if [ ${#WIFI_PASS} -lt 8 ]; then
|
if [ ${#WIFI_PASS} -lt 8 ]; then
|
||||||
whiptail --msgbox "Error: WiFi Password must be at least 8 characters long (WPA2 requirement)." 8 45
|
whiptail --msgbox "Error: WiFi Password must be at least 8 characters long (WPA2 requirement)." 8 45 < /dev/tty
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -56,7 +56,7 @@ echo "System Staging Phase..."
|
|||||||
FREE_SPACE_KB=$(df / --output=avail | tail -n1)
|
FREE_SPACE_KB=$(df / --output=avail | tail -n1)
|
||||||
MIN_SPACE_KB=4194304 # 4GB
|
MIN_SPACE_KB=4194304 # 4GB
|
||||||
if [ "$FREE_SPACE_KB" -lt "$MIN_SPACE_KB" ]; then
|
if [ "$FREE_SPACE_KB" -lt "$MIN_SPACE_KB" ]; then
|
||||||
whiptail --msgbox "Error: Not enough disk space. At least 4GB of free space is required for installation and swap scaling." 8 45
|
whiptail --msgbox "Error: Not enough disk space. At least 4GB of free space is required for installation and swap scaling." 8 45 < /dev/tty
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -276,6 +276,6 @@ SUMMARY+="Your SSH password remains unchanged.\n"
|
|||||||
SUMMARY+="Connect to '$WIFI_SSID' after reboot.\n\n"
|
SUMMARY+="Connect to '$WIFI_SSID' after reboot.\n\n"
|
||||||
SUMMARY+="Reboot now?"
|
SUMMARY+="Reboot now?"
|
||||||
|
|
||||||
if whiptail --title "Success" --yesno "$SUMMARY" 20 60; then
|
if whiptail --title "Success" --yesno "$SUMMARY" 20 60 < /dev/tty; then
|
||||||
reboot
|
reboot
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user