Compare commits
No commits in common. "2f040c143842617c29507952a67b0ceda901ce81" and "93d3f67180eea97e320a26e307ef4c15dcb57071" have entirely different histories.
2f040c1438
...
93d3f67180
9 changed files with 54 additions and 172 deletions
BIN
.DS_Store
vendored
BIN
.DS_Store
vendored
Binary file not shown.
39
BUILD.bazel
39
BUILD.bazel
|
|
@ -1,39 +0,0 @@
|
||||||
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
|
|
||||||
|
|
||||||
# Each operational script exposed as a runnable Bazel target
|
|
||||||
# (e.g. `bazel run //riotsecure:setup`).
|
|
||||||
|
|
||||||
sh_binary(
|
|
||||||
name = "setup",
|
|
||||||
srcs = ["setup.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
sh_binary(
|
|
||||||
name = "setup_ollama",
|
|
||||||
srcs = ["setup_ollama.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
sh_binary(
|
|
||||||
name = "setup_onyx",
|
|
||||||
srcs = ["setup_onyx.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
sh_binary(
|
|
||||||
name = "check_status",
|
|
||||||
srcs = ["check-status.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
sh_binary(
|
|
||||||
name = "cleanup",
|
|
||||||
srcs = ["cleanup.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
sh_binary(
|
|
||||||
name = "fetch_content",
|
|
||||||
srcs = ["fetchContent.sh"],
|
|
||||||
)
|
|
||||||
|
|
||||||
sh_binary(
|
|
||||||
name = "update_models",
|
|
||||||
srcs = ["updateModels.sh"],
|
|
||||||
)
|
|
||||||
2
setup.sh
2
setup.sh
|
|
@ -50,7 +50,6 @@ source "$REPO/steps/step_onyx.sh"
|
||||||
source "$REPO/steps/step_models.sh"
|
source "$REPO/steps/step_models.sh"
|
||||||
source "$REPO/steps/step_webconfig.sh"
|
source "$REPO/steps/step_webconfig.sh"
|
||||||
source "$REPO/steps/step_rag.sh"
|
source "$REPO/steps/step_rag.sh"
|
||||||
source "$REPO/steps/step_sleep.sh"
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Main setup
|
# Main setup
|
||||||
|
|
@ -74,7 +73,6 @@ install_homebrew
|
||||||
install_ollama
|
install_ollama
|
||||||
install_docker
|
install_docker
|
||||||
install_onyx
|
install_onyx
|
||||||
prevent_sleep
|
|
||||||
setup_models
|
setup_models
|
||||||
web_config "host.docker.internal"
|
web_config "host.docker.internal"
|
||||||
rag_upload
|
rag_upload
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ source "$REPO/steps/preflight.sh"
|
||||||
source "$REPO/steps/step_homebrew.sh"
|
source "$REPO/steps/step_homebrew.sh"
|
||||||
source "$REPO/steps/step_ollama.sh"
|
source "$REPO/steps/step_ollama.sh"
|
||||||
source "$REPO/steps/step_models.sh"
|
source "$REPO/steps/step_models.sh"
|
||||||
source "$REPO/steps/step_sleep.sh"
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Main setup
|
# Main setup
|
||||||
|
|
@ -67,7 +66,6 @@ preflight_checks --skip-docker
|
||||||
install_homebrew
|
install_homebrew
|
||||||
install_ollama
|
install_ollama
|
||||||
setup_models
|
setup_models
|
||||||
prevent_sleep
|
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Done
|
# Done
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ source "$REPO/steps/step_docker.sh"
|
||||||
source "$REPO/steps/step_onyx.sh"
|
source "$REPO/steps/step_onyx.sh"
|
||||||
source "$REPO/steps/step_webconfig.sh"
|
source "$REPO/steps/step_webconfig.sh"
|
||||||
source "$REPO/steps/step_rag.sh"
|
source "$REPO/steps/step_rag.sh"
|
||||||
source "$REPO/steps/step_sleep.sh"
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Detect where Ollama is running
|
# Detect where Ollama is running
|
||||||
|
|
@ -78,62 +77,36 @@ detect_ollama_host() {
|
||||||
local LOCAL_IP
|
local LOCAL_IP
|
||||||
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 [ -z "$LOCAL_IP" ]; then
|
if [ -z "$LOCAL_IP" ]; then
|
||||||
print_warning "Could not determine local IP address." >&2
|
echo ""
|
||||||
else
|
return
|
||||||
local SUBNET
|
|
||||||
SUBNET=$(echo "$LOCAL_IP" | cut -d. -f1-3)
|
|
||||||
|
|
||||||
echo "" >&2
|
|
||||||
print_warning "Scanning ${SUBNET}.0/24 for Ollama (port 11434)..." >&2
|
|
||||||
|
|
||||||
local TMPFILE
|
|
||||||
TMPFILE=$(mktemp)
|
|
||||||
|
|
||||||
# Launch all 254 checks simultaneously
|
|
||||||
for i in $(seq 1 254); do
|
|
||||||
local ip="${SUBNET}.${i}"
|
|
||||||
echo -e " ${BLUE}→${NC} Checking $ip..." >&2
|
|
||||||
( nc -z -w 1 "$ip" 11434 2>/dev/null && echo "$ip" >> "$TMPFILE" ) &
|
|
||||||
done
|
|
||||||
|
|
||||||
# Poll every 200ms and stop as soon as the first result appears
|
|
||||||
while [ "$(jobs -rp | wc -l)" -gt 0 ]; do
|
|
||||||
if [ -s "$TMPFILE" ]; then
|
|
||||||
kill $(jobs -rp) 2>/dev/null || true
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 0.2
|
|
||||||
done
|
|
||||||
wait 2>/dev/null
|
|
||||||
|
|
||||||
local FOUND=()
|
|
||||||
while IFS= read -r ip; do
|
|
||||||
FOUND+=("$ip")
|
|
||||||
done < "$TMPFILE"
|
|
||||||
rm -f "$TMPFILE"
|
|
||||||
|
|
||||||
if [ ${#FOUND[@]} -eq 1 ]; then
|
|
||||||
echo "${FOUND[0]}"
|
|
||||||
return
|
|
||||||
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))]}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_warning "Ollama not found on any device in ${SUBNET}.0/24." >&2
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Nothing found — ask the user directly
|
local SUBNET
|
||||||
echo "" >&2
|
SUBNET=$(echo "$LOCAL_IP" | cut -d. -f1-3)
|
||||||
read -p "Enter the IP address of the Ollama device: " manual_ip <&2
|
|
||||||
echo "$manual_ip"
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
@ -155,7 +128,6 @@ preflight_checks
|
||||||
install_homebrew
|
install_homebrew
|
||||||
install_docker
|
install_docker
|
||||||
install_onyx
|
install_onyx
|
||||||
prevent_sleep
|
|
||||||
|
|
||||||
# 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
|
||||||
|
|
@ -165,6 +137,11 @@ else
|
||||||
print_warning "Detecting Ollama host..."
|
print_warning "Detecting Ollama host..."
|
||||||
OLLAMA_HOST=$(detect_ollama_host)
|
OLLAMA_HOST=$(detect_ollama_host)
|
||||||
|
|
||||||
|
if [ -z "$OLLAMA_HOST" ]; then
|
||||||
|
print_warning "Could not detect Ollama automatically."
|
||||||
|
read -p "Enter the IP address or hostname of the Ollama device: " OLLAMA_HOST
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$OLLAMA_HOST" = "host.docker.internal" ]; then
|
if [ "$OLLAMA_HOST" = "host.docker.internal" ]; then
|
||||||
print_success "Ollama detected on this machine (single-device mode)"
|
print_success "Ollama detected on this machine (single-device mode)"
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,13 @@ install_docker() {
|
||||||
softwareupdate --install-rosetta --agree-to-license
|
softwareupdate --install-rosetta --agree-to-license
|
||||||
print_success "Rosetta 2 ready"
|
print_success "Rosetta 2 ready"
|
||||||
|
|
||||||
print_warning "Waiting for Docker.app to appear in /Applications..."
|
|
||||||
local WAIT=0
|
|
||||||
while [ ! -d "/Applications/Docker.app" ]; do
|
|
||||||
if [ $WAIT -ge 30 ]; then
|
|
||||||
print_error "Docker.app not found in /Applications after 30s. Please install Docker Desktop manually."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sleep 2
|
|
||||||
WAIT=$((WAIT + 2))
|
|
||||||
done
|
|
||||||
|
|
||||||
print_warning "Opening Docker Desktop..."
|
print_warning "Opening Docker Desktop..."
|
||||||
open -a Docker
|
if [ -d "/Applications/Docker.app" ]; then
|
||||||
|
open -a Docker
|
||||||
|
else
|
||||||
|
print_error "Docker.app not found in /Applications. Please install Docker Desktop manually."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "MANUAL STEP REQUIRED:"
|
echo "MANUAL STEP REQUIRED:"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Step: Install and start Ollama. Source common.sh before sourcing this file.
|
# Step: Install and start Ollama. Source common.sh before sourcing this file.
|
||||||
|
|
||||||
# Launchd plist that starts Ollama on all interfaces at login.
|
|
||||||
OLLAMA_PLIST="$HOME/Library/LaunchAgents/com.ollama.serve.plist"
|
|
||||||
|
|
||||||
install_ollama() {
|
install_ollama() {
|
||||||
print_step "Installing Ollama"
|
print_step "Installing Ollama"
|
||||||
|
|
||||||
|
|
@ -16,55 +13,18 @@ install_ollama() {
|
||||||
print_success "Ollama installed successfully"
|
print_success "Ollama installed successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Register Ollama as a launchd agent so it:
|
print_warning "Starting Ollama service..."
|
||||||
# - starts automatically at login
|
if ! pgrep -x "ollama" > /dev/null; then
|
||||||
# - listens on all interfaces (0.0.0.0) so other devices can reach it
|
nohup ollama serve > /tmp/ollama.log 2>&1 &
|
||||||
print_warning "Configuring Ollama to listen on all network interfaces..."
|
sleep 3
|
||||||
mkdir -p "$HOME/Library/LaunchAgents"
|
|
||||||
cat > "$OLLAMA_PLIST" <<EOF
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>Label</key>
|
|
||||||
<string>com.ollama.serve</string>
|
|
||||||
<key>ProgramArguments</key>
|
|
||||||
<array>
|
|
||||||
<string>/usr/local/bin/ollama</string>
|
|
||||||
<string>serve</string>
|
|
||||||
</array>
|
|
||||||
<key>EnvironmentVariables</key>
|
|
||||||
<dict>
|
|
||||||
<key>OLLAMA_HOST</key>
|
|
||||||
<string>0.0.0.0:11434</string>
|
|
||||||
</dict>
|
|
||||||
<key>RunAtLoad</key>
|
|
||||||
<true/>
|
|
||||||
<key>KeepAlive</key>
|
|
||||||
<true/>
|
|
||||||
<key>StandardOutPath</key>
|
|
||||||
<string>/tmp/ollama.log</string>
|
|
||||||
<key>StandardErrorPath</key>
|
|
||||||
<string>/tmp/ollama.log</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Stop any existing instance first so the new config takes effect
|
if pgrep -x "ollama" > /dev/null; then
|
||||||
if pgrep -x "ollama" > /dev/null; then
|
print_success "Ollama service started"
|
||||||
print_warning "Restarting Ollama with network binding..."
|
else
|
||||||
launchctl unload "$OLLAMA_PLIST" 2>/dev/null || true
|
print_warning "Ollama service may not have started properly"
|
||||||
pkill -x ollama 2>/dev/null || true
|
echo " Check logs at: /tmp/ollama.log"
|
||||||
sleep 1
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
launchctl load "$OLLAMA_PLIST"
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
if pgrep -x "ollama" > /dev/null; then
|
|
||||||
print_success "Ollama service started (listening on 0.0.0.0:11434)"
|
|
||||||
else
|
else
|
||||||
print_warning "Ollama service may not have started properly"
|
print_success "Ollama service already running"
|
||||||
echo " Check logs at: /tmp/ollama.log"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,8 @@ install_onyx() {
|
||||||
|
|
||||||
print_success "Onyx installation complete"
|
print_success "Onyx installation complete"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
print_warning "Configuring power settings to prevent sleep..."
|
||||||
|
sudo pmset -a sleep 0 disksleep 0
|
||||||
|
print_success "Sleep prevention configured"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Step: Prevent the machine from sleeping. Source common.sh before sourcing this file.
|
|
||||||
|
|
||||||
prevent_sleep() {
|
|
||||||
print_step "Preventing Sleep"
|
|
||||||
|
|
||||||
print_warning "Configuring power settings to prevent sleep..."
|
|
||||||
sudo pmset -a sleep 0 disksleep 0
|
|
||||||
print_success "Sleep prevention configured"
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue