fix: prevent duplicate install questions and MTU prompt in CLI mode (#1422)

## Summary

Fixed a bug where installation questions were asked twice in interactive
mode, and a related bug where the MTU choice prompt appeared in
non-interactive CLI mode.

**Root cause:** `installQuestions()` was being called both by the caller
(`cmd_install()` or `cmd_interactive()`) and again inside
`installOpenVPN()`.

**Changes:**
- Removed the redundant `installQuestions()` call from
`installOpenVPN()`
- Added `installQuestions()` call to the non-interactive branch of
`cmd_install()` (needed for IP detection and setup)
- Added `MTU_CHOICE` default to the non-interactive branch (was
previously set inside `installOpenVPN()` before calling
`installQuestions()`)
This commit is contained in:
Stanislas
2025-12-15 12:42:59 +01:00
committed by GitHub
parent 63eff762dd
commit 0473a35b97

View File

@@ -781,6 +781,13 @@ cmd_install() {
# Multi-client # Multi-client
MULTI_CLIENT=${MULTI_CLIENT:-n} MULTI_CLIENT=${MULTI_CLIENT:-n}
# MTU
if [[ -n $MTU ]]; then
MTU_CHOICE=2
else
MTU_CHOICE=${MTU_CHOICE:-1}
fi
# Encryption - always set defaults for any missing values # Encryption - always set defaults for any missing values
CUSTOMIZE_ENC=${CUSTOMIZE_ENC:-n} CUSTOMIZE_ENC=${CUSTOMIZE_ENC:-n}
set_default_encryption set_default_encryption
@@ -806,6 +813,7 @@ cmd_install() {
SERVER_CERT_DURATION_DAYS=${SERVER_CERT_DURATION_DAYS:-$DEFAULT_CERT_VALIDITY_DURATION_DAYS} SERVER_CERT_DURATION_DAYS=${SERVER_CERT_DURATION_DAYS:-$DEFAULT_CERT_VALIDITY_DURATION_DAYS}
CONTINUE=y CONTINUE=y
installQuestions
installOpenVPN installOpenVPN
fi fi
} }
@@ -2136,9 +2144,6 @@ function installOpenVPN() {
log_info " SERVER_CERT_DURATION_DAYS=$SERVER_CERT_DURATION_DAYS" log_info " SERVER_CERT_DURATION_DAYS=$SERVER_CERT_DURATION_DAYS"
fi fi
# Run setup questions first, and set other variables if auto-install
installQuestions
# Get the "public" interface from the default route # Get the "public" interface from the default route
NIC=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1) NIC=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1)
if [[ -z $NIC ]] && [[ $IPV6_SUPPORT == 'y' ]]; then if [[ -z $NIC ]] && [[ $IPV6_SUPPORT == 'y' ]]; then