mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-02-25 05:57:26 +00:00
dev
This commit is contained in:
205
misc/build.func
205
misc/build.func
@@ -15,50 +15,51 @@ variables() {
|
||||
}
|
||||
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func)
|
||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/core.func)
|
||||
|
||||
# This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
||||
color() {
|
||||
# Colors
|
||||
YW=$(echo "\033[33m")
|
||||
YWB=$(echo "\033[93m")
|
||||
BL=$(echo "\033[36m")
|
||||
RD=$(echo "\033[01;31m")
|
||||
BGN=$(echo "\033[4;92m")
|
||||
GN=$(echo "\033[1;92m")
|
||||
DGN=$(echo "\033[32m")
|
||||
# # This function sets various color variables using ANSI escape codes for formatting text in the terminal.
|
||||
# color() {
|
||||
# # Colors
|
||||
# YW=$(echo "\033[33m")
|
||||
# YWB=$(echo "\033[93m")
|
||||
# BL=$(echo "\033[36m")
|
||||
# RD=$(echo "\033[01;31m")
|
||||
# BGN=$(echo "\033[4;92m")
|
||||
# GN=$(echo "\033[1;92m")
|
||||
# DGN=$(echo "\033[32m")
|
||||
|
||||
# Formatting
|
||||
CL=$(echo "\033[m")
|
||||
BOLD=$(echo "\033[1m")
|
||||
HOLD=" "
|
||||
TAB=" "
|
||||
# # Formatting
|
||||
# CL=$(echo "\033[m")
|
||||
# BOLD=$(echo "\033[1m")
|
||||
# HOLD=" "
|
||||
# TAB=" "
|
||||
|
||||
# Icons
|
||||
CM="${TAB}✔️${TAB}"
|
||||
CROSS="${TAB}✖️${TAB}"
|
||||
INFO="${TAB}💡${TAB}${CL}"
|
||||
OS="${TAB}🖥️${TAB}${CL}"
|
||||
OSVERSION="${TAB}🌟${TAB}${CL}"
|
||||
CONTAINERTYPE="${TAB}📦${TAB}${CL}"
|
||||
DISKSIZE="${TAB}💾${TAB}${CL}"
|
||||
CPUCORE="${TAB}🧠${TAB}${CL}"
|
||||
RAMSIZE="${TAB}🛠️${TAB}${CL}"
|
||||
SEARCH="${TAB}🔍${TAB}${CL}"
|
||||
VERBOSE_CROPPED="🔍${TAB}"
|
||||
VERIFYPW="${TAB}🔐${TAB}${CL}"
|
||||
CONTAINERID="${TAB}🆔${TAB}${CL}"
|
||||
HOSTNAME="${TAB}🏠${TAB}${CL}"
|
||||
BRIDGE="${TAB}🌉${TAB}${CL}"
|
||||
NETWORK="${TAB}📡${TAB}${CL}"
|
||||
GATEWAY="${TAB}🌐${TAB}${CL}"
|
||||
DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
||||
DEFAULT="${TAB}⚙️${TAB}${CL}"
|
||||
MACADDRESS="${TAB}🔗${TAB}${CL}"
|
||||
VLANTAG="${TAB}🏷️${TAB}${CL}"
|
||||
ROOTSSH="${TAB}🔑${TAB}${CL}"
|
||||
CREATING="${TAB}🚀${TAB}${CL}"
|
||||
ADVANCED="${TAB}🧩${TAB}${CL}"
|
||||
}
|
||||
# # Icons
|
||||
# CM="${TAB}✔️${TAB}"
|
||||
# CROSS="${TAB}✖️${TAB}"
|
||||
# INFO="${TAB}💡${TAB}${CL}"
|
||||
# OS="${TAB}🖥️${TAB}${CL}"
|
||||
# OSVERSION="${TAB}🌟${TAB}${CL}"
|
||||
# CONTAINERTYPE="${TAB}📦${TAB}${CL}"
|
||||
# DISKSIZE="${TAB}💾${TAB}${CL}"
|
||||
# CPUCORE="${TAB}🧠${TAB}${CL}"
|
||||
# RAMSIZE="${TAB}🛠️${TAB}${CL}"
|
||||
# SEARCH="${TAB}🔍${TAB}${CL}"
|
||||
# VERBOSE_CROPPED="🔍${TAB}"
|
||||
# VERIFYPW="${TAB}🔐${TAB}${CL}"
|
||||
# CONTAINERID="${TAB}🆔${TAB}${CL}"
|
||||
# HOSTNAME="${TAB}🏠${TAB}${CL}"
|
||||
# BRIDGE="${TAB}🌉${TAB}${CL}"
|
||||
# NETWORK="${TAB}📡${TAB}${CL}"
|
||||
# GATEWAY="${TAB}🌐${TAB}${CL}"
|
||||
# DISABLEIPV6="${TAB}🚫${TAB}${CL}"
|
||||
# DEFAULT="${TAB}⚙️${TAB}${CL}"
|
||||
# MACADDRESS="${TAB}🔗${TAB}${CL}"
|
||||
# VLANTAG="${TAB}🏷️${TAB}${CL}"
|
||||
# ROOTSSH="${TAB}🔑${TAB}${CL}"
|
||||
# CREATING="${TAB}🚀${TAB}${CL}"
|
||||
# ADVANCED="${TAB}🧩${TAB}${CL}"
|
||||
# }
|
||||
|
||||
# This function enables error handling in the script by setting options and defining a trap for the ERR signal.
|
||||
catch_errors() {
|
||||
@@ -79,78 +80,78 @@ error_handler() {
|
||||
echo -e "\n$error_message\n"
|
||||
}
|
||||
|
||||
# This function displays an informational message with logging support.
|
||||
declare -A MSG_INFO_SHOWN
|
||||
SPINNER_ACTIVE=0
|
||||
SPINNER_PID=""
|
||||
SPINNER_MSG=""
|
||||
# # This function displays an informational message with logging support.
|
||||
# declare -A MSG_INFO_SHOWN
|
||||
# SPINNER_ACTIVE=0
|
||||
# SPINNER_PID=""
|
||||
# SPINNER_MSG=""
|
||||
|
||||
trap 'stop_spinner' EXIT INT TERM HUP
|
||||
# trap 'stop_spinner' EXIT INT TERM HUP
|
||||
|
||||
start_spinner() {
|
||||
local msg="$1"
|
||||
local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
|
||||
local spin_i=0
|
||||
local interval=0.1
|
||||
# start_spinner() {
|
||||
# local msg="$1"
|
||||
# local frames=(⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏)
|
||||
# local spin_i=0
|
||||
# local interval=0.1
|
||||
|
||||
SPINNER_MSG="$msg"
|
||||
printf "\r\e[2K" >&2
|
||||
# SPINNER_MSG="$msg"
|
||||
# printf "\r\e[2K" >&2
|
||||
|
||||
{
|
||||
while [[ "$SPINNER_ACTIVE" -eq 1 ]]; do
|
||||
printf "\r\e[2K%s %b" "${frames[spin_i]}" "${YW}${SPINNER_MSG}${CL}" >&2
|
||||
spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
||||
sleep "$interval"
|
||||
done
|
||||
} &
|
||||
# {
|
||||
# while [[ "$SPINNER_ACTIVE" -eq 1 ]]; do
|
||||
# printf "\r\e[2K%s %b" "${frames[spin_i]}" "${YW}${SPINNER_MSG}${CL}" >&2
|
||||
# spin_i=$(((spin_i + 1) % ${#frames[@]}))
|
||||
# sleep "$interval"
|
||||
# done
|
||||
# } &
|
||||
|
||||
SPINNER_PID=$!
|
||||
disown "$SPINNER_PID"
|
||||
}
|
||||
# SPINNER_PID=$!
|
||||
# disown "$SPINNER_PID"
|
||||
# }
|
||||
|
||||
stop_spinner() {
|
||||
if [[ ${SPINNER_PID+v} && -n "$SPINNER_PID" ]] && kill -0 "$SPINNER_PID" 2>/dev/null; then
|
||||
kill "$SPINNER_PID" 2>/dev/null
|
||||
sleep 0.1
|
||||
kill -0 "$SPINNER_PID" 2>/dev/null && kill -9 "$SPINNER_PID" 2>/dev/null
|
||||
wait "$SPINNER_PID" 2>/dev/null || true
|
||||
fi
|
||||
SPINNER_ACTIVE=0
|
||||
unset SPINNER_PID
|
||||
}
|
||||
# stop_spinner() {
|
||||
# if [[ ${SPINNER_PID+v} && -n "$SPINNER_PID" ]] && kill -0 "$SPINNER_PID" 2>/dev/null; then
|
||||
# kill "$SPINNER_PID" 2>/dev/null
|
||||
# sleep 0.1
|
||||
# kill -0 "$SPINNER_PID" 2>/dev/null && kill -9 "$SPINNER_PID" 2>/dev/null
|
||||
# wait "$SPINNER_PID" 2>/dev/null || true
|
||||
# fi
|
||||
# SPINNER_ACTIVE=0
|
||||
# unset SPINNER_PID
|
||||
# }
|
||||
|
||||
spinner_guard() {
|
||||
if [[ "$SPINNER_ACTIVE" -eq 1 ]] && [[ -n "$SPINNER_PID" ]]; then
|
||||
kill "$SPINNER_PID" 2>/dev/null
|
||||
wait "$SPINNER_PID" 2>/dev/null || true
|
||||
SPINNER_ACTIVE=0
|
||||
unset SPINNER_PID
|
||||
fi
|
||||
}
|
||||
# spinner_guard() {
|
||||
# if [[ "$SPINNER_ACTIVE" -eq 1 ]] && [[ -n "$SPINNER_PID" ]]; then
|
||||
# kill "$SPINNER_PID" 2>/dev/null
|
||||
# wait "$SPINNER_PID" 2>/dev/null || true
|
||||
# SPINNER_ACTIVE=0
|
||||
# unset SPINNER_PID
|
||||
# fi
|
||||
# }
|
||||
|
||||
msg_info() {
|
||||
local msg="$1"
|
||||
[[ -n "${MSG_INFO_SHOWN["$msg"]+x}" ]] && return
|
||||
MSG_INFO_SHOWN["$msg"]=1
|
||||
# msg_info() {
|
||||
# local msg="$1"
|
||||
# [[ -n "${MSG_INFO_SHOWN["$msg"]+x}" ]] && return
|
||||
# MSG_INFO_SHOWN["$msg"]=1
|
||||
|
||||
spinner_guard
|
||||
SPINNER_ACTIVE=1
|
||||
start_spinner "$msg"
|
||||
}
|
||||
# spinner_guard
|
||||
# SPINNER_ACTIVE=1
|
||||
# start_spinner "$msg"
|
||||
# }
|
||||
|
||||
msg_ok() {
|
||||
local msg="$1"
|
||||
stop_spinner
|
||||
printf "\r\e[2K%s %b\n" "${CM}" "${GN}${msg}${CL}" >&2
|
||||
unset MSG_INFO_SHOWN["$msg"]
|
||||
}
|
||||
# msg_ok() {
|
||||
# local msg="$1"
|
||||
# stop_spinner
|
||||
# printf "\r\e[2K%s %b\n" "${CM}" "${GN}${msg}${CL}" >&2
|
||||
# unset MSG_INFO_SHOWN["$msg"]
|
||||
# }
|
||||
|
||||
msg_error() {
|
||||
stop_spinner
|
||||
local msg="$1"
|
||||
printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2
|
||||
#log_message "ERROR" "$msg"
|
||||
}
|
||||
# msg_error() {
|
||||
# stop_spinner
|
||||
# local msg="$1"
|
||||
# printf "\r\e[2K%s %b\n" "${CROSS}" "${RD}${msg}${CL}" >&2
|
||||
# #log_message "ERROR" "$msg"
|
||||
# }
|
||||
|
||||
# log_message() {
|
||||
# local level="$1"
|
||||
|
||||
Reference in New Issue
Block a user