Update setup-auto-updates.sh

This commit is contained in:
2025-07-28 05:36:55 +00:00
parent c29205048b
commit d077ce4572

View File

@@ -120,6 +120,23 @@ enable_timers_if_systemd() {
fi 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() { validate_with_dryrun() {
wait_for_apt || true wait_for_apt || true
wait_for_apt_units || true wait_for_apt_units || true