ensures interactive input for terminal prompts in setup.sh

This commit is contained in:
Menno van Leeuwen 2024-11-08 14:17:14 +01:00
parent 792af5e4c6
commit dfc68c275a
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE

View File

@ -33,6 +33,14 @@ die() {
exit 1 exit 1
} }
# Ensure we're running interactively
ensure_interactive() {
# If stdin is not a terminal, reconnect stdin to /dev/tty
if [ ! -t 0 ]; then
exec < /dev/tty || die "Failed to connect to terminal. Please run the script directly instead of piping from curl"
fi
}
confirm_symlink() { confirm_symlink() {
local link="$1" local link="$1"
local msg="$2" local msg="$2"
@ -88,6 +96,9 @@ EOF
log_success "Hardware configuration created successfully." log_success "Hardware configuration created successfully."
log_info "Consider adding additional hardware configuration to $config_file" log_info "Consider adding additional hardware configuration to $config_file"
# Ensure interactive input before system type selection
ensure_interactive
# System type selection # System type selection
local systemType local systemType
while true; do while true; do
@ -256,6 +267,9 @@ prepare_hostname() {
return return
fi fi
# Ensure interactive input before hostname prompt
ensure_interactive
while true; do while true; do
log_info "Enter the hostname for this machine:" log_info "Enter the hostname for this machine:"
read -r hostname read -r hostname