Improve unattended mode detection and export MODE
Enhanced the is_unattended() function to prioritize the MODE variable for detecting unattended/non-interactive mode, with detailed handling for various modes and legacy fallbacks. Also, export MODE in build_container() to inform install scripts about the current mode. Updated APP name in forgejo-runner.sh for consistency.
This commit is contained in:
parent
310d0e54a6
commit
a82d04982d
@ -6,7 +6,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
|
|||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
# Source: https://forgejo.org/
|
# Source: https://forgejo.org/
|
||||||
|
|
||||||
APP="Forgejo Runner"
|
APP="Forgejo-Runner"
|
||||||
var_tags="${var_tags:-ci}"
|
var_tags="${var_tags:-ci}"
|
||||||
var_cpu="${var_cpu:-2}"
|
var_cpu="${var_cpu:-2}"
|
||||||
var_ram="${var_ram:-2048}"
|
var_ram="${var_ram:-2048}"
|
||||||
|
|||||||
@ -3461,6 +3461,10 @@ build_container() {
|
|||||||
export DEV_MODE_LOGS="${DEV_MODE_LOGS:-false}"
|
export DEV_MODE_LOGS="${DEV_MODE_LOGS:-false}"
|
||||||
export DEV_MODE_DRYRUN="${DEV_MODE_DRYRUN:-false}"
|
export DEV_MODE_DRYRUN="${DEV_MODE_DRYRUN:-false}"
|
||||||
|
|
||||||
|
# MODE export for unattended detection in install scripts
|
||||||
|
# This tells install scripts whether to prompt for input or use defaults
|
||||||
|
export MODE="${METHOD:-default}"
|
||||||
|
|
||||||
# Build PCT_OPTIONS as multi-line string
|
# Build PCT_OPTIONS as multi-line string
|
||||||
PCT_OPTIONS_STRING=" -hostname $HN"
|
PCT_OPTIONS_STRING=" -hostname $HN"
|
||||||
|
|
||||||
|
|||||||
@ -813,15 +813,60 @@ is_verbose_mode() {
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# is_unattended()
|
# is_unattended()
|
||||||
#
|
#
|
||||||
# - Detects if script is running in unattended/silent mode
|
# - Detects if script is running in unattended/non-interactive mode
|
||||||
# - Checks PHS_SILENT, var_unattended, and UNATTENDED variables
|
# - Checks MODE variable first (primary method)
|
||||||
|
# - Falls back to legacy flags (PHS_SILENT, var_unattended)
|
||||||
# - Returns 0 (true) if unattended, 1 (false) otherwise
|
# - Returns 0 (true) if unattended, 1 (false) otherwise
|
||||||
# - Used by prompt functions to auto-apply defaults
|
# - Used by prompt functions to auto-apply defaults
|
||||||
|
#
|
||||||
|
# Modes that are unattended:
|
||||||
|
# - default (1) : Use script defaults, no prompts
|
||||||
|
# - mydefaults (3) : Use user's default.vars, no prompts
|
||||||
|
# - appdefaults (4) : Use app-specific defaults, no prompts
|
||||||
|
#
|
||||||
|
# Modes that are interactive:
|
||||||
|
# - advanced (2) : Full wizard with all options
|
||||||
|
#
|
||||||
|
# Note: Even in advanced mode, install scripts run unattended because
|
||||||
|
# all values are already collected during the wizard phase.
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
is_unattended() {
|
is_unattended() {
|
||||||
|
# Primary: Check MODE variable (case-insensitive)
|
||||||
|
local mode="${MODE:-${mode:-}}"
|
||||||
|
mode="${mode,,}" # lowercase
|
||||||
|
|
||||||
|
case "$mode" in
|
||||||
|
default|1)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
mydefaults|userdefaults|3)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
appdefaults|4)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
advanced|2)
|
||||||
|
# Advanced mode is interactive ONLY during wizard
|
||||||
|
# Inside container (install scripts), it should be unattended
|
||||||
|
# Check if we're inside a container (no pveversion command)
|
||||||
|
if ! command -v pveversion &>/dev/null; then
|
||||||
|
# We're inside the container - all values already collected
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
# On host during wizard - interactive
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Legacy fallbacks for compatibility
|
||||||
[[ "${PHS_SILENT:-0}" == "1" ]] && return 0
|
[[ "${PHS_SILENT:-0}" == "1" ]] && return 0
|
||||||
[[ "${var_unattended:-}" =~ ^(yes|true|1)$ ]] && return 0
|
[[ "${var_unattended:-}" =~ ^(yes|true|1)$ ]] && return 0
|
||||||
[[ "${UNATTENDED:-}" =~ ^(yes|true|1)$ ]] && return 0
|
[[ "${UNATTENDED:-}" =~ ^(yes|true|1)$ ]] && return 0
|
||||||
|
|
||||||
|
# No TTY available = unattended
|
||||||
|
[[ ! -t 0 ]] && return 0
|
||||||
|
|
||||||
|
# Default: interactive
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user