Compare commits
10 commits
93d3f67180
...
2f040c1438
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f040c1438 | |||
| e58ffbc650 | |||
| fbdde55b82 | |||
| 6e02572bd7 | |||
| 4564c637f4 | |||
| 24014fd121 | |||
| 5b895a19b4 | |||
| 9fa3efacf6 | |||
| 61a054f376 | |||
| fdab99ac79 |
9 changed files with 172 additions and 54 deletions
BIN
.DS_Store
vendored
Normal file
BIN
.DS_Store
vendored
Normal file
Binary file not shown.
39
BUILD.bazel
Normal file
39
BUILD.bazel
Normal 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"],
|
||||||
|
)
|
||||||
2
setup.sh
2
setup.sh
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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:"
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
10
steps/step_sleep.sh
Executable 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"
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue