diff --git a/setup-auto-updates.sh b/setup-auto-updates.sh index c020e0d..2ab1539 100644 --- a/setup-auto-updates.sh +++ b/setup-auto-updates.sh @@ -122,21 +122,31 @@ enable_timers_if_systemd() { validate_with_dryrun() { wait_for_apt || true + wait_for_apt_units || true echo "[INFO] Validating unattended-upgrades with a dry run…" local log="/tmp/unattended-upgrades-dryrun.$$" - if ! timeout 180 unattended-upgrades --dry-run --debug >"$log" 2>&1; then + + # Temporarily disable ERR trap so a non-zero here doesn't print "[ERROR] Line …" + trap - ERR + set +e + timeout 240 unattended-upgrades --dry-run --debug >"$log" 2>&1 + local rc=$? + set -e + trap 'echo "[ERROR] Line $LINENO failed" >&2' ERR + + if (( rc != 0 )); then echo "[WARN] Dry run timed out or failed; see $log" return 1 fi - # Show the header line so you can see what matched + grep -E "Allowed origins are" "$log" | head -n1 || true - # Catch real parser errors if grep -qiE "Unable to parse|ValueError|AttributeError|ImportError" "$log"; then echo "[ERROR] Parsing error detected; see $log" return 1 fi } + show_status() { echo echo "[INFO] Config files:"