mirror of https://github.com/tteck/Proxmox.git
parent
8e10c14bce
commit
867a10f03f
|
@ -25,6 +25,8 @@ trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
||||||
|
|
||||||
# This function handles errors
|
# This function handles errors
|
||||||
function error_handler() {
|
function error_handler() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local exit_code="$?"
|
local exit_code="$?"
|
||||||
local line_number="$1"
|
local line_number="$1"
|
||||||
local command="$2"
|
local command="$2"
|
||||||
|
@ -32,20 +34,37 @@ function error_handler() {
|
||||||
echo -e "\n$error_message\n"
|
echo -e "\n$error_message\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function prints an informational message
|
# This function displays a spinner.
|
||||||
function msg_info() {
|
function spinner() {
|
||||||
local msg="$1"
|
printf "\e[?25l"
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
spinner="/-\\|/-\\|"
|
||||||
|
spin_i=0
|
||||||
|
while true; do
|
||||||
|
printf "\b%s" "${spinner:spin_i++%${#spinner}:1}"
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function prints a success message
|
# This function displays an informational message with a yellow color.
|
||||||
|
function msg_info() {
|
||||||
|
local msg="$1"
|
||||||
|
echo -ne " ${HOLD} ${YW}${msg} "
|
||||||
|
spinner &
|
||||||
|
SPINNER_PID=$!
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function displays a success message with a green color.
|
||||||
function msg_ok() {
|
function msg_ok() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function prints an error message
|
# This function displays a error message with a red color.
|
||||||
function msg_error() {
|
function msg_error() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ catch_errors() {
|
||||||
|
|
||||||
# This function is called when an error occurs. It receives the exit code, line number, and command that caused the error, and displays an error message.
|
# This function is called when an error occurs. It receives the exit code, line number, and command that caused the error, and displays an error message.
|
||||||
error_handler() {
|
error_handler() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local exit_code="$?"
|
local exit_code="$?"
|
||||||
local line_number="$1"
|
local line_number="$1"
|
||||||
local command="$2"
|
local command="$2"
|
||||||
|
@ -34,20 +36,38 @@ error_handler() {
|
||||||
echo -e "\n$error_message\n"
|
echo -e "\n$error_message\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function displays a spinner.
|
||||||
|
spinner() {
|
||||||
|
printf "\e[?25l"
|
||||||
|
spinner="/-\\|/-\\|"
|
||||||
|
spin_i=0
|
||||||
|
while true; do
|
||||||
|
printf "\b%s" "${spinner:spin_i++%${#spinner}:1}"
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# This function displays an informational message with a yellow color.
|
# This function displays an informational message with a yellow color.
|
||||||
msg_info() {
|
msg_info() {
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
echo -ne " ${HOLD} ${YW}${msg} "
|
||||||
|
spinner &
|
||||||
|
SPINNER_PID=$!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# This function displays a success message with a green color.
|
# This function displays a success message with a green color.
|
||||||
msg_ok() {
|
msg_ok() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function displays an error message with a red color.
|
# This function displays a error message with a red color.
|
||||||
msg_error() {
|
msg_error() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ catch_errors() {
|
||||||
|
|
||||||
# This function handles errors
|
# This function handles errors
|
||||||
error_handler() {
|
error_handler() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local exit_code="$?"
|
local exit_code="$?"
|
||||||
local line_number="$1"
|
local line_number="$1"
|
||||||
local command="$2"
|
local command="$2"
|
||||||
|
@ -46,20 +48,38 @@ error_handler() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function prints an informational message
|
# This function displays a spinner.
|
||||||
msg_info() {
|
spinner() {
|
||||||
local msg="$1"
|
printf "\e[?25l"
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
spinner="/-\\|/-\\|"
|
||||||
|
spin_i=0
|
||||||
|
while true; do
|
||||||
|
printf "\b%s" "${spinner:spin_i++%${#spinner}:1}"
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function prints a success message
|
# This function displays an informational message with a yellow color.
|
||||||
|
msg_info() {
|
||||||
|
local msg="$1"
|
||||||
|
echo -ne " ${HOLD} ${YW}${msg} "
|
||||||
|
spinner &
|
||||||
|
SPINNER_PID=$!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# This function displays a success message with a green color.
|
||||||
msg_ok() {
|
msg_ok() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function prints an error message
|
# This function displays a error message with a red color.
|
||||||
msg_error() {
|
msg_error() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\e[?25h"
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue