diff --git a/misc/build.func b/misc/build.func index e64fb896c..5a8ea0292 100644 --- a/misc/build.func +++ b/misc/build.func @@ -4094,19 +4094,8 @@ EOF' # that sends "configuring" status AFTER the host already reported "failed" export CONTAINER_INSTALLING=true - # Capture lxc-attach terminal output to host-side log via tee. - # This is the ONLY reliable way to get install output when: - # - install.func fails to load (DNS error) → no container-side logging - # - install script crashes before logging starts - # - $STD/silent() not used for some commands - # PIPESTATUS[0] gets the real exit code from lxc-attach (not from tee). - # stdin comes from /dev/tty so install scripts can use interactive `read`. - local _LXC_CAPTURE_LOG="/tmp/.install-capture-${SESSION_ID}.log" - lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/${var_install}.sh)" &1 | tee "$_LXC_CAPTURE_LOG" - local lxc_exit=${PIPESTATUS[0]} - - # Restore terminal state after pipeline (tee/lxc-attach may leave it broken) - stty sane 2>/dev/null || true + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/${var_install}.sh)" + local lxc_exit=$? unset CONTAINER_INSTALLING @@ -4168,19 +4157,9 @@ EOF' build_log_copied=true fi - # Copy and append INSTALL_LOG from container (with timeout to prevent hangs) + # Copy and append INSTALL_LOG from container local temp_install_log="/tmp/.install-temp-${SESSION_ID}.log" - local container_log_ok=false - if timeout 8 pct pull "$CTID" "/root/.install-${SESSION_ID}.log" "$temp_install_log" 2>/dev/null; then - # Only use container log if it has meaningful content (>100 bytes) - if [[ -s "$temp_install_log" ]] && [[ $(stat -c%s "$temp_install_log" 2>/dev/null || echo 0) -gt 100 ]]; then - container_log_ok=true - fi - fi - - # PHASE 2: Use container-side log if available, otherwise use host-captured tee output - local _LXC_CAPTURE_LOG="/tmp/.install-capture-${SESSION_ID}.log" - if [[ "$container_log_ok" == true ]]; then + if pct pull "$CTID" "/root/.install-${SESSION_ID}.log" "$temp_install_log" 2>/dev/null; then { echo "================================================================================" echo "PHASE 2: APPLICATION INSTALLATION (Container)" @@ -4188,24 +4167,8 @@ EOF' cat "$temp_install_log" echo "" } >>"$combined_log" + rm -f "$temp_install_log" install_log_copied=true - elif [[ -s "$_LXC_CAPTURE_LOG" ]]; then - # Fallback: host-captured terminal output from lxc-attach - # This captures everything the user saw, including errors when install.func - # failed to load (DNS issues, etc.) and no container-side logging was set up. - { - echo "================================================================================" - echo "PHASE 2: APPLICATION INSTALLATION (Container - captured from terminal)" - echo "================================================================================" - # Strip ANSI escape codes from terminal capture - sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' "$_LXC_CAPTURE_LOG" | sed 's/\r$//' - echo "" - } >>"$combined_log" - install_log_copied=true - fi - rm -f "$temp_install_log" - - if [[ "$install_log_copied" == true ]]; then # Point INSTALL_LOG to combined log so get_full_log() finds it INSTALL_LOG="$combined_log" fi @@ -4391,16 +4354,8 @@ EOF' echo "" echo -en "${YW}Select option [1-${max_option}] (default: 1, auto-remove in 60s): ${CL}" - # Restore terminal state after lxc-attach|tee pipeline - stty sane 2>/dev/null || true - # Drain stale input from terminal buffer (lxc-attach|tee leaves residual data - # that causes read to return immediately with empty input) - dd iflag=nonblock if=/dev/tty of=/dev/null 2>/dev/null || true - sleep 0.3 - - # Read user choice local response="" - if read -t 60 -r response &1 | tee "$_LXC_CAPTURE_LOG" - local apt_retry_exit=${PIPESTATUS[0]} - stty sane 2>/dev/null || true + lxc-attach -n "$CTID" -- bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/install/${var_install}.sh)" + local apt_retry_exit=$? set -Eeuo pipefail trap 'error_handler' ERR @@ -4600,9 +4553,6 @@ EOF' exit $install_exit_code fi - # Clean up host-side capture log (not needed on success, already in combined_log on failure) - rm -f "/tmp/.install-capture-${SESSION_ID}.log" 2>/dev/null - # Re-enable error handling after successful install or recovery menu completion set -Eeuo pipefail trap 'error_handler' ERR diff --git a/misc/error_handler.func b/misc/error_handler.func index 183aa2be8..6223b6a29 100644 --- a/misc/error_handler.func +++ b/misc/error_handler.func @@ -286,12 +286,9 @@ error_handler() { echo -en "${YW}Remove broken container ${CTID}? (Y/n) [auto-remove in 60s]: ${CL}" fi - # Reset terminal state and flush stale input from buffer - stty sane 2>/dev/null || true - dd iflag=nonblock if=/dev/tty of=/dev/null 2>/dev/null || true - sleep 0.3 + # Read user response local response="" - if read -t 60 -r response /dev/null 2>&1; then