Files
yaris-obd/deploy/install_watchdog.sh
T
2026-08-09 17:55:13 -04:00

31 lines
1.1 KiB
Bash
Executable File

#!/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."