From d077ce45724b93e3db183630a065cf08d577c167 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 28 Jul 2025 05:36:55 +0000 Subject: [PATCH] Update setup-auto-updates.sh --- setup-auto-updates.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/setup-auto-updates.sh b/setup-auto-updates.sh index 2ab1539..c4da51d 100644 --- a/setup-auto-updates.sh +++ b/setup-auto-updates.sh @@ -120,6 +120,23 @@ enable_timers_if_systemd() { fi } +wait_for_apt_units() { + # Wait for apt-daily/apt-daily-upgrade units to finish (up to ~120s) + if command -v systemctl >/dev/null 2>&1; then + local units=(apt-daily.service apt-daily-upgrade.service) + for i in {1..60}; do + local busy=0 + for u in "${units[@]}"; do + systemctl is-active --quiet "$u" && { busy=1; break; } + done + (( busy == 0 )) && return 0 + (( i % 10 == 0 )) && echo "[INFO] apt units busy…waiting $((i*2))s" + sleep 2 + done + echo "[WARN] apt units still busy after ~120s; continuing anyway." + fi +} + validate_with_dryrun() { wait_for_apt || true wait_for_apt_units || true