riotsecure/setup_ollama.sh
cediackermann ef27add5d3 Refactor setup into modular steps; add split-device support
- Extract shared helpers into steps/common.sh (colors, print_*, wait_for_user, ask_confirmation)
- Split each install step into its own sourced script under steps/
- setup.sh now sources step files instead of duplicating logic
- Add setup_ollama.sh: Ollama-only device setup (no Docker)
- Add setup_onyx.sh: Onyx-only device setup with auto-detection of Ollama host via network scan
- setup_ollama.sh prints ready-to-run setup_onyx.sh command with detected IP at completion
- Docker memory recommendation is MAX when machine has <20 GB RAM, 20 GB otherwise
- cleanup.sh and check-status.sh source steps/common.sh with inline curl fallback
- check-status.sh detects device mode (single/ollama/onyx) and skips irrelevant checks
- cleanup.sh reinstall message lists all three setup one-liners
- README updated with split-device one-liner commands
2026-04-24 09:53:33 +02:00

70 lines
2.2 KiB
Bash
Executable file

#!/bin/bash
# Setup script for the Ollama device.
# Run this on the machine that will host AI models only.
# No Docker required on this device.
#
# Usage: ./setup_ollama.sh
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/steps/common.sh"
source "$SCRIPT_DIR/steps/preflight.sh"
source "$SCRIPT_DIR/steps/step_homebrew.sh"
source "$SCRIPT_DIR/steps/step_ollama.sh"
source "$SCRIPT_DIR/steps/step_repo.sh"
source "$SCRIPT_DIR/steps/step_models.sh"
check_mac
echo ""
echo -e "${BLUE}RIoT Secure — Ollama Device Setup${NC}"
echo "This machine will run Ollama and serve AI models to the Onyx device."
echo ""
echo "Estimated installation time: 10-20 minutes"
echo ""
echo "The following will be installed/configured:"
echo " • Homebrew (package manager)"
echo " • Ollama (AI model runtime)"
echo " • RIoT AI models (several GB download)"
echo ""
preflight_checks --skip-docker
install_homebrew
setup_repo
install_ollama
setup_models
# =============================================================================
# Done
# =============================================================================
print_step "Ollama Device Setup Complete!"
echo ""
echo -e "${GREEN}✓ Ollama is running and models are loaded.${NC}"
echo ""
echo "Next steps:"
echo " 1. Note this machine's local IP address:"
LOCAL_IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "")
if [ -n "$LOCAL_IP" ]; then
echo -e "${BLUE}===================================================${NC}"
echo -e "${GREEN} Run this command on the Onyx device:${NC}"
echo ""
echo -e " ${YELLOW}./setup_onyx.sh --ollama-host ${LOCAL_IP}${NC}"
echo ""
echo -e "${BLUE}===================================================${NC}"
else
print_warning "Could not detect local IP address automatically."
echo " Find it manually with: ipconfig getifaddr en0"
echo " Then on the Onyx device run:"
echo -e " ${YELLOW}./setup_onyx.sh --ollama-host <this-machine-IP>${NC}"
fi
echo ""
echo "Useful commands:"
echo " - List Ollama models: ollama list"
echo " - Update models: cd ~/riotsecure && ./updateModels.sh modelfiles"
echo " - View Ollama logs: tail -f /tmp/ollama.log"
echo ""