#!/usr/bin/env bash # Installs the Peppa watchdog as a launchd agent (starts at login, restarts on crash). # caffeinate -i keeps the Mac from idle-sleeping while the watchdog runs. # Remove: launchctl bootout gui/$(id -u)/quest.telecom.peppa.watchdog && rm the plist. set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" LABEL=quest.telecom.peppa.watchdog PLIST="$HOME/Library/LaunchAgents/$LABEL.plist" mkdir -p "$HOME/Library/LaunchAgents" "$HOME/.peppa" cat > "$PLIST" < Label$LABEL ProgramArguments /usr/bin/caffeinate-i $ROOT/packages/cli/bin/peppawatchdog EnvironmentVariables PATH$HOME/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin RunAtLoad KeepAlive StandardOutPath$HOME/.peppa/watchdog.log StandardErrorPath$HOME/.peppa/watchdog.log PLIST launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true launchctl bootstrap "gui/$(id -u)" "$PLIST" echo "watchdog installed: $PLIST (log: ~/.peppa/watchdog.log)"