mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-28 05:10:40 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f6900c5c0c | |||
| 2e97eb8aae | |||
| f51b3ae221 | |||
| 2fcbc6b754 | |||
| b49b3f31d7 | |||
| 01bbacec22 | |||
| 116253df1a | |||
| 8706cd3783 | |||
| 874d8f300c |
@@ -449,6 +449,9 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
|
|||||||
|
|
||||||
### 💾 Core
|
### 💾 Core
|
||||||
|
|
||||||
|
- Revert "core: Add PHS_VERBOSE env var to skip verbose mode prompts" [@MickLesk](https://github.com/MickLesk) ([#13963](https://github.com/community-scripts/ProxmoxVE/pull/13963))
|
||||||
|
- Revert "core: hotfix - prefer silent mode on PHS env conflict" [@MickLesk](https://github.com/MickLesk) ([#13962](https://github.com/community-scripts/ProxmoxVE/pull/13962))
|
||||||
|
|
||||||
- #### 🐞 Bug Fixes
|
- #### 🐞 Bug Fixes
|
||||||
|
|
||||||
- core: hotfix - prefer silent mode on PHS env conflict [@MickLesk](https://github.com/MickLesk) ([#13951](https://github.com/community-scripts/ProxmoxVE/pull/13951))
|
- core: hotfix - prefer silent mode on PHS env conflict [@MickLesk](https://github.com/MickLesk) ([#13951](https://github.com/community-scripts/ProxmoxVE/pull/13951))
|
||||||
|
|||||||
+111
-70
@@ -2702,10 +2702,6 @@ advanced_settings() {
|
|||||||
# STEP 28: Verbose Mode & Confirmation
|
# STEP 28: Verbose Mode & Confirmation
|
||||||
# ═══════════════════════════════════════════════════════════════════════════
|
# ═══════════════════════════════════════════════════════════════════════════
|
||||||
28)
|
28)
|
||||||
# PHS_VERBOSE forces verbose mode and skips the prompt
|
|
||||||
if [[ "$PHS_MODE" == "verbose" ]]; then
|
|
||||||
_verbose="yes"
|
|
||||||
else
|
|
||||||
local verbose_default_flag="--defaultno"
|
local verbose_default_flag="--defaultno"
|
||||||
[[ "$_verbose" == "yes" ]] && verbose_default_flag=""
|
[[ "$_verbose" == "yes" ]] && verbose_default_flag=""
|
||||||
|
|
||||||
@@ -2717,7 +2713,6 @@ advanced_settings() {
|
|||||||
else
|
else
|
||||||
_verbose="no"
|
_verbose="no"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
# Build summary
|
# Build summary
|
||||||
local ct_type_desc="Unprivileged"
|
local ct_type_desc="Unprivileged"
|
||||||
[[ "$_ct_type" == "0" ]] && ct_type_desc="Privileged"
|
[[ "$_ct_type" == "0" ]] && ct_type_desc="Privileged"
|
||||||
@@ -3449,7 +3444,7 @@ configure_ssh_settings() {
|
|||||||
# msg_menu()
|
# msg_menu()
|
||||||
#
|
#
|
||||||
# - Displays a numbered menu for update_script() functions
|
# - Displays a numbered menu for update_script() functions
|
||||||
# - In silent mode (PHS_MODE=silent): auto-selects the default option
|
# - In silent mode (PHS_SILENT=1): auto-selects the default option
|
||||||
# - In interactive mode: shows menu via read with 10s timeout + default fallback
|
# - In interactive mode: shows menu via read with 10s timeout + default fallback
|
||||||
# - Usage: CHOICE=$(msg_menu "Title" "tag1" "Description 1" "tag2" "Desc 2" ...)
|
# - Usage: CHOICE=$(msg_menu "Title" "tag1" "Description 1" "tag2" "Desc 2" ...)
|
||||||
# - The first item is always the default
|
# - The first item is always the default
|
||||||
@@ -3473,7 +3468,7 @@ msg_menu() {
|
|||||||
local count=${#tags[@]}
|
local count=${#tags[@]}
|
||||||
|
|
||||||
# Silent mode: return default immediately
|
# Silent mode: return default immediately
|
||||||
if [[ "$PHS_MODE" == "silent" ]]; then
|
if [[ -n "${PHS_SILENT+x}" ]] && [[ "${PHS_SILENT}" == "1" ]]; then
|
||||||
echo "$default_tag"
|
echo "$default_tag"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@@ -3509,34 +3504,6 @@ msg_menu() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# resolve_phs_mode()
|
|
||||||
#
|
|
||||||
# - Resolves PHS_SILENT/PHS_VERBOSE env vars into a single PHS_MODE enum
|
|
||||||
# - Values: "silent", "verbose", "interactive"
|
|
||||||
# - If both PHS_SILENT=1 and PHS_VERBOSE=1, shows a conflict warning
|
|
||||||
# and defaults to "interactive"
|
|
||||||
# - Should be called once early, before any mode-dependent logic
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
resolve_phs_mode() {
|
|
||||||
if [[ -n "${PHS_SILENT+x}" ]] && [[ "${PHS_SILENT}" == "1" ]] && [[ -n "${PHS_VERBOSE+x}" ]] && [[ "${PHS_VERBOSE}" == "1" ]]; then
|
|
||||||
# Conflict handling must never block unattended/non-TTY updates.
|
|
||||||
# Prefer silent mode to keep automation safe.
|
|
||||||
if [[ -t 0 ]] && [[ -t 1 ]] && command -v whiptail >/dev/null 2>&1; then
|
|
||||||
whiptail --backtitle "Proxmox VE Helper Scripts" \
|
|
||||||
--title "Configuration Conflict Warning" \
|
|
||||||
--msgbox "PHS_SILENT and PHS_VERBOSE are both set.\n\nFalling back to silent mode." 10 58 || true
|
|
||||||
fi
|
|
||||||
PHS_MODE="silent"
|
|
||||||
elif [[ -n "${PHS_SILENT+x}" ]] && [[ "${PHS_SILENT}" == "1" ]]; then
|
|
||||||
PHS_MODE="silent"
|
|
||||||
elif [[ -n "${PHS_VERBOSE+x}" ]] && [[ "${PHS_VERBOSE}" == "1" ]]; then
|
|
||||||
PHS_MODE="verbose"
|
|
||||||
else
|
|
||||||
PHS_MODE="interactive"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# start()
|
# start()
|
||||||
#
|
#
|
||||||
@@ -3547,16 +3514,17 @@ resolve_phs_mode() {
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
start() {
|
start() {
|
||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func)
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func)
|
||||||
resolve_phs_mode
|
|
||||||
if command -v pveversion >/dev/null 2>&1; then
|
if command -v pveversion >/dev/null 2>&1; then
|
||||||
install_script || return 0
|
install_script || return 0
|
||||||
return 0
|
return 0
|
||||||
elif [[ "$PHS_MODE" == "silent" ]]; then
|
elif [ ! -z ${PHS_SILENT+x} ] && [[ "${PHS_SILENT}" == "1" ]]; then
|
||||||
VERBOSE="no"
|
VERBOSE="no"
|
||||||
set_std_mode
|
set_std_mode
|
||||||
elif [[ "$PHS_MODE" == "verbose" ]]; then
|
ensure_profile_loaded
|
||||||
VERBOSE="yes"
|
get_lxc_ip
|
||||||
set_std_mode
|
update_script
|
||||||
|
update_motd_ip
|
||||||
|
cleanup_lxc
|
||||||
else
|
else
|
||||||
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "${APP} LXC Update/Setting" --menu \
|
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "${APP} LXC Update/Setting" --menu \
|
||||||
"Support/Update functions for ${APP} LXC. Choose an option:" \
|
"Support/Update functions for ${APP} LXC. Choose an option:" \
|
||||||
@@ -3580,12 +3548,12 @@ start() {
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
|
||||||
ensure_profile_loaded
|
ensure_profile_loaded
|
||||||
get_lxc_ip
|
get_lxc_ip
|
||||||
update_script
|
update_script
|
||||||
update_motd_ip
|
update_motd_ip
|
||||||
cleanup_lxc
|
cleanup_lxc
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -5408,13 +5376,59 @@ create_lxc_container() {
|
|||||||
|
|
||||||
# Offer upgrade for pve-container/lxc-pve if candidate > installed; optional auto-retry pct create
|
# Offer upgrade for pve-container/lxc-pve if candidate > installed; optional auto-retry pct create
|
||||||
# Returns:
|
# Returns:
|
||||||
# 0 = no upgrade needed / container created after upgrade or fallback
|
# 0 = no upgrade needed / container created after upgrade or explicit fallback
|
||||||
# 1 = upgraded (and if do_retry=yes and retry succeeded, creation done)
|
# 1 = upgraded (and if do_retry=yes and retry succeeded, creation done)
|
||||||
# 2 = user declined
|
# 2 = user chose ignore
|
||||||
# 3 = upgrade attempted but failed OR retry failed
|
# 3 = upgrade attempted but failed OR retry failed
|
||||||
|
# 4 = user cancelled
|
||||||
offer_lxc_stack_upgrade_and_maybe_retry() {
|
offer_lxc_stack_upgrade_and_maybe_retry() {
|
||||||
local do_retry="${1:-no}" # yes|no
|
local do_retry="${1:-no}" # yes|no
|
||||||
local _pvec_i _pvec_c _lxcp_i _lxcp_c need=0
|
local _pvec_i _pvec_c _lxcp_i _lxcp_c need=0
|
||||||
|
local _ans
|
||||||
|
|
||||||
|
has_previous_os_version_template() {
|
||||||
|
local os_type="${PCT_OSTYPE:-}"
|
||||||
|
local current_ver="${PCT_OSVERSION:-}"
|
||||||
|
local tpl_pattern="${TEMPLATE_PATTERN:-${TEMPLATE:-}}"
|
||||||
|
local -a all_versions=()
|
||||||
|
|
||||||
|
[[ -n "$os_type" && -n "$current_ver" ]] || return 1
|
||||||
|
|
||||||
|
mapfile -t _local_vers < <(
|
||||||
|
pveam list "$TEMPLATE_STORAGE" 2>/dev/null |
|
||||||
|
awk '{print $1}' |
|
||||||
|
sed 's|.*/||' |
|
||||||
|
grep -E "^${os_type}-[0-9]" |
|
||||||
|
{ [[ -n "$tpl_pattern" ]] && grep "$tpl_pattern" || cat; } |
|
||||||
|
sed -E "s/^${os_type}-([0-9]+(\.[0-9]+)?).*/\1/" |
|
||||||
|
sort -u -V
|
||||||
|
)
|
||||||
|
all_versions+=("${_local_vers[@]}")
|
||||||
|
|
||||||
|
if command -v timeout &>/dev/null; then
|
||||||
|
timeout 30 pveam update >/dev/null 2>&1 || true
|
||||||
|
else
|
||||||
|
pveam update >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
mapfile -t _online_vers < <(
|
||||||
|
pveam available -section system 2>/dev/null |
|
||||||
|
awk '{print $2}' |
|
||||||
|
grep -E "^${os_type}-[0-9]" |
|
||||||
|
{ [[ -n "$tpl_pattern" ]] && grep "$tpl_pattern" || cat; } |
|
||||||
|
sed -E "s/^${os_type}-([0-9]+(\.[0-9]+)?).*/\1/" |
|
||||||
|
sort -u -V 2>/dev/null || true
|
||||||
|
)
|
||||||
|
all_versions+=("${_online_vers[@]}")
|
||||||
|
|
||||||
|
printf '%s\n' "${all_versions[@]}" | sort -u -V | awk -v cur="$current_ver" '
|
||||||
|
{
|
||||||
|
split($0, a, ".")
|
||||||
|
split(cur, b, ".")
|
||||||
|
if (a[1]+0 < b[1]+0) found=1
|
||||||
|
}
|
||||||
|
END { exit found ? 0 : 1 }
|
||||||
|
'
|
||||||
|
}
|
||||||
|
|
||||||
_pvec_i="$(pkg_ver pve-container)"
|
_pvec_i="$(pkg_ver pve-container)"
|
||||||
_lxcp_i="$(pkg_ver lxc-pve)"
|
_lxcp_i="$(pkg_ver lxc-pve)"
|
||||||
@@ -5435,19 +5449,25 @@ create_lxc_container() {
|
|||||||
msg_warn "An update for the Proxmox LXC stack is available"
|
msg_warn "An update for the Proxmox LXC stack is available"
|
||||||
echo " pve-container: installed=${_pvec_i:-n/a} candidate=${_pvec_c:-n/a}"
|
echo " pve-container: installed=${_pvec_i:-n/a} candidate=${_pvec_c:-n/a}"
|
||||||
echo " lxc-pve : installed=${_lxcp_i:-n/a} candidate=${_lxcp_c:-n/a}"
|
echo " lxc-pve : installed=${_lxcp_i:-n/a} candidate=${_lxcp_c:-n/a}"
|
||||||
|
echo " note : option 1 runs host apt update + apt upgrade"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# Offer older OS version fallback when template version might be too new for LXC stack
|
# Offer older OS version fallback when template version might be too new for LXC stack
|
||||||
local _has_fallback_option=false
|
local _has_fallback_option=false
|
||||||
if [[ -n "${PCT_OSTYPE:-}" && -n "${PCT_OSVERSION:-}" ]]; then
|
if [[ "$do_retry" == "yes" ]] && has_previous_os_version_template; then
|
||||||
_has_fallback_option=true
|
_has_fallback_option=true
|
||||||
echo " [1] Upgrade LXC stack now (recommended)"
|
echo " [1] Run host upgrade now (recommended). WARNING: this runs apt upgrade and updates all Packeages on your host!"
|
||||||
echo " [2] Use an older ${PCT_OSTYPE} template instead (may not work with all scripts)"
|
echo " [2] Use an older ${PCT_OSTYPE} template instead (may not work with all scripts)"
|
||||||
|
echo " [3] Ignore"
|
||||||
|
echo " [4] Cancel"
|
||||||
|
echo
|
||||||
|
read -rp "Select option [1/2/3/4]: " _ans </dev/tty
|
||||||
|
else
|
||||||
|
echo " [1] Run host upgrade now (recommended). WARNING: this runs apt upgrade and updates all Packeages on your host!"
|
||||||
|
echo " [2] Ignore"
|
||||||
echo " [3] Cancel"
|
echo " [3] Cancel"
|
||||||
echo
|
echo
|
||||||
read -rp "Select option [1/2/3]: " _ans </dev/tty
|
read -rp "Select option [1/2/3]: " _ans </dev/tty
|
||||||
else
|
|
||||||
read -rp "Do you want to upgrade now? [y/N] " _ans </dev/tty
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$_has_fallback_option" == true ]]; then
|
if [[ "$_has_fallback_option" == true ]]; then
|
||||||
@@ -5456,35 +5476,48 @@ create_lxc_container() {
|
|||||||
_ans="y"
|
_ans="y"
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
if [[ "$do_retry" == "yes" ]]; then
|
|
||||||
if fallback_to_previous_os_version; then
|
if fallback_to_previous_os_version; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
else
|
;;
|
||||||
msg_custom "ℹ️" "${YW}" "OS version fallback is only available during container creation."
|
3)
|
||||||
return 2
|
return 2
|
||||||
fi
|
;;
|
||||||
|
4)
|
||||||
|
return 4
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
return 4
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
case "$_ans" in
|
||||||
|
1)
|
||||||
|
_ans="y"
|
||||||
|
;;
|
||||||
|
2)
|
||||||
return 2
|
return 2
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
return 4
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "${_ans,,}" in
|
case "${_ans,,}" in
|
||||||
y | yes)
|
y | yes)
|
||||||
msg_info "Upgrading Proxmox LXC stack (pve-container, lxc-pve)"
|
msg_info "Running host upgrade for LXC stack compatibility"
|
||||||
apt_update_safe
|
apt_update_safe
|
||||||
if $STD apt-get install -y --only-upgrade pve-container lxc-pve; then
|
if $STD apt-get upgrade -y; then
|
||||||
msg_ok "LXC stack upgraded."
|
msg_ok "LXC stack upgraded."
|
||||||
# Verify pct binary still works after upgrade (partial upgrades can break Perl modules)
|
# Verify pct binary still works after upgrade (partial upgrades can break Perl modules)
|
||||||
if ! pct list &>/dev/null; then
|
if ! pct list &>/dev/null; then
|
||||||
msg_error "LXC stack upgrade caused PVE tool breakage (likely Perl module incompatibility)."
|
msg_error "LXC stack upgrade caused PVE tool breakage (likely Perl module incompatibility)."
|
||||||
msg_custom "⚠️" "${YW}" "A partial package upgrade has left the PVE stack in an inconsistent state."
|
msg_custom "⚠️" "${YW}" "A partial package upgrade has left the PVE stack in an inconsistent state."
|
||||||
msg_custom "🔧" "${YW}" "Please run the following on the Proxmox host, then retry:"
|
msg_custom "🔧" "${YW}" "Please run the following on the Proxmox host, then retry:"
|
||||||
echo -e "${TAB} apt update && apt dist-upgrade -y"
|
echo -e "${TAB} apt update && apt upgrade -y"
|
||||||
echo -e "${TAB} reboot"
|
echo -e "${TAB} reboot"
|
||||||
return 3
|
return 3
|
||||||
fi
|
fi
|
||||||
@@ -6093,16 +6126,20 @@ create_lxc_container() {
|
|||||||
rc=$?
|
rc=$?
|
||||||
case $rc in
|
case $rc in
|
||||||
0) : ;; # success - container created, continue
|
0) : ;; # success - container created, continue
|
||||||
2 | 3)
|
2)
|
||||||
# Upgrade declined or failed — try older OS version as last resort
|
msg_error "LXC stack upgrade ignored. Please inspect: $LOGFILE"
|
||||||
msg_warn "Attempting older ${PCT_OSTYPE:-} version as last resort"
|
_flush_pct_log
|
||||||
if fallback_to_previous_os_version; then
|
exit 231
|
||||||
: # success
|
;;
|
||||||
else
|
3)
|
||||||
msg_error "All recovery options exhausted. Please inspect: $LOGFILE"
|
msg_error "LXC stack upgrade failed. Please inspect: $LOGFILE"
|
||||||
|
_flush_pct_log
|
||||||
|
exit 231
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
msg_error "Cancelled by user."
|
||||||
_flush_pct_log
|
_flush_pct_log
|
||||||
exit 231
|
exit 231
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
@@ -6126,16 +6163,20 @@ create_lxc_container() {
|
|||||||
rc=$?
|
rc=$?
|
||||||
case $rc in
|
case $rc in
|
||||||
0) : ;; # success - container created, continue
|
0) : ;; # success - container created, continue
|
||||||
2 | 3)
|
2)
|
||||||
# Upgrade declined or failed — try older OS version as last resort
|
msg_error "LXC stack upgrade ignored. Please inspect: $LOGFILE"
|
||||||
msg_warn "Attempting older ${PCT_OSTYPE:-} version as last resort"
|
_flush_pct_log
|
||||||
if fallback_to_previous_os_version; then
|
exit 231
|
||||||
: # success
|
;;
|
||||||
else
|
3)
|
||||||
msg_error "All recovery options exhausted. Please inspect: $LOGFILE"
|
msg_error "LXC stack upgrade failed. Please inspect: $LOGFILE"
|
||||||
|
_flush_pct_log
|
||||||
|
exit 231
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
msg_error "Cancelled by user."
|
||||||
_flush_pct_log
|
_flush_pct_log
|
||||||
exit 231
|
exit 231
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
|
|||||||
+2
-2
@@ -940,7 +940,7 @@ is_verbose_mode() {
|
|||||||
#
|
#
|
||||||
# - Detects if script is running in unattended/non-interactive mode
|
# - Detects if script is running in unattended/non-interactive mode
|
||||||
# - Checks MODE variable first (primary method)
|
# - Checks MODE variable first (primary method)
|
||||||
# - Falls back to legacy flags (PHS_MODE, var_unattended)
|
# - 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
|
||||||
#
|
#
|
||||||
@@ -984,7 +984,7 @@ is_unattended() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Legacy fallbacks for compatibility
|
# Legacy fallbacks for compatibility
|
||||||
[[ "${PHS_MODE:-}" == "silent" ]] && 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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user