Confirm Docker 10 APT boot reports

master
Carlo Costanzo 2 weeks ago
parent 4680392f8d
commit 640d0d9da8

@ -9,7 +9,8 @@ Type=oneshot
ExecStart=/usr/local/sbin/apt_reboot_report.sh --from-apt-weekly
User=root
Group=root
TimeoutStartSec=330
# Allows docker_10's initial retry, 120-second HA startup settle, and confirmation retry.
TimeoutStartSec=600
[Install]
WantedBy=multi-user.target

@ -3,6 +3,7 @@ set -euo pipefail
# Boot report for APT-managed hosts.
# Reuses the registered apt_weekly webhook and retries while Home Assistant starts.
# docker_10 hosts Home Assistant, so it confirms delivery after HA finishes loading.
WEBHOOK_SOURCE="${1:-}"
HOST_NAME="${2:-$(hostname -s)}"
@ -42,15 +43,33 @@ payload=$(cat <<JSON
JSON
)
curl --fail --silent --show-error \
--connect-timeout 5 \
--max-time 20 \
--retry 30 \
--retry-delay 10 \
--retry-connrefused \
--retry-all-errors \
--retry-max-time 300 \
-X POST \
-H 'Content-Type: application/json' \
-d "$payload" \
"$WEBHOOK_URL"
post_report() {
local retry_max_time="$1"
curl --fail --silent --show-error \
--connect-timeout 5 \
--max-time 20 \
--retry 30 \
--retry-delay 10 \
--retry-connrefused \
--retry-all-errors \
--retry-max-time "$retry_max_time" \
-X POST \
-H 'Content-Type: application/json' \
-d "$payload" \
"$WEBHOOK_URL"
}
post_report 300
if [[ "$HOST_NAME" == "docker_10" ]]; then
CONFIRM_DELAY_SECONDS="${APT_BOOT_REPORT_CONFIRM_DELAY_SECONDS:-120}"
if ! [[ "$CONFIRM_DELAY_SECONDS" =~ ^[0-9]+$ ]]; then
echo "APT_BOOT_REPORT_CONFIRM_DELAY_SECONDS must be a non-negative integer" >&2
exit 1
fi
echo "Waiting ${CONFIRM_DELAY_SECONDS}s for Home Assistant startup before confirming boot status."
sleep "$CONFIRM_DELAY_SECONDS"
post_report 120
fi

Loading…
Cancel
Save

Powered by TurnKey Linux.