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