Add self-deploying setup scripts for all sub-projects (P1-P8)
- Root setup.sh orchestrator with per-phase dispatch (./setup.sh p1..p8 | all | status) - Makefile convenience targets (make infra, make llm, make status, etc.) - scripts/common.sh: shared bash library for OS detection, Docker helpers, service management (launchd/systemd), package install, env management - .env.example + .gitignore: shared config template and secret exclusions P1 (homeai-infra): full implementation - docker-compose.yml: Uptime Kuma, code-server, n8n - Note: Home Assistant, Portainer, Gitea are pre-existing instances - setup.sh: Docker install, homeai network, container health checks P2 (homeai-llm): full implementation - Ollama native install with CUDA/ROCm/Metal auto-detection - launchd plist (macOS) + systemd service (Linux) for auto-start - scripts/pull-models.sh: idempotent model puller from manifest - scripts/benchmark.sh: tokens/sec measurement per model - Open WebUI on port 3030 (avoids Gitea :3000 conflict) P3-P8: working stubs with prerequisite checks and TODO sections Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
86
homeai-llm/scripts/pull-models.sh
Normal file
86
homeai-llm/scripts/pull-models.sh
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env bash
|
||||
# scripts/pull-models.sh — Pull all Ollama models from the manifest
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/pull-models.sh # pull all models
|
||||
# bash scripts/pull-models.sh nomic-embed-text # pull specific model
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
|
||||
source "${REPO_DIR}/scripts/common.sh"
|
||||
|
||||
MANIFEST="${SCRIPT_DIR}/../ollama-models.txt"
|
||||
|
||||
if ! command_exists ollama; then
|
||||
die "Ollama not found. Run: bash homeai-llm/setup.sh first."
|
||||
fi
|
||||
|
||||
if ! curl -sf http://localhost:11434 -o /dev/null; then
|
||||
die "Ollama is not running. Start it first."
|
||||
fi
|
||||
|
||||
# If a specific model is given as arg, just pull that
|
||||
if [[ $# -gt 0 ]]; then
|
||||
for model in "$@"; do
|
||||
log_info "Pulling $model..."
|
||||
ollama pull "$model"
|
||||
log_success "Pulled $model"
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Pull all models from manifest
|
||||
log_section "Pulling Ollama models"
|
||||
|
||||
total=0; pulled=0; skipped=0; failed=0
|
||||
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
# Skip comments and blank lines
|
||||
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
||||
[[ -z "${line// }" ]] && continue
|
||||
|
||||
model="${line%% *}" # strip any trailing comment
|
||||
total=$((total + 1))
|
||||
|
||||
# Check if model is already present
|
||||
if ollama list 2>/dev/null | grep -q "^${model%%:*}"; then
|
||||
tag="${model##*:}"
|
||||
model_name="${model%%:*}"
|
||||
if [[ "$tag" != "$model_name" ]]; then
|
||||
# Has explicit tag — check exact match
|
||||
if ollama list 2>/dev/null | grep -q "^${model_name}.*${tag}"; then
|
||||
log_info "Already present: $model — skipping"
|
||||
skipped=$((skipped + 1))
|
||||
continue
|
||||
fi
|
||||
else
|
||||
log_info "Already present: $model — skipping"
|
||||
skipped=$((skipped + 1))
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
|
||||
log_step "Pulling $model..."
|
||||
if ollama pull "$model"; then
|
||||
log_success "Pulled $model"
|
||||
pulled=$((pulled + 1))
|
||||
else
|
||||
log_error "Failed to pull $model"
|
||||
failed=$((failed + 1))
|
||||
fi
|
||||
|
||||
done < "$MANIFEST"
|
||||
|
||||
echo ""
|
||||
log_info "Pull complete: ${pulled} pulled, ${skipped} already present, ${failed} failed (of ${total} total)"
|
||||
|
||||
if [[ $failed -gt 0 ]]; then
|
||||
log_warn "Some models failed to pull. Check your internet connection and retry."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
log_info "Installed models:"
|
||||
ollama list
|
||||
Reference in New Issue
Block a user