Files
buryan-infra/ops/update-manager/check-compose-available.sh
T

43 lines
1.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# ============================================================
# check-compose-available.sh — есть ли плагин compose во всех гостях
# ============================================================
# Обновление сервисов теперь выполняется через `docker compose up -d`,
# потому что только он пересоздаёт контейнер из нового образа. Если плагина
# в каком-то контейнере нет, обновление там не сработает — это надо знать
# заранее, а не в момент обновления.
#
# Запуск: bash check-compose-available.sh
# ============================================================
set -uo pipefail
lack=""
found=0
printf '%-6s %-22s %s\n' CT ИМЯ COMPOSE
printf '%s\n' '------------------------------------------------'
for id in $(pct list | awk 'NR>1{print $1}'); do
state=$(pct status "$id" 2>/dev/null | awk '{print $2}')
[ "$state" = "running" ] || continue
name=$(pct config "$id" 2>/dev/null | awk '/^hostname/{print $2}')
if ! pct exec "$id" -- bash -c 'command -v docker >/dev/null' 2>/dev/null; then
continue
fi
has=$(pct exec "$id" -- docker compose version 2>/dev/null | head -1)
if [ -n "$has" ]; then
printf '%-6s %-22s %s\n' "$id" "${name:-}" "есть"
found=$((found + 1))
else
printf '%-6s %-22s %s\n' "$id" "${name:-}" "НЕТ"
lack="$lack $id"
fi
done
echo
echo "с плагином compose: $found"
echo "без плагина:${lack:- нет}"