diff --git a/.env.sample b/.env.sample index 625d17e..6b86b1f 100644 --- a/.env.sample +++ b/.env.sample @@ -12,3 +12,6 @@ FRESHRSS_PASSWORD=your-password MATRIX_HOMESERVER=https://matrix.example.net MATRIX_ROOM_ID=!roomid:example.net MATRIX_ACCESS_TOKEN=replace-with-access-token + +# Uptime Kuma push URL +UPTIME_KUMA_PUSH_URL=https://uptime.example.net/api/push/your-token diff --git a/BACKLOG.md b/BACKLOG.md index 3365e29..af180f0 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -134,3 +134,21 @@ Acceptance criteria: - The script posts a message to a Matrix room when updates are detected or errors occur. - Matrix credentials (homeserver, room id, access token) are read from `.env`. - The message includes actionable service names and version details. + +## US-15 - Systemd User Service + +As a maintainer, I want a systemd user service and timer so the script runs daily without manual intervention. + +Acceptance criteria: +- Provide a user-level systemd service file that runs the update checker. +- Provide a user-level timer that runs once per day. +- README documents how to install and enable the service and timer. + +## US-16 - Uptime Kuma Push + +As a maintainer, I want the script to call an Uptime Kuma push URL on each run so that failures are visible in the monitoring dashboard. + +Acceptance criteria: +- The script sends a request to the push URL when it runs. +- The push URL is configured via `.env`. +- Failures to reach the push URL are logged without crashing the run. diff --git a/README.md b/README.md index 505e84e..06fb787 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ export FRESHRSS_PASSWORD=... export MATRIX_HOMESERVER=... export MATRIX_ROOM_ID=... export MATRIX_ACCESS_TOKEN=... +export UPTIME_KUMA_PUSH_URL=... ``` The script also reads `.env` automatically if present. @@ -49,3 +50,21 @@ To run live integration checks against the real services: ```bash RUN_LIVE_TESTS=1 python -m pytest tests/test_live_services.py ``` + +## Systemd (user) + +Copy the unit files and enable the timer: + +```bash +mkdir -p ~/.config/systemd/user +cp systemd/check-for-updates.service ~/.config/systemd/user/ +cp systemd/check-for-updates.timer ~/.config/systemd/user/ +systemctl --user daemon-reload +systemctl --user enable --now check-for-updates.timer +``` + +View logs: + +```bash +journalctl --user -u check-for-updates.service +``` diff --git a/check_updates.py b/check_updates.py index c86fdc4..58136d8 100644 --- a/check_updates.py +++ b/check_updates.py @@ -565,6 +565,16 @@ def join_matrix_room(homeserver: str, room_id: str, token: str, timeout: float) return +def send_uptime_kuma_ping(timeout: float) -> None: + push_url = os.getenv("UPTIME_KUMA_PUSH_URL") + if not push_url: + return + try: + fetch_response(push_url, timeout=timeout, user_agent="check-for-updates") + except Exception as exc: + print(f"Uptime Kuma push failed: {exc}", file=sys.stderr) + + def main() -> int: parser = argparse.ArgumentParser(description="Check for webservice updates") parser.add_argument("--config", default="services.yaml", help="Path to services YAML") @@ -622,6 +632,7 @@ def main() -> int: summary, should_notify = build_summary(results) if should_notify: send_matrix_message(summary, args.timeout) + send_uptime_kuma_ping(args.timeout) return 0 diff --git a/systemd/check-for-updates.service b/systemd/check-for-updates.service new file mode 100644 index 0000000..dace9f4 --- /dev/null +++ b/systemd/check-for-updates.service @@ -0,0 +1,7 @@ +[Unit] +Description=Check hosted services for updates + +[Service] +Type=oneshot +WorkingDirectory=%h/Projects/check-for-updates +ExecStart=%h/Projects/check-for-updates/.venv/bin/python %h/Projects/check-for-updates/check_updates.py --config %h/Projects/check-for-updates/services.yaml diff --git a/systemd/check-for-updates.timer b/systemd/check-for-updates.timer new file mode 100644 index 0000000..52972a1 --- /dev/null +++ b/systemd/check-for-updates.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Run update checks daily + +[Timer] +OnCalendar=daily +Persistent=true + +[Install] +WantedBy=timers.target