diff --git a/misc/build.func b/misc/build.func index 41bfb273..e6b49e4e 100644 --- a/misc/build.func +++ b/misc/build.func @@ -32,41 +32,41 @@ elif command -v wget >/dev/null 2>&1; then #echo "(build.func) Loaded core.func via wget" fi -set -Eeuo pipefail -trap 'error_handler $? $LINENO "$BASH_COMMAND"' ERR -trap on_exit EXIT -trap on_interrupt INT -trap on_terminate TERM +# set -Eeuo pipefail +# trap 'error_handler $? $LINENO "$BASH_COMMAND"' ERR +# trap on_exit EXIT +# trap on_interrupt INT +# trap on_terminate TERM -error_handler() { - local exit_code="$1" - local line_number="$2" - local command="${3:-}" +# error_handler() { +# local exit_code="$1" +# local line_number="$2" +# local command="${3:-}" - if [[ "$exit_code" -eq 0 ]]; then - return 0 - fi +# if [[ "$exit_code" -eq 0 ]]; then +# return 0 +# fi - printf "\e[?25h" - echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" - exit "$exit_code" -} +# printf "\e[?25h" +# echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" +# exit "$exit_code" +# } -on_exit() { - local exit_code="$?" - [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" - exit "$exit_code" -} +# on_exit() { +# local exit_code="$?" +# [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" +# exit "$exit_code" +# } -on_interrupt() { - echo -e "\n${RD}Interrupted by user (SIGINT)${CL}" - exit 130 -} +# on_interrupt() { +# echo -e "\n${RD}Interrupted by user (SIGINT)${CL}" +# exit 130 +# } -on_terminate() { - echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}" - exit 143 -} +# on_terminate() { +# echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}" +# exit 143 +# } # Check if the shell is using bash shell_check() { diff --git a/misc/core.func b/misc/core.func index 5df50efd..5937b3dd 100644 --- a/misc/core.func +++ b/misc/core.func @@ -96,10 +96,10 @@ _tool_error_hint() { # exit 143 # } -catch_errors() { - set -Eeuo pipefail - trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -} +# catch_errors() { +# set -Eeuo pipefail +# trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +# } # ------------------------------------------------------------------------------ # Sets ANSI color codes used for styled terminal output. @@ -190,8 +190,11 @@ set_std_mode() { } # Silent execution function +SILENT_LOGFILE="/tmp/silent.$$.log" + silent() { - "$@" >/dev/null 2>&1 + "$@" >>"$SILENT_LOGFILE" 2>&1 + return $? } # Function to download & save header files diff --git a/misc/create_lxc.sh b/misc/create_lxc.sh index 36e4fcb9..ace589d4 100644 --- a/misc/create_lxc.sh +++ b/misc/create_lxc.sh @@ -24,41 +24,41 @@ fi # ------------------------------------------------------------------------------ # Strict error handling # ------------------------------------------------------------------------------ -set -Eeuo pipefail -trap 'error_handler $? $LINENO "$BASH_COMMAND"' ERR -trap on_exit EXIT -trap on_interrupt INT -trap on_terminate TERM +# set -Eeuo pipefail +# trap 'error_handler $? $LINENO "$BASH_COMMAND"' ERR +# trap on_exit EXIT +# trap on_interrupt INT +# trap on_terminate TERM -error_handler() { - local exit_code="$1" - local line_number="$2" - local command="${3:-}" +# error_handler() { +# local exit_code="$1" +# local line_number="$2" +# local command="${3:-}" - if [[ "$exit_code" -eq 0 ]]; then - return 0 - fi +# if [[ "$exit_code" -eq 0 ]]; then +# return 0 +# fi - printf "\e[?25h" - echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" - exit "$exit_code" -} +# printf "\e[?25h" +# echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" +# exit "$exit_code" +# } -on_exit() { - local exit_code="$?" - [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" - exit "$exit_code" -} +# on_exit() { +# local exit_code="$?" +# [[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile" +# exit "$exit_code" +# } -on_interrupt() { - echo -e "\n${RD}Interrupted by user (SIGINT)${CL}" - exit 130 -} +# on_interrupt() { +# echo -e "\n${RD}Interrupted by user (SIGINT)${CL}" +# exit 130 +# } -on_terminate() { - echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}" - exit 143 -} +# on_terminate() { +# echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}" +# exit 143 +# } exit_script() { clear @@ -490,7 +490,6 @@ if ! pveam list "$TEMPLATE_STORAGE" 2>/dev/null | grep -q "$TEMPLATE"; then msg_error "Template $TEMPLATE not available in storage $TEMPLATE_STORAGE after download." exit 223 fi -msg_ok "Template $TEMPLATE is ready for container creation." # ------------------------------------------------------------------------------ # Dynamic preflight for Debian 13.x: offer upgrade if available (no hard mins) diff --git a/misc/install.func b/misc/install.func index 94e5c5a8..1248c273 100644 --- a/misc/install.func +++ b/misc/install.func @@ -25,27 +25,27 @@ verb_ip6() { fi } -# This function sets error handling options and defines the error_handler function to handle errors -catch_errors() { - set -Eeuo pipefail - trap 'error_handler $LINENO "$BASH_COMMAND"' ERR -} +# # This function sets error handling options and defines the error_handler function to handle errors +# catch_errors() { +# set -Eeuo pipefail +# trap 'error_handler $LINENO "$BASH_COMMAND"' ERR +# } -# This function handles errors -error_handler() { - source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) - local exit_code="$1" - local line_number="$2" - local command="${3:-}" +# # This function handles errors +# error_handler() { +# source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) +# local exit_code="$1" +# local line_number="$2" +# local command="${3:-}" - if [[ "$exit_code" -eq 0 ]]; then - return 0 - fi +# if [[ "$exit_code" -eq 0 ]]; then +# return 0 +# fi - printf "\e[?25h" - echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" - exit "$exit_code" -} +# printf "\e[?25h" +# echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" +# exit "$exit_code" +#} # This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection setting_up_container() {