From 3d9706b46693868091b4e433a36a39e233446414 Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Sun, 9 Aug 2026 17:55:13 -0400 Subject: [PATCH] Add Pi hardware watchdog setup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- deploy/install_watchdog.sh | 30 ++++++++++++++++++++++++++++++ deploy/yaris-watchdog.conf | 3 +++ 2 files changed, 33 insertions(+) create mode 100755 deploy/install_watchdog.sh create mode 100644 deploy/yaris-watchdog.conf diff --git a/deploy/install_watchdog.sh b/deploy/install_watchdog.sh new file mode 100755 index 0000000..e72e89d --- /dev/null +++ b/deploy/install_watchdog.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# Enable systemd's hardware watchdog on the Pi. +# Run this ON THE PI as the `yaris` user: +# cd /home/yaris/app/yaris-obd && bash deploy/install_watchdog.sh +set -euo pipefail + +REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +CONFIG_FILE="$REPO_DIR/deploy/yaris-watchdog.conf" +CONFIG_DIR="/etc/systemd/system.conf.d" +CONFIG_DEST="$CONFIG_DIR/yaris-watchdog.conf" + +if [ ! -e /dev/watchdog0 ]; then + echo "No /dev/watchdog0 device found; refusing to enable a watchdog." + exit 1 +fi + +sudo install -D -m 0644 "$CONFIG_FILE" "$CONFIG_DEST" + +# Manager configuration is not covered by daemon-reload. Re-exec systemd so the +# watchdog starts now without requiring an otherwise unnecessary reboot. +sudo systemctl daemon-reexec + +runtime_watchdog="$(systemctl show --property=RuntimeWatchdogUSec --value)" +if [ "$runtime_watchdog" = "0" ]; then + echo "Runtime watchdog did not activate; check $CONFIG_DEST." + exit 1 +fi + +echo "Hardware watchdog enabled with RuntimeWatchdogUSec=$runtime_watchdog." +echo "Reboot once when convenient, then rerun this script to verify persistence." diff --git a/deploy/yaris-watchdog.conf b/deploy/yaris-watchdog.conf new file mode 100644 index 0000000..9ee888d --- /dev/null +++ b/deploy/yaris-watchdog.conf @@ -0,0 +1,3 @@ +[Manager] +RuntimeWatchdogSec=10s +RebootWatchdogSec=10min