schon/scripts/Unix/reboot.sh
2025-06-16 14:02:30 +03:00

39 lines
1.2 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
SPINNER=('|' '/' '-' '\\')
COLORS=(97 37 90)
DELAY=0.1
run_with_spinner() {
local cmd="$1"
local msg="$2"
printf "\e[1m%s...\e[0m " "$msg"
eval "$cmd" &> /dev/null &
local pid=$!
local i=0
while kill -0 "$pid" 2>/dev/null; do
local frame=${SPINNER[i % ${#SPINNER[@]}]}
local color=${COLORS[i % ${#COLORS[@]}]}
printf "\e[${color}m%s\e[0m" "$frame"
sleep "$DELAY"
printf "\b"
((i++))
done
wait "$pid"
printf "\e[32m✔\e[0m\n"
}
echo
run_with_spinner "docker compose down --ansi never" "Stopping services (down)"
run_with_spinner "docker compose up -d --build --ansi never" "Rebuilding & starting services"
run_with_spinner "docker compose exec app poetry run python manage.py migrate --no-input" "Applying database migrations"
run_with_spinner "docker compose exec app poetry run python manage.py collectstatic --no-input" "Collecting static files"
run_with_spinner "docker compose exec app poetry run python manage.py set_default_caches" "Setting default caches"
run_with_spinner "docker system prune -f" "Cleaning up unused Docker data"
echo -e "\e[1mAll done! Your application is up and running.\e[0m"