Update setup-auto-updates.sh
This commit is contained in:
@@ -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:"
|
||||
|
||||
Reference in New Issue
Block a user