#!/usr/bin/env bash # Install llm-router as a boot service: launchd on macOS, systemd (user) on Linux. # Run from the repo root: ./deploy/install-service.sh set -euo pipefail cd "$(dirname "$0")/.." INSTALL_DIR="$(pwd)" PATH_VAL="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" fill() { sed -e "s|__INSTALL_DIR__|$INSTALL_DIR|g" -e "s|__PATH__|$PATH_VAL|g" "$1"; } case "$(uname -s)" in Darwin) PLIST="$HOME/Library/LaunchAgents/com.llm-router.plist" fill deploy/com.llm-router.plist.template > "$PLIST" launchctl bootout "gui/$(id -u)/com.llm-router" 2>/dev/null || true launchctl bootstrap "gui/$(id -u)" "$PLIST" echo ">> installed launchd agent: $PLIST" echo " status: launchctl print gui/$(id -u)/com.llm-router | grep state" echo " logs: tail -f $INSTALL_DIR/launchd.out.log" echo " remove: launchctl bootout gui/$(id -u)/com.llm-router && rm $PLIST" ;; Linux) UNIT_DIR="$HOME/.config/systemd/user"; mkdir -p "$UNIT_DIR" fill deploy/llm-router.service.template > "$UNIT_DIR/llm-router.service" systemctl --user daemon-reload systemctl --user enable --now llm-router.service echo ">> installed systemd user service" echo " status: systemctl --user status llm-router" echo " logs: journalctl --user -u llm-router -f" echo " remove: systemctl --user disable --now llm-router && rm $UNIT_DIR/llm-router.service" echo " (tip: 'loginctl enable-linger $USER' to run without being logged in)" ;; *) echo "Unsupported OS: $(uname -s). Run ./run.sh manually or add your own unit."; exit 1 ;; esac