#!/bin/bash # ============================================================ # Project Friday — Full Setup Script # Run this once to install all dependencies and download models. # ============================================================ set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" BACKEND_DIR="$PROJECT_DIR/backend" VENV_DIR="$BACKEND_DIR/venv" # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' NC='\033[0m' # No Color echo "" echo -e "${PURPLE}╔══════════════════════════════════════════════════╗${NC}" echo -e "${PURPLE}║ PROJECT FRIDAY — Setup Script ║${NC}" echo -e "${PURPLE}║ Sovereign Intelligence Suite ║${NC}" echo -e "${PURPLE}╚══════════════════════════════════════════════════╝${NC}" echo "" # ── Step 1: Check Prerequisites ────────────────────────────── echo -e "${CYAN}[1/8] Checking prerequisites...${NC}" # Check macOS if [[ "$(uname)" != "Darwin" ]]; then echo -e "${RED}Error: This script is designed for macOS only.${NC}" exit 1 fi echo -e " ${GREEN}✓${NC} macOS detected" # Check Xcode CLI tools if ! xcode-select -p &>/dev/null; then echo -e " ${YELLOW}Installing Xcode Command Line Tools...${NC}" xcode-select --install echo -e " ${YELLOW}Please wait for Xcode CLI tools to finish installing, then re-run this script.${NC}" exit 1 fi echo -e " ${GREEN}✓${NC} Xcode CLI tools installed" # Check Python 3 if ! command -v python3 &>/dev/null; then echo -e "${RED}Error: Python 3 is not installed. Install it via: brew install python${NC}" exit 1 fi PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}') echo -e " ${GREEN}✓${NC} Python $PYTHON_VERSION" # ── Step 2: Install Homebrew Packages ──────────────────────── echo "" echo -e "${CYAN}[2/8] Installing system dependencies via Homebrew...${NC}" if ! command -v brew &>/dev/null; then echo -e " ${YELLOW}Installing Homebrew...${NC}" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi # Install required packages for pkg in ffmpeg portaudio; do if brew list "$pkg" &>/dev/null; then echo -e " ${GREEN}✓${NC} $pkg already installed" else echo -e " ${YELLOW}Installing $pkg...${NC}" brew install "$pkg" echo -e " ${GREEN}✓${NC} $pkg installed" fi done # ── Step 3: Install Ollama ────────────────────────────────── echo "" echo -e "${CYAN}[3/8] Setting up Ollama (local LLM)...${NC}" if command -v ollama &>/dev/null; then echo -e " ${GREEN}✓${NC} Ollama already installed" else echo -e " ${YELLOW}Installing Ollama via Homebrew...${NC}" brew install ollama echo -e " ${GREEN}✓${NC} Ollama installed" fi # Start Ollama service if not running if ! pgrep -x "ollama" &>/dev/null; then echo -e " ${YELLOW}Starting Ollama service...${NC}" ollama serve &>/dev/null & sleep 3 fi echo -e " ${GREEN}✓${NC} Ollama service running" # ── Step 4: Pull LLM Model ────────────────────────────────── echo "" echo -e "${CYAN}[4/8] Downloading LLM model (llama3:8b)...${NC}" echo -e " ${YELLOW}This may take a while on first run (~4.7GB download)...${NC}" if ollama list 2>/dev/null | grep -q "llama3:8b"; then echo -e " ${GREEN}✓${NC} llama3:8b model already downloaded" else ollama pull llama3:8b echo -e " ${GREEN}✓${NC} llama3:8b model downloaded" fi # ── Step 5: Create Python Virtual Environment ─────────────── echo "" echo -e "${CYAN}[5/8] Setting up Python virtual environment...${NC}" if [ -d "$VENV_DIR" ]; then echo -e " ${GREEN}✓${NC} Virtual environment already exists" else python3 -m venv "$VENV_DIR" echo -e " ${GREEN}✓${NC} Virtual environment created" fi # Activate venv source "$VENV_DIR/bin/activate" echo -e " ${GREEN}✓${NC} Virtual environment activated" # Upgrade pip pip install --upgrade pip --quiet echo -e " ${GREEN}✓${NC} pip upgraded" # ── Step 6: Install Python Dependencies ───────────────────── echo "" echo -e "${CYAN}[6/8] Installing Python dependencies...${NC}" echo -e " ${YELLOW}This includes PyTorch, Whisper, and other ML packages...${NC}" pip install -r "$BACKEND_DIR/requirements.txt" --quiet 2>&1 | tail -5 echo -e " ${GREEN}✓${NC} Python dependencies installed" # ── Step 7: Download Whisper Model ────────────────────────── echo "" echo -e "${CYAN}[7/8] Pre-downloading Whisper STT model (base)...${NC}" python3 -c " import whisper print(' Downloading Whisper base model...') model = whisper.load_model('base') print(' ✓ Whisper base model ready') " 2>&1 | grep -v "FP16\|UserWarning" # ── Step 8: Create .env file ──────────────────────────────── echo "" echo -e "${CYAN}[8/8] Creating configuration...${NC}" if [ ! -f "$BACKEND_DIR/.env" ]; then cp "$PROJECT_DIR/.env.example" "$BACKEND_DIR/.env" echo -e " ${GREEN}✓${NC} .env file created from template" else echo -e " ${GREEN}✓${NC} .env file already exists" fi # Create data directories mkdir -p "$PROJECT_DIR/data" "$PROJECT_DIR/models" "$PROJECT_DIR/data/recordings" echo -e " ${GREEN}✓${NC} Data directories created" # ── Done ───────────────────────────────────────────────────── echo "" echo -e "${GREEN}╔══════════════════════════════════════════════════╗${NC}" echo -e "${GREEN}║ SETUP COMPLETE! 🎉 ║${NC}" echo -e "${GREEN}╚══════════════════════════════════════════════════╝${NC}" echo "" echo -e " To start Friday:" echo -e " ${CYAN}cd $PROJECT_DIR && bash scripts/start.sh${NC}" echo "" echo -e " Or use the CLI directly:" echo -e " ${CYAN}cd $BACKEND_DIR && source venv/bin/activate && python cli.py${NC}" echo "" echo -e " Dashboard will be at: ${BLUE}http://localhost:7777${NC}" echo ""