#!/bin/bash HA_URL="http://localhost:8123" STATE_FILE="/tmp/ha_watchdog_state" if curl -s -m 10 "$HA_URL" > /dev/null; then echo "0" > "$STATE_FILE" else STATE="0" if [ -f "$STATE_FILE" ]; then STATE=$(cat "$STATE_FILE") fi if [ "$STATE" -eq 1 ]; then # Already tried restarting once, failed again -> Reboot echo "0" > "$STATE_FILE" sudo reboot else # Try returning the container to life docker restart HomeAssistant echo "1" > "$STATE_FILE" fi fi