From 3bd3fb5836b1ae2a1bd22e305213dacd7388aae8 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Fri, 11 Apr 2025 08:58:04 +0200 Subject: [PATCH] Factor out all duplicate code from install.func --- misc/install.func | 89 ----------------------------------------------- 1 file changed, 89 deletions(-) diff --git a/misc/install.func b/misc/install.func index 65e52c6..e0586ab 100644 --- a/misc/install.func +++ b/misc/install.func @@ -4,48 +4,6 @@ # License: MIT # https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE -# This function sets color variables for formatting output in the terminal -color() { - # Colors - YW=$(echo "\033[33m") - YWB=$(echo "\033[93m") - BL=$(echo "\033[36m") - RD=$(echo "\033[01;31m") - GN=$(echo "\033[1;92m") - - # Formatting - CL=$(echo "\033[m") - BFR="\\r\\033[K" - BOLD=$(echo "\033[1m") - HOLD=" " - TAB=" " - - # System - RETRY_NUM=10 - RETRY_EVERY=3 - - # Icons - CM="${TAB}✔️${TAB}${CL}" - CROSS="${TAB}✖️${TAB}${CL}" - INFO="${TAB}💡${TAB}${CL}" - NETWORK="${TAB}📡${TAB}${CL}" - HOSTNAME="${TAB}🏠${TAB}${CL}" -} - -# Function to set STD mode based on verbosity -set_std_mode() { - if [ "$VERBOSE" = "yes" ]; then - STD="" - else - STD="silent" - fi -} - -# Silent execution function -silent() { - "$@" >/dev/null 2>&1 -} - # This function enables IPv6 if it's not disabled and sets verbose mode verb_ip6() { set_std_mode # Set STD mode based on VERBOSE @@ -80,46 +38,6 @@ error_handler() { fi } -# This function displays a spinner. -spinner() { - local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏') - local spin_i=0 - local interval=0.1 - printf "\e[?25l" - - local color="${YWB}" - - while true; do - printf "\r ${color}%s${CL}" "${frames[spin_i]}" - spin_i=$(((spin_i + 1) % ${#frames[@]})) - sleep "$interval" - done -} - -# This function displays an informational message with a yellow color. -msg_info() { - local msg="$1" - echo -ne "${TAB}${YW}${HOLD}${msg}${HOLD}" - spinner & - SPINNER_PID=$! -} - -# This function displays a success message with a green color. -msg_ok() { - if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi - printf "\e[?25h" - local msg="$1" - echo -e "${BFR}${CM}${GN}${msg}${CL}" -} - -# This function displays a error message with a red color. -msg_error() { - if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi - printf "\e[?25h" - local msg="$1" - echo -e "${BFR}${CROSS}${RD}${msg}${CL}" -} - # This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection setting_up_container() { msg_info "Setting up Container OS" @@ -148,12 +66,6 @@ setting_up_container() { msg_ok "Network Connected: ${BL}$(hostname -I)" } -exit_script() { - clear - echo -e "\n${CROSS}${RD}Script aborted.${CL}\n" - exit -} - # This function checks the network connection by pinging a known IP address and prompts the user to continue if the internet is not connected network_check() { set +e @@ -275,4 +187,3 @@ EOF fi source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/helper.func) } -