Add daily weather report automation

This commit is contained in:
2026-06-20 08:08:39 +02:00
parent c39ae5cdfa
commit c7663779bb
4 changed files with 657 additions and 0 deletions
@@ -24,6 +24,8 @@ MAIL_SCRIPT="${MAIL_SCRIPT:-/mnt/user/services/homelab-infra/services/posture-ch
SEND_NTFY="${SEND_NTFY:-0}"
NTFY_TOPIC="${NTFY_TOPIC:-homelab-info}"
NTFY_SCRIPT="${NTFY_SCRIPT:-/mnt/user/services/homelab-infra/ops/restore-tests/send-ntfy.sh}"
INCLUDE_WEATHER_REPORT="${INCLUDE_WEATHER_REPORT:-0}"
WEATHER_REPORT_SCRIPT="${WEATHER_REPORT_SCRIPT:-/mnt/user/services/homelab-infra/services/posture-check/weather-day-report.py}"
BORG_CONTAINER="${BORG_CONTAINER:-borg-ui}"
PROMETHEUS_CONTAINER="${PROMETHEUS_CONTAINER:-monitoring-prometheus}"
TRAEFIK_ACME_PATH="${TRAEFIK_ACME_PATH:-/mnt/user/appdata/traefik/letsencrypt/acme.json}"
@@ -218,6 +220,44 @@ derive_report_status() {
set_summary "report_status" "$REPORT_STATUS"
}
collect_weather_report() {
[ "$INCLUDE_WEATHER_REPORT" = "1" ] || return 0
append "## Wetterbericht"
append ""
if ! command -v python3 >/dev/null 2>&1; then
append "- Wetterbericht nicht erzeugt: \`python3\` ist auf dem Host nicht verfuegbar."
append ""
record_section_error "weather" "python3 fehlt"
set_summary "weather_report_status" "missing-python"
return 0
fi
if [ ! -f "$WEATHER_REPORT_SCRIPT" ]; then
append "- Wetterbericht nicht erzeugt: Script fehlt unter \`$WEATHER_REPORT_SCRIPT\`."
append ""
record_section_error "weather" "Script $WEATHER_REPORT_SCRIPT fehlt"
set_summary "weather_report_status" "missing-script"
return 0
fi
local weather_out
if weather_out="$(python3 "$WEATHER_REPORT_SCRIPT" --heading-level 3 2>&1)"; then
printf '%s\n\n' "$weather_out" >> "$BODY_PATH"
set_summary "weather_report_status" "ok"
else
append "- Wetterbericht nicht erzeugt:"
append ""
append '```text'
printf '%s\n' "$weather_out" >> "$BODY_PATH"
append '```'
append ""
record_section_error "weather" "$(printf '%s' "$weather_out" | head -n 1 | shorten)"
set_summary "weather_report_status" "failed"
fi
}
print_status_reasons() {
local count=0
@@ -1367,6 +1407,7 @@ Section errors: ${section_failures:-unknown}"
main() {
collect_overview
collect_weather_report
collect_host_health
collect_borg
collect_prometheus