-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·96 lines (85 loc) · 3.88 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·96 lines (85 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
# yaggo-brain bootstrap installer (macOS / Linux).
#
# Unlike a single-binary MCP server, yaggo-brain is a full local-first stack
# (Docker Compose + a pnpm/turbo monorepo). This script clones the repo, installs
# dependencies, brings up the infrastructure, applies migrations, and pulls the
# local models so you can go straight to `pnpm dev`.
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/YaggoSEO/yaggo-brain/main/install.sh | bash
# curl -fsSL https://raw.githubusercontent.com/YaggoSEO/yaggo-brain/main/install.sh | bash -s -- --dir=./yaggo-brain
# curl -fsSL .../install.sh | bash -s -- --no-models # skip Ollama model pulls
# curl -fsSL .../install.sh | bash -s -- --no-docker # skip infra + migrations
#
# Flags: --dir=PATH --no-docker --no-models --dev -h/--help
set -euo pipefail
REPO_URL="https://github.com/YaggoSEO/yaggo-brain.git"
TARGET_DIR="yaggo-brain"
RUN_DOCKER=1
PULL_MODELS=1
START_DEV=0
for arg in "$@"; do
case "$arg" in
--dir=*) TARGET_DIR="${arg#*=}" ;;
--no-docker) RUN_DOCKER=0 ;;
--no-models) PULL_MODELS=0 ;;
--dev) START_DEV=1 ;;
-h|--help)
echo "Usage: install.sh [--dir=PATH] [--no-docker] [--no-models] [--dev]"; exit 0 ;;
*) echo "unknown option: $arg" >&2; exit 1 ;;
esac
done
info() { printf '\033[36m[yaggo-brain]\033[0m %s\n' "$*"; }
warn() { printf '\033[33m[yaggo-brain]\033[0m %s\n' "$*"; }
err() { printf '\033[31m[yaggo-brain]\033[0m %s\n' "$*" >&2; }
have() { command -v "$1" >/dev/null 2>&1; }
# --- prerequisites ---
have git || { err "git is required."; exit 1; }
have node || { err "Node.js >= 20 is required (https://nodejs.org)."; exit 1; }
NODE_MAJOR="$(node -p 'process.versions.node.split(".")[0]')"
[ "$NODE_MAJOR" -ge 20 ] || { err "Node.js >= 20 required (found $(node -v))."; exit 1; }
if ! have pnpm && have corepack; then
info "Enabling pnpm via corepack"; corepack enable pnpm >/dev/null 2>&1 || true
fi
have pnpm || { err "pnpm is required. Install it: npm i -g pnpm"; exit 1; }
# --- locate or clone the repo ---
if [ -f package.json ] && grep -q '"name": *"yaggo-brain"' package.json 2>/dev/null; then
info "Running inside an existing yaggo-brain checkout."
else
if [ -d "$TARGET_DIR/.git" ]; then
info "Updating existing checkout in $TARGET_DIR"; git -C "$TARGET_DIR" pull --ff-only || true
else
info "Cloning $REPO_URL into $TARGET_DIR"; git clone --depth=1 "$REPO_URL" "$TARGET_DIR"
fi
cd "$TARGET_DIR"
fi
# --- environment file ---
if [ ! -f .env ]; then cp .env.example .env; info "Created .env from .env.example"; fi
# --- dependencies ---
info "Installing dependencies (pnpm install)"; pnpm install
# --- infrastructure + migrations ---
if [ "$RUN_DOCKER" -eq 1 ]; then
if have docker; then
info "Starting infrastructure (docker compose up -d)"; pnpm db:up
info "Waiting for Postgres to become ready..."
for _ in $(seq 1 30); do
if docker exec yaggo-postgres pg_isready -U yaggo -d yaggo >/dev/null 2>&1; then break; fi
sleep 2
done
info "Applying database migrations"
pnpm db:migrate || warn "Migrations failed; run 'pnpm db:migrate' once Postgres is healthy."
if [ "$PULL_MODELS" -eq 1 ]; then
info "Pulling local Ollama models (best effort)"
docker exec yaggo-ollama ollama pull nomic-embed-text || warn "skipped nomic-embed-text"
docker exec yaggo-ollama ollama pull qwen2.5:3b || warn "skipped qwen2.5:3b"
docker exec yaggo-ollama ollama pull qwen2.5-coder:7b || warn "skipped qwen2.5-coder:7b"
fi
else
warn "Docker not found; skipping infra. Install Docker, then run: pnpm db:up && pnpm db:migrate"
fi
fi
info "Done."
info "Start the panel: pnpm dev (web http://localhost:3000, api http://localhost:3333)"
info "Wire your IDE: npx yaggo-brain install --target=cursor (also: claude-code, windsurf, --all)"
if [ "$START_DEV" -eq 1 ]; then info "Starting dev server..."; pnpm dev; fi