#!/bin/sh # Install (or resync) the self-healing launchd agent for the Flow rinse. # Run ON the rig Mac, from this directory: ./install.sh # # Mirrors the vault-backup pattern (mrpgi-vault/backup.sh): launchd can't # execute scripts inside ~/Documents (macOS TCC blocks it), so the agent runs # a COPY of the runtime at "~/Library/Application Support/flowrinse/". # Once the agent owns the server, queue.jsonl / results.jsonl / downloads # live THERE — enqueue via http://localhost:8017/enqueue as usual. # # Re-run after editing launch.sh / local_server_example.py to resync the copy. # # One-time macOS prompts on first run (click Allow on the rig's screen): # * Automation: "sh"/"osascript" wants to control "Brave Browser" # # Manage the job: # launchctl kickstart -k gui/$(id -u)/games.monsterrobot.flowrinse # run now # launchctl bootout gui/$(id -u)/games.monsterrobot.flowrinse # stop it set -e DIR="$(cd "$(dirname "$0")" && pwd)" APP="$HOME/Library/Application Support/flowrinse" LABEL=games.monsterrobot.flowrinse PLIST="$HOME/Library/LaunchAgents/$LABEL.plist" # runtime copy (code always refreshed; live state never overwritten) mkdir -p "$APP" cp "$DIR/launch.sh" "$DIR/local_server_example.py" "$DIR/flowclient.py" "$APP/" chmod +x "$APP/launch.sh" for f in queue.jsonl results.jsonl; do [ -f "$APP/$f" ] || { [ -f "$DIR/$f" ] && cp "$DIR/$f" "$APP/$f" || true; } done mkdir -p "$HOME/Library/LaunchAgents" cp "$DIR/$LABEL.plist" "$PLIST" launchctl bootout gui/$(id -u)/$LABEL 2>/dev/null || true launchctl bootstrap gui/$(id -u) "$PLIST" echo "installed $LABEL — fires at load + every 10 min" echo "run now: launchctl kickstart -k gui/$(id -u)/$LABEL"