Compare commits

...

10 commits

Author SHA1 Message Date
2f040c1438
build: add Bazel BUILD file
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 23:50:55 +02:00
e58ffbc650
chore: commit pending changes before monorepo submodule conversion
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 22:52:49 +02:00
fbdde55b82 Prevent sleep on all devices (Ollama and Onyx)
Extracted pmset config into steps/step_sleep.sh and call it from
setup.sh, setup_ollama.sh, and setup_onyx.sh so both devices in a
split setup stay awake.
2026-04-24 13:08:33 +02:00
6e02572bd7 Replace ping sweep with direct parallel port scan across full subnet
Ping sweep + wait was the bottleneck: it blocked until all 254 pings
timed out before starting the port check. Now all 254 nc checks fire
simultaneously and we stop polling as soon as the first hit is written,
completing in ~1s instead of ~1 minute.
2026-04-24 11:49:32 +02:00
4564c637f4 Stop Ollama port scan as soon as first host is found 2026-04-24 11:46:48 +02:00
24014fd121 Expose Ollama on all network interfaces via launchd agent
By default Ollama only binds to 127.0.0.1, making it unreachable
from other devices. Install a launchd plist that sets OLLAMA_HOST=0.0.0.0
so the Ollama device is discoverable by the Onyx device on the network.
The agent also auto-starts Ollama at login.
2026-04-24 11:28:08 +02:00
5b895a19b4 Ping-sweep subnet before ARP lookup to find devices not yet in cache 2026-04-24 11:21:18 +02:00
9fa3efacf6 Show each device checked during Ollama scan; prompt user if not found 2026-04-24 11:16:21 +02:00
61a054f376 Speed up Ollama host detection using ARP table + parallel checks
Instead of sequentially probing all 254 IPs in the subnet (worst case
~4 minutes), read the ARP table for devices already visible on the
network and check all of them for port 11434 simultaneously. Completes
in roughly one nc timeout (~1s) regardless of network size.
2026-04-24 11:09:46 +02:00
fdab99ac79 Wait for Docker.app to appear before opening after install 2026-04-24 10:55:43 +02:00
9 changed files with 172 additions and 54 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

39
BUILD.bazel Normal file
View file

@ -0,0 +1,39 @@
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"],
)

View file

@ -50,6 +50,7 @@ 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
@ -73,6 +74,7 @@ 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

View file

@ -45,6 +45,7 @@ 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
@ -66,6 +67,7 @@ preflight_checks --skip-docker
install_homebrew install_homebrew
install_ollama install_ollama
setup_models setup_models
prevent_sleep
# ============================================================================= # =============================================================================
# Done # Done

View file

@ -64,6 +64,7 @@ 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
@ -77,36 +78,62 @@ 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
echo "" print_warning "Could not determine local IP address." >&2
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 else
echo "" 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
echo "" >&2
read -p "Enter the IP address of the Ollama device: " manual_ip <&2
echo "$manual_ip"
} }
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@ -128,6 +155,7 @@ 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
@ -137,11 +165,6 @@ 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

View file

@ -16,13 +16,19 @@ 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..."
if [ -d "/Applications/Docker.app" ]; then open -a Docker
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:"

View file

@ -1,6 +1,9 @@
#!/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"
@ -13,18 +16,55 @@ install_ollama() {
print_success "Ollama installed successfully" print_success "Ollama installed successfully"
fi fi
print_warning "Starting Ollama service..." # Register Ollama as a launchd agent so it:
if ! pgrep -x "ollama" > /dev/null; then # - starts automatically at login
nohup ollama serve > /tmp/ollama.log 2>&1 & # - listens on all interfaces (0.0.0.0) so other devices can reach it
sleep 3 print_warning "Configuring Ollama to listen on all network interfaces..."
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
if pgrep -x "ollama" > /dev/null; then # Stop any existing instance first so the new config takes effect
print_success "Ollama service started" if pgrep -x "ollama" > /dev/null; then
else print_warning "Restarting Ollama with network binding..."
print_warning "Ollama service may not have started properly" launchctl unload "$OLLAMA_PLIST" 2>/dev/null || true
echo " Check logs at: /tmp/ollama.log" pkill -x ollama 2>/dev/null || true
fi sleep 1
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_success "Ollama service already running" print_warning "Ollama service may not have started properly"
echo " Check logs at: /tmp/ollama.log"
fi fi
} }

View file

@ -20,8 +20,4 @@ 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"
} }

10
steps/step_sleep.sh Executable file
View file

@ -0,0 +1,10 @@
#!/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"
}