Update vm-core.func
This commit is contained in:
parent
b9cbfef0ca
commit
cc10993edb
@ -20,14 +20,15 @@ load_functions() {
|
|||||||
color
|
color
|
||||||
formatting
|
formatting
|
||||||
icons
|
icons
|
||||||
|
default_vars
|
||||||
set_std_mode
|
set_std_mode
|
||||||
|
shell_check
|
||||||
get_valid_nextid
|
get_valid_nextid
|
||||||
cleanup_vmid
|
cleanup_vmid
|
||||||
cleanup
|
cleanup
|
||||||
check_root
|
check_root
|
||||||
pve_check
|
pve_check
|
||||||
arch_check
|
arch_check
|
||||||
# add more
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to download & save header files
|
# Function to download & save header files
|
||||||
@ -85,6 +86,7 @@ formatting() {
|
|||||||
BOLD=$(echo "\033[1m")
|
BOLD=$(echo "\033[1m")
|
||||||
HOLD=" "
|
HOLD=" "
|
||||||
TAB=" "
|
TAB=" "
|
||||||
|
TAB3=" "
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -111,6 +113,7 @@ icons() {
|
|||||||
NETWORK="${TAB}📡${TAB}${CL}"
|
NETWORK="${TAB}📡${TAB}${CL}"
|
||||||
GATEWAY="${TAB}🌐${TAB}${CL}"
|
GATEWAY="${TAB}🌐${TAB}${CL}"
|
||||||
DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
||||||
|
ICON_DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
||||||
DEFAULT="${TAB}⚙️${TAB}${CL}"
|
DEFAULT="${TAB}⚙️${TAB}${CL}"
|
||||||
MACADDRESS="${TAB}🔗${TAB}${CL}"
|
MACADDRESS="${TAB}🔗${TAB}${CL}"
|
||||||
VLANTAG="${TAB}🏷️${TAB}${CL}"
|
VLANTAG="${TAB}🏷️${TAB}${CL}"
|
||||||
@ -133,6 +136,19 @@ set_std_mode() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# default_vars()
|
||||||
|
#
|
||||||
|
# - Sets default retry and wait variables used for system actions
|
||||||
|
# - RETRY_NUM: Maximum number of retry attempts (default: 10)
|
||||||
|
# - RETRY_EVERY: Seconds to wait between retries (default: 3)
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
default_vars() {
|
||||||
|
RETRY_NUM=10
|
||||||
|
RETRY_EVERY=3
|
||||||
|
i=$RETRY_NUM
|
||||||
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# get_active_logfile()
|
# get_active_logfile()
|
||||||
#
|
#
|
||||||
@ -309,6 +325,46 @@ __curl_err_handler() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# shell_check()
|
||||||
|
#
|
||||||
|
# - Verifies that the script is running under Bash shell
|
||||||
|
# - Exits with error message if different shell is detected
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
shell_check() {
|
||||||
|
if [[ "$(ps -p $$ -o comm=)" != "bash" ]]; then
|
||||||
|
clear
|
||||||
|
msg_error "Your default shell is currently not set to Bash. To use these scripts, please switch to the Bash shell."
|
||||||
|
echo -e "\nExiting..."
|
||||||
|
sleep 2
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# clear_line()
|
||||||
|
#
|
||||||
|
# - Clears current terminal line using tput or ANSI escape codes
|
||||||
|
# - Moves cursor to beginning of line (carriage return)
|
||||||
|
# - Fallback to ANSI codes if tput not available
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
clear_line() {
|
||||||
|
tput cr 2>/dev/null || echo -en "\r"
|
||||||
|
tput el 2>/dev/null || echo -en "\033[K"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# is_verbose_mode()
|
||||||
|
#
|
||||||
|
# - Determines if script should run in verbose mode
|
||||||
|
# - Checks VERBOSE and var_verbose variables
|
||||||
|
# - Also returns true if not running in TTY (pipe/redirect scenario)
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
is_verbose_mode() {
|
||||||
|
local verbose="${VERBOSE:-${var_verbose:-no}}"
|
||||||
|
[[ "$verbose" != "no" || ! -t 2 ]]
|
||||||
|
}
|
||||||
|
|
||||||
### dev spinner ###
|
### dev spinner ###
|
||||||
SPINNER_ACTIVE=0
|
SPINNER_ACTIVE=0
|
||||||
SPINNER_PID=""
|
SPINNER_PID=""
|
||||||
@ -431,6 +487,20 @@ msg_custom() {
|
|||||||
printf "\r\e[2K%s %b\n" "$symbol" "${color}${msg}${CL}" >&2
|
printf "\r\e[2K%s %b\n" "$symbol" "${color}${msg}${CL}" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# msg_debug()
|
||||||
|
#
|
||||||
|
# - Displays debug message with timestamp when var_full_verbose=1
|
||||||
|
# - Automatically enables var_verbose if not already set
|
||||||
|
# - Uses bright yellow color for debug output
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
msg_debug() {
|
||||||
|
if [[ "${var_full_verbose:-0}" == "1" ]]; then
|
||||||
|
[[ "${var_verbose:-0}" != "1" ]] && var_verbose=1
|
||||||
|
echo -e "${YWB}[$(date '+%F %T')] [DEBUG]${CL} $*"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Displays error message and immediately terminates script
|
# Displays error message and immediately terminates script
|
||||||
fatal() {
|
fatal() {
|
||||||
msg_error "$1"
|
msg_error "$1"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user