1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-02-01 21:31:52 +00:00

fix spinner on lxc-ip-tag (#876)

* fix spinner on lxc-ip-tag

* fix indention
This commit is contained in:
CanbiZ 2024-12-17 15:30:51 +01:00 committed by GitHub
parent b18b49ef6f
commit c60b16229b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,15 +50,17 @@ error_handler() {
echo -e "\n$error_message\n" echo -e "\n$error_message\n"
} }
# This function displays a spinner.
spinner() { spinner() {
local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏') local frames=('⠋' '⠙' '⠹' '⠸' '⠼' '⠴' '⠦' '⠧' '⠇' '⠏')
local spin_i=0 local spin_i=0
local interval=0.1 local interval=0.1
printf "\e[?25l" printf "\e[?25l"
local orange="\e[38;5;214m"
local color="${YWB}"
while true; do while true; do
printf "\r ${orange}%s\e[0m " "${frames[spin_i]}" printf "\r ${color}%s${CL}" "${frames[spin_i]}"
spin_i=$(((spin_i + 1) % ${#frames[@]})) spin_i=$(((spin_i + 1) % ${#frames[@]}))
sleep "$interval" sleep "$interval"
done done
@ -67,7 +69,7 @@ spinner() {
# 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 "${TAB}${YW}${HOLD}${msg}${HOLD}"
spinner & spinner &
SPINNER_PID=$! SPINNER_PID=$!
} }
@ -92,8 +94,11 @@ while true; do
read -p "This will install ${APP} on ${hostname}. Proceed? (y/n): " yn read -p "This will install ${APP} on ${hostname}. Proceed? (y/n): " yn
case $yn in case $yn in
[Yy]*) break ;; [Yy]*) break ;;
[Nn]*) msg_info "Installation cancelled."; exit ;; [Nn]*)
*) msg_info "Please answer yes or no." ;; msg_error "Installation cancelled."
exit
;;
*) msg_error "Please answer yes or no." ;;
esac esac
done done
@ -118,6 +123,7 @@ msg_ok "Installed Dependencies"
msg_info "Setting up IP-Tag Scripts" msg_info "Setting up IP-Tag Scripts"
mkdir -p /opt/lxc-iptag mkdir -p /opt/lxc-iptag
msg_ok "Setup IP-Tag Scripts"
msg_info "Setup Default Config" msg_info "Setup Default Config"
if [[ ! -f /opt/lxc-iptag/iptag.conf ]]; then if [[ ! -f /opt/lxc-iptag/iptag.conf ]]; then
@ -322,7 +328,6 @@ chmod +x /opt/lxc-iptag/iptag
msg_info "Creating Service" msg_info "Creating Service"
if [[ ! -f /lib/systemd/system/iptag.service ]]; then if [[ ! -f /lib/systemd/system/iptag.service ]]; then
echo "Systemd service file not found. Creating it now..."
cat <<EOF >/lib/systemd/system/iptag.service cat <<EOF >/lib/systemd/system/iptag.service
[Unit] [Unit]
Description=LXC IP-Tag service Description=LXC IP-Tag service
@ -347,5 +352,5 @@ msg_info "Starting Service"
systemctl daemon-reload &>/dev/null systemctl daemon-reload &>/dev/null
systemctl enable -q --now iptag.service &>/dev/null systemctl enable -q --now iptag.service &>/dev/null
msg_ok "Started Service" msg_ok "Started Service"
SPINNER_PID=""
echo -e "\n${APP} installation completed successfully! ${CL}\n" echo -e "\n${APP} installation completed successfully! ${CL}\n"