fix: enhance gitapply.sh with animated effects and improved cache clearing

This commit is contained in:
2025-12-23 20:24:27 -05:00
parent e805d38961
commit 6491e0e904

View File

@@ -11,6 +11,7 @@ DTEAL='\033[38;5;30m'
YELLOW='\033[1;33m' YELLOW='\033[1;33m'
RED='\033[0;31m' RED='\033[0;31m'
BOLD='\033[1m' BOLD='\033[1m'
DIM='\033[2m'
NC='\033[0m' # No Color NC='\033[0m' # No Color
# Symbols # Symbols
@@ -19,65 +20,199 @@ CROSS="✖"
ARROW="➜" ARROW="➜"
GEAR="⚙" GEAR="⚙"
ROCKET="🚀" ROCKET="🚀"
SPARKLE="✨"
# Animation frames
SPINNER_FRAMES=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏")
PROGRESS_CHARS=("░" "▒" "▓" "█")
# Typewriter effect function
typewriter() {
local text="$1"
local delay="${2:-0.03}"
for ((i=0; i<${#text}; i++)); do
echo -n "${text:$i:1}"
sleep "$delay"
done
}
# Spinner function - runs command with animated spinner
spinner() {
local pid=$1
local message="$2"
local i=0
while kill -0 "$pid" 2>/dev/null; do
echo -ne "\r ${LBLUE}${SPINNER_FRAMES[$i]}${NC} ${message}"
i=$(( (i + 1) % ${#SPINNER_FRAMES[@]} ))
sleep 0.1
done
wait "$pid"
return $?
}
# Progress bar function
progress_bar() {
local duration=$1
local width=30
local step=$(echo "scale=4; $duration / $width" | bc)
echo -ne " ${LBLUE}[${NC}"
for ((i=0; i<width; i++)); do
echo -ne "${TEAL}█${NC}"
sleep "$step"
done
echo -e "${LBLUE}]${NC} ${TEAL}${CHECK}${NC}"
}
# Animated box drawing
draw_box_top() {
echo -ne "${CYAN}"
echo -n "╔"
for ((i=0; i<84; i++)); do
echo -n "═"
sleep 0.005
done
echo -e "╗${NC}"
}
draw_box_bottom() {
echo -ne "${CYAN}"
echo -n "╚"
for ((i=0; i<84; i++)); do
echo -n "═"
sleep 0.005
done
echo -e "╝${NC}"
}
# Fade in logo line by line
fade_in_logo() {
local lines=(
"${CYAN}║ ║${NC}"
"${CYAN}║ ${LBLUE} .-~~~-. ${LCYAN}██╗ ██╗██╗██████╗ ████████╗███╗ ██╗███████╗████████╗${CYAN} ║${NC}"
"${CYAN}║ ${LBLUE} .- ~ ~-( )- ~~ -. ${LCYAN}██║ ██║██║██╔══██╗╚══██╔══╝████╗ ██║██╔════╝╚══██╔══╝${CYAN} ║${NC}"
"${CYAN}║ ${LBLUE} / \\${LCYAN}██║ ██║██║██████╔╝ ██║ ██╔██╗ ██║█████╗ ██║${CYAN} ║${NC}"
"${CYAN}║ ${BLUE} | ${DTEAL}.-----.${BLUE} |${TEAL}╚██╗ ██╔╝██║██╔══██╗ ██║ ██║╚██╗██║██╔══╝ ██║${CYAN} ║${NC}"
"${CYAN}║ ${BLUE} \\ ${DTEAL}( )${BLUE} / ${TEAL} ╚████╔╝ ██║██║ ██║ ██║ ██║ ╚████║███████╗ ██║${CYAN} ║${NC}"
"${CYAN}║ ${DTEAL} \`~ --._____.-- ~\` ${TEAL} ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝${CYAN} ║${NC}"
"${CYAN}║ ║${NC}"
"${CYAN}║ ${BOLD}${YELLOW}Paymenter Load Balancer - Git Update & Apply${NC}${CYAN} ║${NC}"
"${CYAN}║ ║${NC}"
)
for line in "${lines[@]}"; do
echo -e "$line"
sleep 0.08
done
}
# Pulse effect for status messages
pulse_message() {
local message="$1"
local color="$2"
for i in {1..2}; do
echo -ne "\r ${color}${BOLD}${message}${NC}"
sleep 0.15
echo -ne "\r ${color}${DIM}${message}${NC}"
sleep 0.15
done
echo -ne "\r ${color}${message}${NC}"
}
clear clear
echo -e "${CYAN}╔════════════════════════════════════════════════════════════════════════════════════╗${NC}" # Animated header
echo -e "${CYAN}║ ║${NC}" draw_box_top
echo -e "${CYAN}║ ${LBLUE} .-~~~-. ${LCYAN}██╗ ██╗██╗██████╗ ████████╗███╗ ██╗███████╗████████╗${CYAN} ║${NC}" fade_in_logo
echo -e "${CYAN}║ ${LBLUE} .- ~ ~-( )- ~~ -. ${LCYAN}██║ ██║██║██╔══██╗╚══██╔══╝████╗ ██║██╔════╝╚══██╔══╝${CYAN} ║${NC}" draw_box_bottom
echo -e "${CYAN}║ ${LBLUE} / \\${LCYAN}██║ ██║██║██████╔╝ ██║ ██╔██╗ ██║█████╗ ██║${CYAN} ║${NC}"
echo -e "${CYAN}║ ${BLUE} | ${DTEAL}.-----.${BLUE} |${TEAL}╚██╗ ██╔╝██║██╔══██╗ ██║ ██║╚██╗██║██╔══╝ ██║${CYAN} ║${NC}"
echo -e "${CYAN}║ ${BLUE} \\ ${DTEAL}( )${BLUE} / ${TEAL} ╚████╔╝ ██║██║ ██║ ██║ ██║ ╚████║███████╗ ██║${CYAN} ║${NC}"
echo -e "${CYAN}║ ${DTEAL} \`~ --._____.-- ~\` ${TEAL} ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝${CYAN} ║${NC}"
echo -e "${CYAN}║ ║${NC}"
echo -e "${CYAN}║ ${BOLD}${YELLOW}Paymenter Load Balancer - Git Update & Apply${NC}${CYAN} ║${NC}"
echo -e "${CYAN}║ ║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════════════════════════════════╝${NC}"
echo "" echo ""
echo -e "${LBLUE}${ARROW}${NC} Repository: ${LCYAN}https://gitea.virtnet.bond/Joseph.Rawlings/Virtnet.bond/${NC}" # Animated repository info
echo -ne "${LBLUE}${ARROW}${NC} Repository: "
typewriter "https://gitea.virtnet.bond/Joseph.Rawlings/Virtnet.bond/" 0.02
echo -e "${NC}"
echo "" echo ""
sleep_time=$((RANDOM % 5 + 1)) sleep_time=$((RANDOM % 5 + 1))
cd /var/www/paymenter cd /var/www/paymenter
# Preparing update with animated countdown
echo -e "${TEAL}${GEAR}${NC} ${BOLD}Preparing update...${NC}" echo -e "${TEAL}${GEAR}${NC} ${BOLD}Preparing update...${NC}"
echo -ne " ${LBLUE}⏳${NC} Waiting " echo -ne " ${LBLUE}⏳${NC} Waiting "
for ((i=sleep_time; i>0; i--)); do for ((i=sleep_time; i>0; i--)); do
echo -ne "${LCYAN}${i}${NC} " echo -ne "${LCYAN}${BOLD}${i}${NC} "
sleep 1 for frame in "${SPINNER_FRAMES[@]}"; do
echo -ne "${LBLUE}${frame}${NC}"
sleep 0.1
echo -ne "\b"
done done
echo -e "${TEAL}${CHECK}${NC}" done
echo -e "${TEAL}${CHECK}${NC} ${SPARKLE}"
echo "" echo ""
# Git pull with spinner
echo -e "${TEAL}${GEAR}${NC} ${BOLD}Pulling latest changes from Git...${NC}" echo -e "${TEAL}${GEAR}${NC} ${BOLD}Pulling latest changes from Git...${NC}"
if ! git pull; then git pull > /tmp/git_output.txt 2>&1 &
echo -e " ${RED}${CROSS}${NC} Git pull failed!" GIT_PID=$!
echo -e "${LBLUE}${ARROW}${NC} Restarting script..." spinner $GIT_PID "Fetching from remote..."
GIT_STATUS=$?
if [ $GIT_STATUS -ne 0 ]; then
echo -e "\r ${RED}${CROSS}${NC} Git pull failed! "
cat /tmp/git_output.txt
echo ""
pulse_message "Restarting script..." "${YELLOW}"
echo ""
sleep 2 sleep 2
exec "$0" "$@" exec "$0" "$@"
fi fi
echo -e " ${TEAL}${CHECK}${NC} Git pull completed" echo -e "\r ${TEAL}${CHECK}${NC} Git pull completed ${SPARKLE} "
cat /tmp/git_output.txt | head -3 | while read line; do
echo -e " ${DIM}${line}${NC}"
done
echo "" echo ""
# Cache clearing with progress
echo -e "${TEAL}${GEAR}${NC} ${BOLD}Clearing caches...${NC}" echo -e "${TEAL}${GEAR}${NC} ${BOLD}Clearing caches...${NC}"
php artisan view:clear > /dev/null 2>&1 echo -ne " ${LBLUE}${SPINNER_FRAMES[0]}${NC} View cache"
echo -e " ${TEAL}${CHECK}${NC} View cache cleared" php artisan view:clear > /dev/null 2>&1 &
php artisan cache:clear > /dev/null 2>&1 spinner $! "View cache"
echo -e " ${TEAL}${CHECK}${NC} Application cache cleared" echo -e "\r ${TEAL}${CHECK}${NC} View cache cleared ${SPARKLE} "
echo -ne " ${LBLUE}${SPINNER_FRAMES[0]}${NC} Application cache"
php artisan cache:clear > /dev/null 2>&1 &
spinner $! "Application cache"
echo -e "\r ${TEAL}${CHECK}${NC} Application cache cleared ${SPARKLE} "
echo "" echo ""
# PHP-FPM restart with progress bar
echo -e "${TEAL}${GEAR}${NC} ${BOLD}Restarting PHP-FPM...${NC}" echo -e "${TEAL}${GEAR}${NC} ${BOLD}Restarting PHP-FPM...${NC}"
systemctl restart php8.3-fpm systemctl restart php8.3-fpm &
echo -e " ${TEAL}${CHECK}${NC} PHP 8.3 FPM restarted" RESTART_PID=$!
spinner $RESTART_PID "Restarting service..."
echo -e "\r ${TEAL}${CHECK}${NC} PHP 8.3 FPM restarted ${SPARKLE} "
echo "" echo ""
echo -e "${CYAN}╔════════════════════════════════════════════════════════════════════════════════════╗${NC}" # Animated completion box
sleep 0.3
draw_box_top
echo -e "${CYAN}║ ║${NC}" echo -e "${CYAN}║ ║${NC}"
echo -e "${CYAN}║ ${TEAL}${ROCKET} ${BOLD}UPDATE COMPLETE!${NC}${CYAN} ║${NC}" sleep 0.1
echo -ne "${CYAN}║ ${TEAL}${ROCKET} ${NC}"
typewriter "${BOLD}UPDATE COMPLETE!${NC}" 0.05
echo -e "${CYAN} ║${NC}"
sleep 0.1
echo -e "${CYAN}║ ║${NC}" echo -e "${CYAN}║ ║${NC}"
echo -e "${CYAN}║ ${NC}Paymenter has been successfully updated and services restarted.${CYAN} ║${NC}" echo -e "${CYAN}║ ${NC}Paymenter has been successfully updated and services restarted.${CYAN} ║${NC}"
echo -e "${CYAN}║ ║${NC}" echo -e "${CYAN}║ ║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════════════════════════════════╝${NC}" draw_box_bottom
# Final sparkle animation
echo ""
echo -ne " "
for i in {1..5}; do
echo -ne "${LCYAN}${SPARKLE}${NC} "
sleep 0.15
done
echo ""
echo "" echo ""