Clone repo before sourcing step files in all setup scripts

setup.sh, setup_onyx.sh, and setup_ollama.sh can all be run via
curl | bash without a local checkout. They now clone (or pull)
~/riotsecure first with inline minimal helpers, then source step
files from the cloned repo. The setup_repo step is removed from the
main flow since the clone already happens at the top.
This commit is contained in:
cediackermann 2026-04-24 10:11:30 +02:00
parent 3be9b5604d
commit 8a06384cc1
3 changed files with 155 additions and 106 deletions

View file

@ -3,23 +3,48 @@
# For a split setup (Onyx on one machine, Ollama on another) use: # For a split setup (Onyx on one machine, Ollama on another) use:
# setup_onyx.sh — on the Onyx device # setup_onyx.sh — on the Onyx device
# setup_ollama.sh — on the Ollama device # setup_ollama.sh — on the Ollama device
#
# Usage (one-liner):
# bash <(curl -fsSL https://raw.githubusercontent.com/cediackermann/riotsecure/main/setup.sh)
set -e set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Minimal helpers needed before the repo is cloned
source "$SCRIPT_DIR/steps/common.sh" RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
source "$SCRIPT_DIR/steps/preflight.sh" _info() { echo -e "${BLUE}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_homebrew.sh" _success() { echo -e "${GREEN}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_ollama.sh" _warning() { echo -e "${YELLOW}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_repo.sh" _error() { echo -e "${RED}$1${NC}"; exit 1; }
source "$SCRIPT_DIR/steps/step_docker.sh"
source "$SCRIPT_DIR/steps/step_onyx.sh"
source "$SCRIPT_DIR/steps/step_models.sh"
source "$SCRIPT_DIR/steps/step_webconfig.sh"
source "$SCRIPT_DIR/steps/step_rag.sh"
check_mac [[ "$OSTYPE" != "darwin"* ]] && _error "This script is designed for macOS."
# ---------------------------------------------------------------------------
# Clone or update the repo first so step files are available
# ---------------------------------------------------------------------------
_info "Setting up riotsecure repository..."
if [ -d ~/riotsecure ]; then
_warning "Repository already exists — updating..."
git -C ~/riotsecure pull
else
git clone https://github.com/cediackermann/riotsecure.git ~/riotsecure
fi
_success "Repository ready at ~/riotsecure"
# Source all shared step files from the cloned repo
REPO="$HOME/riotsecure"
source "$REPO/steps/common.sh"
source "$REPO/steps/preflight.sh"
source "$REPO/steps/step_homebrew.sh"
source "$REPO/steps/step_ollama.sh"
source "$REPO/steps/step_docker.sh"
source "$REPO/steps/step_onyx.sh"
source "$REPO/steps/step_models.sh"
source "$REPO/steps/step_webconfig.sh"
source "$REPO/steps/step_rag.sh"
# ---------------------------------------------------------------------------
# Main setup
# ---------------------------------------------------------------------------
echo "" echo ""
echo -e "${BLUE}RIoT Secure — Full Single-Device Setup${NC}" echo -e "${BLUE}RIoT Secure — Full Single-Device Setup${NC}"
echo "" echo ""
@ -37,7 +62,6 @@ preflight_checks
install_homebrew install_homebrew
install_ollama install_ollama
setup_repo
install_docker install_docker
install_onyx install_onyx
setup_models setup_models
@ -54,8 +78,8 @@ echo -e "${GREEN}✓ All automated steps completed successfully!${NC}"
echo "" echo ""
echo -e "Access the web interface at: ${BLUE}http://localhost:3000${NC}" echo -e "Access the web interface at: ${BLUE}http://localhost:3000${NC}"
LOCAL_IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "Unable to detect") LOCAL_IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "")
if [ "$LOCAL_IP" != "Unable to detect" ]; then if [ -n "$LOCAL_IP" ]; then
echo -e "From other devices on the network: ${BLUE}http://${LOCAL_IP}:3000${NC}" echo -e "From other devices on the network: ${BLUE}http://${LOCAL_IP}:3000${NC}"
fi fi

View file

@ -3,20 +3,43 @@
# Run this on the machine that will host AI models only. # Run this on the machine that will host AI models only.
# No Docker required on this device. # No Docker required on this device.
# #
# Usage: ./setup_ollama.sh # Usage (one-liner):
# bash <(curl -fsSL https://raw.githubusercontent.com/cediackermann/riotsecure/main/setup_ollama.sh)
set -e set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Minimal helpers needed before the repo is cloned
source "$SCRIPT_DIR/steps/common.sh" RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
source "$SCRIPT_DIR/steps/preflight.sh" _info() { echo -e "${BLUE}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_homebrew.sh" _success() { echo -e "${GREEN}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_ollama.sh" _warning() { echo -e "${YELLOW}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_repo.sh" _error() { echo -e "${RED}$1${NC}"; exit 1; }
source "$SCRIPT_DIR/steps/step_models.sh"
check_mac [[ "$OSTYPE" != "darwin"* ]] && _error "This script is designed for macOS."
# ---------------------------------------------------------------------------
# Clone or update the repo first so step files are available
# ---------------------------------------------------------------------------
_info "Setting up riotsecure repository..."
if [ -d ~/riotsecure ]; then
_warning "Repository already exists — updating..."
git -C ~/riotsecure pull
else
git clone https://github.com/cediackermann/riotsecure.git ~/riotsecure
fi
_success "Repository ready at ~/riotsecure"
# Source all shared step files from the cloned repo
REPO="$HOME/riotsecure"
source "$REPO/steps/common.sh"
source "$REPO/steps/preflight.sh"
source "$REPO/steps/step_homebrew.sh"
source "$REPO/steps/step_ollama.sh"
source "$REPO/steps/step_models.sh"
# ---------------------------------------------------------------------------
# Main setup
# ---------------------------------------------------------------------------
echo "" echo ""
echo -e "${BLUE}RIoT Secure — Ollama Device Setup${NC}" echo -e "${BLUE}RIoT Secure — Ollama Device Setup${NC}"
echo "This machine will run Ollama and serve AI models to the Onyx device." echo "This machine will run Ollama and serve AI models to the Onyx device."
@ -32,7 +55,6 @@ echo ""
preflight_checks --skip-docker preflight_checks --skip-docker
install_homebrew install_homebrew
setup_repo
install_ollama install_ollama
setup_models setup_models
@ -44,22 +66,21 @@ print_step "Ollama Device Setup Complete!"
echo "" echo ""
echo -e "${GREEN}✓ Ollama is running and models are loaded.${NC}" echo -e "${GREEN}✓ Ollama is running and models are loaded.${NC}"
echo "" 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 "") LOCAL_IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "")
if [ -n "$LOCAL_IP" ]; then if [ -n "$LOCAL_IP" ]; then
echo -e "${BLUE}===================================================${NC}" echo -e "${BLUE}===================================================${NC}"
echo -e "${GREEN} Run this command on the Onyx device:${NC}" echo -e "${GREEN} Run this command on the Onyx device:${NC}"
echo "" echo ""
echo -e " ${YELLOW}./setup_onyx.sh --ollama-host ${LOCAL_IP}${NC}" echo -e " ${YELLOW}bash <(curl -fsSL https://raw.githubusercontent.com/cediackermann/riotsecure/main/setup_onyx.sh) --ollama-host ${LOCAL_IP}${NC}"
echo "" echo ""
echo -e "${BLUE}===================================================${NC}" echo -e "${BLUE}===================================================${NC}"
else else
print_warning "Could not detect local IP address automatically." print_warning "Could not detect local IP address automatically."
echo " Find it manually with: ipconfig getifaddr en0" echo " Find it manually with: ipconfig getifaddr en0"
echo " Then on the Onyx device run:" echo " Then on the Onyx device run:"
echo -e " ${YELLOW}./setup_onyx.sh --ollama-host <this-machine-IP>${NC}" echo -e " ${YELLOW}bash <(curl -fsSL https://raw.githubusercontent.com/cediackermann/riotsecure/main/setup_onyx.sh) --ollama-host <this-machine-IP>${NC}"
fi fi
echo "" echo ""

View file

@ -3,84 +3,22 @@
# Run this on the machine that will host the Onyx web interface. # Run this on the machine that will host the Onyx web interface.
# Docker is required on this device; Ollama is NOT installed here. # Docker is required on this device; Ollama is NOT installed here.
# #
# Usage: # Usage (one-liner):
# ./setup_onyx.sh # auto-detect Ollama host # bash <(curl -fsSL https://raw.githubusercontent.com/cediackermann/riotsecure/main/setup_onyx.sh)
# ./setup_onyx.sh --ollama-host <IP> # override with a specific host # bash <(curl -fsSL https://raw.githubusercontent.com/cediackermann/riotsecure/main/setup_onyx.sh) --ollama-host <IP>
set -e set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Minimal helpers needed before the repo is cloned
source "$SCRIPT_DIR/steps/common.sh" RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
source "$SCRIPT_DIR/steps/preflight.sh" _info() { echo -e "${BLUE}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_homebrew.sh" _success() { echo -e "${GREEN}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_repo.sh" _warning() { echo -e "${YELLOW}$1${NC}"; }
source "$SCRIPT_DIR/steps/step_docker.sh" _error() { echo -e "${RED}$1${NC}"; exit 1; }
source "$SCRIPT_DIR/steps/step_onyx.sh"
source "$SCRIPT_DIR/steps/step_webconfig.sh"
source "$SCRIPT_DIR/steps/step_rag.sh"
check_mac [[ "$OSTYPE" != "darwin"* ]] && _error "This script is designed for macOS."
# --------------------------------------------------------------------------- # Parse arguments before cloning so --ollama-host is available throughout
# Detect where Ollama is running
# ---------------------------------------------------------------------------
detect_ollama_host() {
# 1. Check if Ollama is reachable on the Docker host (single-device)
if curl -sf --connect-timeout 2 http://host.docker.internal:11434 >/dev/null 2>&1; then
echo "host.docker.internal"
return
fi
# 2. Scan the local /24 subnet for port 11434
local LOCAL_IP
LOCAL_IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "")
if [ -z "$LOCAL_IP" ]; then
echo ""
return
fi
local SUBNET
SUBNET=$(echo "$LOCAL_IP" | cut -d. -f1-3)
print_warning "Ollama not found locally — scanning ${SUBNET}.0/24 for Ollama..."
local FOUND=()
for i in $(seq 1 254); do
(nc -z -w 1 "${SUBNET}.${i}" 11434 2>/dev/null && echo "${SUBNET}.${i}") &
done
# Collect results as background jobs finish
while IFS= read -r line; do
FOUND+=("$line")
done < <(wait; jobs -p | xargs -I{} wait {} 2>/dev/null; true)
# Re-run synchronously to get output (background approach above doesn't capture stdout cleanly)
FOUND=()
for i in $(seq 1 254); do
if nc -z -w 1 "${SUBNET}.${i}" 11434 2>/dev/null; then
FOUND+=("${SUBNET}.${i}")
fi
done
if [ ${#FOUND[@]} -eq 1 ]; then
echo "${FOUND[0]}"
elif [ ${#FOUND[@]} -gt 1 ]; then
# Multiple hosts found — let the user pick
echo "" >&2
print_warning "Multiple hosts with Ollama found:" >&2
for i in "${!FOUND[@]}"; do
echo " $((i+1))) ${FOUND[$i]}" >&2
done
echo "" >&2
read -p "Select the Ollama host (1-${#FOUND[@]}): " pick >&2
echo "${FOUND[$((pick-1))]}"
else
echo ""
fi
}
# ---------------------------------------------------------------------------
# Parse arguments
# ---------------------------------------------------------------------------
OLLAMA_HOST_OVERRIDE="" OLLAMA_HOST_OVERRIDE=""
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
@ -96,6 +34,75 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
# ---------------------------------------------------------------------------
# Clone or update the repo first so step files are available
# ---------------------------------------------------------------------------
_info "Setting up riotsecure repository..."
if [ -d ~/riotsecure ]; then
_warning "Repository already exists — updating..."
git -C ~/riotsecure pull
else
git clone https://github.com/cediackermann/riotsecure.git ~/riotsecure
fi
_success "Repository ready at ~/riotsecure"
# Source all shared step files from the cloned repo
REPO="$HOME/riotsecure"
source "$REPO/steps/common.sh"
source "$REPO/steps/preflight.sh"
source "$REPO/steps/step_homebrew.sh"
source "$REPO/steps/step_docker.sh"
source "$REPO/steps/step_onyx.sh"
source "$REPO/steps/step_webconfig.sh"
source "$REPO/steps/step_rag.sh"
# ---------------------------------------------------------------------------
# Detect where Ollama is running
# ---------------------------------------------------------------------------
detect_ollama_host() {
if curl -sf --connect-timeout 2 http://host.docker.internal:11434 >/dev/null 2>&1; then
echo "host.docker.internal"
return
fi
local LOCAL_IP
LOCAL_IP=$(ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1 2>/dev/null || echo "")
if [ -z "$LOCAL_IP" ]; then
echo ""
return
fi
local SUBNET
SUBNET=$(echo "$LOCAL_IP" | cut -d. -f1-3)
print_warning "Ollama not found locally — scanning ${SUBNET}.0/24 for Ollama..."
local FOUND=()
for i in $(seq 1 254); do
if nc -z -w 1 "${SUBNET}.${i}" 11434 2>/dev/null; then
FOUND+=("${SUBNET}.${i}")
fi
done
if [ ${#FOUND[@]} -eq 1 ]; then
echo "${FOUND[0]}"
elif [ ${#FOUND[@]} -gt 1 ]; then
echo "" >&2
print_warning "Multiple hosts with Ollama found:" >&2
for i in "${!FOUND[@]}"; do
echo " $((i+1))) ${FOUND[$i]}" >&2
done
echo "" >&2
read -p "Select the Ollama host (1-${#FOUND[@]}): " pick >&2
echo "${FOUND[$((pick-1))]}"
else
echo ""
fi
}
# ---------------------------------------------------------------------------
# Main setup
# ---------------------------------------------------------------------------
echo "" echo ""
echo -e "${BLUE}RIoT Secure — Onyx Device Setup${NC}" echo -e "${BLUE}RIoT Secure — Onyx Device Setup${NC}"
echo "" echo ""
@ -110,13 +117,10 @@ echo ""
preflight_checks preflight_checks
install_homebrew install_homebrew
setup_repo
install_docker install_docker
install_onyx install_onyx
# --------------------------------------------------------------------------- # Resolve Ollama host after Docker is running so host.docker.internal works
# Resolve Ollama host (after Docker is running so host.docker.internal works)
# ---------------------------------------------------------------------------
if [ -n "$OLLAMA_HOST_OVERRIDE" ]; then if [ -n "$OLLAMA_HOST_OVERRIDE" ]; then
OLLAMA_HOST="$OLLAMA_HOST_OVERRIDE" OLLAMA_HOST="$OLLAMA_HOST_OVERRIDE"
echo -e "Using provided Ollama host: ${BLUE}${OLLAMA_HOST}${NC}" echo -e "Using provided Ollama host: ${BLUE}${OLLAMA_HOST}${NC}"