c9aac20e73
Ansible-managed (inline-compose, file-provider router, host :8099), idempotent (changed=0). PBS-backed pg_dump (daily, keep 14) with verified round-trip restore; ntfy 'garage' reminder probe (.190); Diun repo-watch for new tags; Homepage tile+widget. Secrets via ansible-vault / /etc env files / HOMEPAGE_VAR — none in repo. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.7 KiB
Bash
36 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
# Daily LubeLogger reminder digest -> ntfy 'garage' topic.
|
|
# Reads per-vehicle reminder urgency counts from LubeLogger's API and posts a
|
|
# summary ONLY when something is due/overdue (PastDue + VeryUrgent + Urgent).
|
|
# Runs on ansible-control (.190) via lubelogger-reminders.timer.
|
|
# Shape mirrors the gluetun vpn-tunnel-probe (oneshot + timer, set -euo pipefail).
|
|
|
|
source /etc/lubelogger-reminders.env # LUBELOGGER_URL LUBELOGGER_USER LUBELOGGER_PASS NTFY_URL
|
|
|
|
if ! resp=$(curl -sf --max-time 20 -u "${LUBELOGGER_USER}:${LUBELOGGER_PASS}" "${LUBELOGGER_URL}/api/vehicle/info"); then
|
|
logger -t lubelogger-reminders "ERROR: LubeLogger API query failed"
|
|
curl -sf --max-time 15 -H "Priority: high" -H "Tags: warning" \
|
|
-H "Title: LubeLogger reminder probe failed" \
|
|
-d "Could not query ${LUBELOGGER_URL}/api/vehicle/info" "$NTFY_URL" || true
|
|
exit 1
|
|
fi
|
|
|
|
total=$(printf '%s' "$resp" | jq '[.[] | (.PastDueReminderCount + .VeryUrgentReminderCount + .UrgentReminderCount)] | add // 0')
|
|
|
|
if [ "${total:-0}" -gt 0 ]; then
|
|
body=$(printf '%s' "$resp" | jq -r '
|
|
.[]
|
|
| (.PastDueReminderCount + .VeryUrgentReminderCount + .UrgentReminderCount) as $due
|
|
| select($due > 0)
|
|
| "• \(.VehicleData.Year) \(.VehicleData.Make) \(.VehicleData.Model): "
|
|
+ "\(.PastDueReminderCount) past-due, \(.VeryUrgentReminderCount) very-urgent, \(.UrgentReminderCount) urgent"')
|
|
curl -sf --max-time 15 \
|
|
-H "Title: Vehicle maintenance due (${total})" \
|
|
-H "Tags: wrench" -H "Priority: default" \
|
|
-d "$body" "$NTFY_URL" || true
|
|
logger -t lubelogger-reminders "posted ${total} due reminder(s) to ntfy garage"
|
|
else
|
|
logger -t lubelogger-reminders "no due/overdue reminders"
|
|
fi
|