feat: enhance gitapply.sh with improved output, error handling, and cache clearing

This commit is contained in:
2025-12-23 20:16:38 -05:00
parent edd6ed4323
commit 3a8489cbd7

View File

@@ -1,20 +1,82 @@
#!/bin/bash #!/bin/bash
echo "Virtnet.bond Paymenter Load Balancer Git Repository Update and Apply" # Colors
echo "https://gitea.virtnet.bond/Joseph.Rawlings/Virtnet.bond/" RED='\033[0;31m'
echo "------------------------------------------------------------------------" GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
BOLD='\033[1m'
NC='\033[0m' # No Color
# Symbols
CHECK="✔"
CROSS="✖"
ARROW="➜"
GEAR="⚙"
ROCKET="🚀"
clear
echo -e "${CYAN}"
echo "╔══════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo "║ ${BOLD}${MAGENTA}██╗ ██╗██╗██████╗ ████████╗███╗ ██╗███████╗████████╗${CYAN} ║"
echo "║ ${BOLD}${MAGENTA}██║ ██║██║██╔══██╗╚══██╔══╝████╗ ██║██╔════╝╚══██╔══╝${CYAN} ║"
echo "║ ${BOLD}${MAGENTA}██║ ██║██║██████╔╝ ██║ ██╔██╗ ██║█████╗ ██║${CYAN} ║"
echo "║ ${BOLD}${MAGENTA}╚██╗ ██╔╝██║██╔══██╗ ██║ ██║╚██╗██║██╔══╝ ██║${CYAN} ║"
echo "║ ${BOLD}${MAGENTA} ╚████╔╝ ██║██║ ██║ ██║ ██║ ╚████║███████╗ ██║${CYAN} ║"
echo "║ ${BOLD}${MAGENTA} ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝${CYAN} ║"
echo "║ ║"
echo "║ ${BOLD}${YELLOW}Paymenter Load Balancer - Git Update & Apply${CYAN} ║"
echo "║ ║"
echo "╚══════════════════════════════════════════════════════════════════════╝"
echo -e "${NC}"
echo -e "${BLUE}${ARROW}${NC} Repository: ${CYAN}https://gitea.virtnet.bond/Joseph.Rawlings/Virtnet.bond/${NC}"
echo ""
sleep_time=$((RANDOM % 5 + 1)) sleep_time=$((RANDOM % 5 + 1))
cd /var/www/paymenter cd /var/www/paymenter
echo "Sleeping for $sleep_time seconds..."
sleep "$sleep_time" echo -e "${YELLOW}${GEAR}${NC} ${BOLD}Preparing update...${NC}"
echo -ne " ${BLUE}⏳${NC} Waiting "
for ((i=sleep_time; i>0; i--)); do
echo -ne "${CYAN}${i}${NC} "
sleep 1
done
echo -e "${GREEN}${CHECK}${NC}"
echo ""
echo -e "${YELLOW}${GEAR}${NC} ${BOLD}Pulling latest changes from Git...${NC}"
if ! git pull; then if ! git pull; then
echo "Git pull failed. Restarting script..." echo -e " ${RED}${CROSS}${NC} Git pull failed!"
echo -e "${YELLOW}${ARROW}${NC} Restarting script..."
sleep 2
exec "$0" "$@" exec "$0" "$@"
fi fi
php artisan view:clear echo -e " ${GREEN}${CHECK}${NC} Git pull completed"
php artisan cache:clear echo ""
echo -e "${YELLOW}${GEAR}${NC} ${BOLD}Clearing caches...${NC}"
php artisan view:clear > /dev/null 2>&1
echo -e " ${GREEN}${CHECK}${NC} View cache cleared"
php artisan cache:clear > /dev/null 2>&1
echo -e " ${GREEN}${CHECK}${NC} Application cache cleared"
echo ""
echo -e "${YELLOW}${GEAR}${NC} ${BOLD}Restarting PHP-FPM...${NC}"
systemctl restart php8.3-fpm systemctl restart php8.3-fpm
echo "\n\n" echo -e " ${GREEN}${CHECK}${NC} PHP 8.3 FPM restarted"
echo "------------------------------------------------------------------------" echo ""
echo "Paymenter has been updated successfully."
echo "------------------------------------------------------------------------" echo -e "${CYAN}"
echo "╔══════════════════════════════════════════════════════════════════════╗"
echo "║ ║"
echo -e "║ ${GREEN}${ROCKET} ${BOLD}UPDATE COMPLETE!${NC}${CYAN} ║"
echo "║ ║"
echo -e "║ ${NC}Paymenter has been successfully updated and services restarted.${CYAN} ║"
echo "║ ║"
echo "╚══════════════════════════════════════════════════════════════════════╝"
echo -e "${NC}"