Add Pi hardware watchdog setup
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Executable
+30
@@ -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."
|
||||
@@ -0,0 +1,3 @@
|
||||
[Manager]
|
||||
RuntimeWatchdogSec=10s
|
||||
RebootWatchdogSec=10min
|
||||
Reference in New Issue
Block a user