mirror of
https://github.com/tteck/Proxmox.git
synced 2024-11-22 08:13:11 +01:00
Update alpine-install.func
add spinner, attempt 2
This commit is contained in:
parent
e27191e607
commit
c73a2909f7
@ -34,6 +34,8 @@ catch_errors() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
error_handler() {
|
error_handler() {
|
||||||
|
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID; fi
|
||||||
|
printf "\033[?25h"
|
||||||
local exit_code="$?"
|
local exit_code="$?"
|
||||||
local line_number="$1"
|
local line_number="$1"
|
||||||
local command="$2"
|
local command="$2"
|
||||||
@ -41,17 +43,37 @@ error_handler() {
|
|||||||
echo -e "\n$error_message\n"
|
echo -e "\n$error_message\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
msg_info() {
|
# This function displays a spinner.
|
||||||
local msg="$1"
|
spinner() {
|
||||||
echo -ne " ${HOLD} ${YW}${msg}..."
|
printf "\033[?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.
|
||||||
|
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 "\033[?25h"
|
||||||
local msg="$1"
|
local msg="$1"
|
||||||
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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 "\033[?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
Block a user