#!/bin/bash # One-command install on a fresh Apple Silicon Mac. # # git clone ssh://git@100.71.119.27:222/monster/yourovo.git # cd yourovo/mac && ./install.sh # # Installs dependencies, then registers a launchd agent so the daemon starts at login # and restarts itself if it dies. No Terminal needed after this, ever. # # Re-runnable: pulls the latest commit and reloads the agent. set -e cd "$(dirname "$0")" HERE="$(pwd -P)" LABEL="com.pricegod.labeld" PLIST="$HOME/Library/LaunchAgents/$LABEL.plist" LOG="$HOME/Library/Logs/pricegod-labeld.log" case "${1:-install}" in uninstall) launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true rm -f "$PLIST" echo "removed $LABEL" exit 0 ;; esac echo "==> updating from git" git -C "$HERE/.." pull --ff-only 2>/dev/null || echo " (skipped -- not a clean fast-forward)" echo "==> dependencies" ./setup.sh echo "==> launchd agent" mkdir -p "$(dirname "$PLIST")" "$(dirname "$LOG")" cat > "$PLIST" < Label $LABEL ProgramArguments $HERE/venv/bin/python $HERE/daemon.py WorkingDirectory $HERE RunAtLoad KeepAlive ProcessType Interactive StandardOutPath $LOG StandardErrorPath $LOG PLISTEOF launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true launchctl bootstrap "gui/$(id -u)" "$PLIST" launchctl kickstart -k "gui/$(id -u)/$LABEL" echo "==> waiting for the daemon" for i in $(seq 1 20); do if curl -fsS -m 2 http://localhost:7790/ >/dev/null 2>&1; then echo curl -s http://localhost:7790/devices echo echo echo "OK -- running on http://localhost:7790/ and will start at every login." echo " logs: tail -f $LOG" echo " restart: launchctl kickstart -k gui/$(id -u)/$LABEL" echo " uninstall: ./install.sh uninstall" exit 0 fi sleep 0.5 done echo "daemon did not come up -- check $LOG" >&2 tail -20 "$LOG" 2>/dev/null || true exit 1