feat: cross-platform install scripts + hub Docker + macOS Full Disk Access 📦🐳🔐

Maximum-easy adoption:
- install.sh (macOS+Linux): curl|sh friendly. Detects OS/arch, resolves the
  binary (env → local dist/ → download → go-build fallback), lets you pick the
  install dir (smart default + prompt on a TTY), and optionally sets up a
  KEEP-ALIVE auto-restart service — launchd KeepAlive (mac) / systemd
  Restart=always user unit (linux). Flags + env for non-interactive use.
- install.ps1 (Windows): copy exe + user PATH + optional restart-on-failure
  Scheduled Task at logon.
- Hub Docker: Dockerfile (multi-stage, static CGO-free, alpine, healthcheck-
  ready) + docker-compose.yml (restart: unless-stopped = self-heal, named
  volume, dashboard-ready, optional autoheal profile for unhealthy-restart) +
  .dockerignore — drop-in for TrueNAS/Synology/unRAID.
- macOS Full Disk Access: 'devbox doctor' now tests the ACTUAL protected mount
  paths (~/Desktop, ~/Documents, ~/Downloads, iCloud) and flags any it can't
  read, with the exact System Settings fix + a deep link; install.sh points to
  it on mac. Windows install.ps1 notes Controlled Folder Access (off by default).
  (TCC.db probe was unreliable across macOS versions — testing the real mounts
  is honest + version-proof.) shellcheck-clean; 18 pkgs -race green; win+mac build.
This commit is contained in:
shoemoney 2026-06-23 13:05:16 -05:00
parent 9f662cd476
commit 44e142fdf0
9 changed files with 536 additions and 0 deletions

14
.dockerignore Normal file
View file

@ -0,0 +1,14 @@
# keep the build context small + reproducible. NB: do NOT exclude .go sources or
# internal/hub/dashboard/index.html (it's go:embed'd into the hub binary).
.git
.gitignore
.claude
.playwright-mcp
dist
bin
docs/images
*.png
*.pre-v2.bak
README.md
install.ps1
deploy

28
Dockerfile Normal file
View file

@ -0,0 +1,28 @@
# devbox hub — multi-stage, static (CGO-free, pure-Go sqlite), tiny final image.
# Build: docker build -t devbox-hub .
# Run: docker run -d --restart unless-stopped -p 8088:8088 -v devbox:/data devbox-hub
# (or just `docker compose up -d` — see docker-compose.yml)
FROM golang:1.26-alpine AS build
WORKDIR /src
# cache deps separately from source for faster rebuilds
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG VERSION=docker
# CGO off -> a fully static binary that runs on scratch/alpine without libc.
RUN CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" \
-o /out/devbox-hub ./cmd/devbox-hub
FROM alpine:3.20
# ca-certificates + tzdata for correct TLS/timestamps; wget (busybox) backs the healthcheck.
RUN apk add --no-cache ca-certificates tzdata && adduser -D -u 10001 devbox
COPY --from=build /out/devbox-hub /usr/local/bin/devbox-hub
USER devbox
VOLUME /data
# 8088 = hub API · 8099 = live dashboard (only reachable if you enable --dashboard)
EXPOSE 8088 8099
# ENTRYPOINT is just the binary so `command:` / `docker run … <args>` can tweak flags
# (e.g. add --dashboard). Default CMD serves the hub on all interfaces.
ENTRYPOINT ["devbox-hub"]
CMD ["serve", "--data", "/data", "--listen", "0.0.0.0:8088"]

56
cmd/devbox/fda_darwin.go Normal file
View file

@ -0,0 +1,56 @@
//go:build darwin
package main
import (
"os"
"path/filepath"
"strings"
"git.shoemoney.ai/shoemoney/devbox/internal/config"
)
// protectedMounts returns the local mount paths that live under a macOS TCC-
// protected directory (Desktop/Documents/Downloads/iCloud). A daemon can't sync
// these without Full Disk Access — and being a background agent, it can't even
// show the per-folder prompt, so it just silently fails until FDA is granted.
func protectedMounts(mounts []config.Mount) []string {
home, err := os.UserHomeDir()
if err != nil {
return nil
}
guarded := []string{
filepath.Join(home, "Desktop"),
filepath.Join(home, "Documents"),
filepath.Join(home, "Downloads"),
filepath.Join(home, "Library", "Mobile Documents"), // iCloud Drive
}
var out []string
for _, m := range mounts {
abs, err := filepath.Abs(m.Local)
if err != nil {
continue
}
for _, g := range guarded {
if abs == g || strings.HasPrefix(abs, g+string(os.PathSeparator)) {
out = append(out, m.Local)
break
}
}
}
return out
}
// blockedByTCC returns the protected paths this process currently CANNOT read
// (permission denied) — the honest signal that Full Disk Access is missing, since
// it tests the exact dirs we sync rather than a TCC.db probe that varies by macOS
// version. A path that reads fine, or doesn't exist yet, is not reported.
func blockedByTCC(paths []string) []string {
var blocked []string
for _, p := range paths {
if _, err := os.ReadDir(p); err != nil && os.IsPermission(err) {
blocked = append(blocked, p)
}
}
return blocked
}

11
cmd/devbox/fda_other.go Normal file
View file

@ -0,0 +1,11 @@
//go:build !darwin
package main
import "git.shoemoney.ai/shoemoney/devbox/internal/config"
// Full Disk Access is a macOS concept; elsewhere these are no-ops. (Windows has a
// loose analog — Controlled Folder Access — but it's off by default; install.ps1
// notes how to allowlist devbox if a user has it on.)
func protectedMounts([]config.Mount) []string { return nil }
func blockedByTCC([]string) []string { return nil }

32
cmd/devbox/fda_test.go Normal file
View file

@ -0,0 +1,32 @@
//go:build darwin
package main
import (
"os"
"path/filepath"
"testing"
"git.shoemoney.ai/shoemoney/devbox/internal/config"
)
func TestProtectedMounts(t *testing.T) {
home, err := os.UserHomeDir()
if err != nil {
t.Skip("no home dir")
}
mounts := []config.Mount{
{Local: filepath.Join(home, "Documents", "work")},
{Local: filepath.Join(home, "Desktop")},
{Local: "/tmp/devbox-not-protected"},
{Local: filepath.Join(home, "Library", "Mobile Documents", "iCloud~x")},
}
got := protectedMounts(mounts)
if len(got) != 3 {
t.Fatalf("protectedMounts = %v, want 3 (Documents, Desktop, iCloud — not /tmp)", got)
}
// A readable dir is never reported as TCC-blocked.
if b := blockedByTCC([]string{t.TempDir()}); len(b) != 0 {
t.Fatalf("a readable dir was reported blocked: %v", b)
}
}

View file

@ -887,6 +887,22 @@ func doctorCmd() *cobra.Command {
} }
_ = os.RemoveAll(probe) _ = os.RemoveAll(probe)
// macOS Full Disk Access — needed to sync TCC-protected folders
// (~/Desktop, ~/Documents, ~/Downloads, iCloud). A background daemon
// can't show the per-folder prompt, so without FDA those mounts fail
// silently. We test the actual protected mounts (honest, version-proof):
// only the ones we'd really sync, and only flag the ones truly blocked.
if prot := protectedMounts(d.Mounts); len(prot) > 0 {
if blocked := blockedByTCC(prot); len(blocked) == 0 {
check(true, false, "full disk access", "protected mounts readable ("+strings.Join(prot, ", ")+")")
} else {
exe, _ := os.Executable()
check(false, false, "full disk access", "NOT granted — can't read "+strings.Join(blocked, ", ")+
"\n fix: System Settings → Privacy & Security → Full Disk Access → + add "+exe+
"\n open it: open \"x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles\"")
}
}
// Mounts: dir exists + writable. // Mounts: dir exists + writable.
check(len(d.Mounts) > 0, len(d.Mounts) == 0, "mounts", fmt.Sprintf("%d configured", len(d.Mounts))) check(len(d.Mounts) > 0, len(d.Mounts) == 0, "mounts", fmt.Sprintf("%d configured", len(d.Mounts)))
for _, m := range d.Mounts { for _, m := range d.Mounts {

44
docker-compose.yml Normal file
View file

@ -0,0 +1,44 @@
# devbox hub — drop-in for a NAS (TrueNAS SCALE, Synology, unRAID, any Docker host).
#
# docker compose up -d --build # hub on :8088, data persisted, self-healing
# docker compose exec hub devbox-hub token --data /data # mint a join token
# docker compose logs -f hub
#
# Devices then: devbox setup (point them at http://<nas-ip>:8088)
services:
hub:
build: .
# Prefer a published image once you have one:
# image: git.shoemoney.ai/shoemoney/devbox-hub:latest
container_name: devbox-hub
restart: unless-stopped # keep-alive + auto-restart + recover (crash & reboot)
ports:
- "8088:8088" # hub API
# - "8099:8099" # live dashboard — uncomment AND enable it in `command:` below
volumes:
- devbox-data:/data # snapshots, blobs, token DB — survives upgrades
# Default serves the hub. To enable the live dashboard, swap in this command:
# command: ["serve","--data","/data","--listen","0.0.0.0:8088","--dashboard","--dashboard-addr","0.0.0.0:8099"]
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8088/metrics"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
# Optional self-heal: restarts the hub if its healthcheck goes unhealthy (Docker's
# restart policy only catches crashes, not a wedged-but-running process). Enable with:
# docker compose --profile selfheal up -d
autoheal:
image: willfarrell/autoheal:latest
container_name: devbox-autoheal
restart: unless-stopped
profiles: ["selfheal"]
environment:
AUTOHEAL_CONTAINER_LABEL: all
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes:
devbox-data:

122
install.ps1 Normal file
View file

@ -0,0 +1,122 @@
#Requires -Version 5
<#
.SYNOPSIS
devbox installer for Windows. Installs devbox.exe to a location you choose and
(optionally) registers a keep-alive Scheduled Task that runs the sync daemon at
logon and restarts it on failure.
.EXAMPLE
irm https://git.shoemoney.ai/shoemoney/devbox/raw/branch/main/install.ps1 | iex
.\install.ps1 -BinDir "$env:LOCALAPPDATA\Programs\devbox" -Service
.\install.ps1 -Hub # also install devbox-hub.exe
#>
param(
[string]$BinDir = $env:DEVBOX_BIN_DIR,
[switch]$Hub,
[switch]$Service,
[switch]$NoService,
[string]$ReleaseUrl = $(if ($env:DEVBOX_RELEASE_URL) { $env:DEVBOX_RELEASE_URL } else { "https://git.shoemoney.ai/shoemoney/devbox/releases/download/latest" })
)
$ErrorActionPreference = "Stop"
function Say($m) { Write-Host $m }
function Die($m) { Write-Error $m; exit 1 }
$arch = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "amd64" }
Say "📦 devbox installer — detected windows/$arch"
$scriptDir = if ($PSScriptRoot) { $PSScriptRoot } else { (Get-Location).Path }
$tmp = Join-Path $env:TEMP ("devbox-install-" + [System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Path $tmp -Force | Out-Null
$haveGo = [bool](Get-Command go -ErrorAction SilentlyContinue)
# Resolve a binary: explicit env, local dist\, download, or `go build`.
function Resolve-Bin($name) {
$envVar = ($name.ToUpper().Replace("-", "_")) + "_BIN" # devbox -> DEVBOX_BIN
$explicit = [Environment]::GetEnvironmentVariable($envVar)
if ($explicit -and (Test-Path $explicit)) { return $explicit }
foreach ($d in @("$scriptDir\dist", "$scriptDir\..\dist", ".\dist")) {
$cand = Get-ChildItem -Path $d -Filter "${name}_*_windows_${arch}.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($cand) { return $cand.FullName }
}
$dest = Join-Path $tmp "$name.exe"
try {
Invoke-WebRequest -Uri "$ReleaseUrl/${name}_windows_${arch}.exe" -OutFile $dest -UseBasicParsing
if ((Get-Item $dest).Length -gt 0) { return $dest }
} catch { }
if ($haveGo -and (Test-Path "$scriptDir\go.mod")) {
Say " building $name from source (go)..."
$env:CGO_ENABLED = "0"
Push-Location $scriptDir
try { & go build -o $dest "./cmd/$name"; if ($LASTEXITCODE -ne 0) { throw } } finally { Pop-Location }
return $dest
}
Die "could not find or fetch '$name' — set $envVar, run scripts/build-release.sh, or pass -ReleaseUrl"
}
# Choose install dir.
if (-not $BinDir) {
$def = "$env:LOCALAPPDATA\Programs\devbox"
if ([Environment]::UserInteractive) {
$ans = Read-Host "Where should the binaries live? [$def]"
$BinDir = if ($ans) { $ans } else { $def }
} else { $BinDir = $def }
}
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
Say "🚚 installing to $BinDir"
function Install-One($name) {
$src = Resolve-Bin $name
Copy-Item -Path $src -Destination (Join-Path $BinDir "$name.exe") -Force
Say " ✅ $name -> $BinDir\$name.exe"
}
Install-One "devbox"
if ($Hub) { Install-One "devbox-hub" }
# Add to the user PATH (persisted) if missing.
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$BinDir*") {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$BinDir", "User")
Say " ➕ added $BinDir to your user PATH (open a new terminal to pick it up)"
}
# Optional keep-alive Scheduled Task: runs `devbox start` at logon, restarts on
# failure — the Windows equivalent of launchd KeepAlive / systemd Restart=always.
function Install-Service {
$exe = Join-Path $BinDir "devbox.exe"
$action = New-ScheduledTaskAction -Execute $exe -Argument "start"
$trigger = New-ScheduledTaskTrigger -AtLogOn
$settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -RestartCount 999 -RestartInterval (New-TimeSpan -Minutes 1) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries
Register-ScheduledTask -TaskName "devbox" -Action $action -Trigger $trigger -Settings $settings -Force | Out-Null
Start-ScheduledTask -TaskName "devbox"
Say " ✅ scheduled task 'devbox' registered (runs at logon, restarts on failure)"
Say " stop: Unregister-ScheduledTask -TaskName devbox -Confirm:`$false"
}
$doService = $false
if ($Service) { $doService = $true }
elseif ($NoService) { $doService = $false }
elseif ([Environment]::UserInteractive) {
$ans = Read-Host "Set up a keep-alive auto-restart service for the sync daemon? [Y/n]"
$doService = ($ans -notmatch '^[Nn]')
}
if ($doService) { Say "🔁 setting up keep-alive service"; Install-Service }
# Windows' loose analog to macOS Full Disk Access is Controlled Folder Access
# (Defender ransomware protection) — OFF by default. If a user has it ON, a
# background sync of Documents/Desktop will be blocked until devbox is allowlisted.
try {
$cfa = (Get-MpPreference -ErrorAction SilentlyContinue).EnableControlledFolderAccess
if ($cfa -and $cfa -ne 0) {
Say ""
Say "🔐 Controlled Folder Access is ON — allow devbox to write protected folders:"
Say " Windows Security → Virus & threat protection → Ransomware protection →"
Say " Allow an app through Controlled folder access → add $BinDir\devbox.exe"
}
} catch { }
Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue
Say ""
Say "🎉 done. Next: run 'devbox setup' to join a hub and start syncing."
if ($Hub) { Say " hub: 'devbox-hub serve --dashboard' — or use the Dockerfile for a NAS (see README)." }

213
install.sh Executable file
View file

@ -0,0 +1,213 @@
#!/bin/sh
# devbox installer — macOS + Linux. Detects your platform, installs the binary to
# a location you choose, and (optionally) sets up a keep-alive auto-restart service
# so the sync daemon survives crashes and reboots.
#
# curl -fsSL https://git.shoemoney.ai/shoemoney/devbox/raw/branch/main/install.sh | sh
# sh install.sh # interactive: pick dir, offer service
# sh install.sh --hub --service # also install the hub + enable the service
# DEVBOX_BIN_DIR=~/.local/bin DEVBOX_SERVICE=1 sh install.sh # non-interactive
#
# Knobs (flags or env): --bin-dir DIR (DEVBOX_BIN_DIR) · --hub (DEVBOX_INSTALL_HUB=1)
# · --service / --no-service (DEVBOX_SERVICE=1/0) · --release-url URL (DEVBOX_RELEASE_URL).
set -eu
INSTALL_HUB="${DEVBOX_INSTALL_HUB:-0}"
BIN_DIR="${DEVBOX_BIN_DIR:-}"
WANT_SERVICE="${DEVBOX_SERVICE:-ask}"
RELEASE_URL="${DEVBOX_RELEASE_URL:-https://git.shoemoney.ai/shoemoney/devbox/releases/download/latest}"
while [ $# -gt 0 ]; do
case "$1" in
--hub) INSTALL_HUB=1 ;;
--bin-dir) BIN_DIR="$2"; shift ;;
--service) WANT_SERVICE=1 ;;
--no-service) WANT_SERVICE=0 ;;
--release-url) RELEASE_URL="$2"; shift ;;
-h|--help) sed -n '2,14p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
*) echo "unknown option: $1" >&2; exit 2 ;;
esac
shift
done
say() { printf '%s\n' "$*"; }
die() { printf '🛑 %s\n' "$*" >&2; exit 1; }
is_tty(){ [ -t 0 ] && [ -t 1 ]; }
# --- detect platform -------------------------------------------------------
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$OS" in darwin|linux) ;; *) die "unsupported OS '$OS' (this installer is macOS/Linux; use install.ps1 on Windows)";; esac
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) ARCH=amd64 ;;
arm64|aarch64) ARCH=arm64 ;;
*) die "unsupported arch '$ARCH'";;
esac
# windows-only target aside, we ship linux/amd64, linux/arm64*, darwin/arm64, darwin/amd64.
say "📦 devbox installer — detected ${OS}/${ARCH}"
SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" 2>/dev/null && pwd || echo .)
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
HAVE_GO=0; command -v go >/dev/null 2>&1 && HAVE_GO=1
# resolve_bin <name> -> prints an executable path for that binary, building or
# downloading as needed. Order: explicit env, local dist/, beside-script, download,
# go build (if a checkout + toolchain are present). Keeps working before any
# published release exists.
resolve_bin() {
name=$1
envvar=$(printf '%s_BIN' "$(echo "$name" | tr 'a-z-' 'A-Z_')") # devbox->DEVBOX_BIN, devbox-hub->DEVBOX_HUB_BIN
eval explicit="\${$envvar:-}"
if [ -n "${explicit:-}" ] && [ -x "$explicit" ]; then echo "$explicit"; return; fi
for d in "$SCRIPT_DIR/dist" "$SCRIPT_DIR/../dist" "./dist"; do
for cand in "$d/${name}"_*_"${OS}"_"${ARCH}"; do
[ -x "$cand" ] && { echo "$cand"; return; }
done
done
[ -x "$SCRIPT_DIR/$name" ] && { echo "$SCRIPT_DIR/$name"; return; }
asset="${name}_${OS}_${ARCH}"
if curl -fsSL "$RELEASE_URL/$asset" -o "$TMP/$name" 2>/dev/null && [ -s "$TMP/$name" ]; then
chmod +x "$TMP/$name"; echo "$TMP/$name"; return
fi
if [ "$HAVE_GO" = 1 ] && [ -f "$SCRIPT_DIR/go.mod" ]; then
say " building $name from source (go)…" >&2
( cd "$SCRIPT_DIR" && CGO_ENABLED=0 go build -o "$TMP/$name" "./cmd/$name" ) || die "go build $name failed"
echo "$TMP/$name"; return
fi
die "could not find or fetch '$name' — set ${envvar}=/path, run scripts/build-release.sh first, or set --release-url"
}
# --- choose install dir ----------------------------------------------------
default_bin_dir() {
if [ -w /usr/local/bin ] 2>/dev/null; then echo /usr/local/bin; return; fi
if command -v sudo >/dev/null 2>&1 && [ "$OS" = linux ]; then echo /usr/local/bin; return; fi
echo "$HOME/.local/bin"
}
if [ -z "$BIN_DIR" ]; then
def=$(default_bin_dir)
if is_tty; then
printf 'Where should the binaries live? [%s] ' "$def"
read -r ans </dev/tty || ans=""
BIN_DIR=${ans:-$def}
else
BIN_DIR=$def
fi
fi
BIN_DIR=$(eval echo "$BIN_DIR") # expand a leading ~
SUDO=""
if ! mkdir -p "$BIN_DIR" 2>/dev/null || ! [ -w "$BIN_DIR" ]; then
if command -v sudo >/dev/null 2>&1; then
SUDO="sudo"; $SUDO mkdir -p "$BIN_DIR" || die "cannot create $BIN_DIR"
else
die "$BIN_DIR is not writable and sudo is unavailable — pick another with --bin-dir"
fi
fi
install_one() {
src=$(resolve_bin "$1")
$SUDO install -m 0755 "$src" "$BIN_DIR/$1"
say " ✅ $1 → $BIN_DIR/$1"
}
say "🚚 installing to $BIN_DIR"
install_one devbox
[ "$INSTALL_HUB" = 1 ] && install_one devbox-hub
case ":$PATH:" in *":$BIN_DIR:"*) ;; *)
say "⚠️ $BIN_DIR is not on your PATH. Add to your shell rc:"
say " export PATH=\"$BIN_DIR:\$PATH\"" ;;
esac
# --- keep-alive service (optional) ----------------------------------------
DEVBOX="$BIN_DIR/devbox"
install_service_macos() {
label="ai.shoemoney.devbox"
plist="$HOME/Library/LaunchAgents/$label.plist"
mkdir -p "$HOME/Library/LaunchAgents" "$HOME/Library/Logs"
cat > "$plist" <<PLIST
<?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>$label</string>
<key>ProgramArguments</key><array><string>$DEVBOX</string><string>start</string></array>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
<key>ThrottleInterval</key><integer>5</integer>
<key>StandardOutPath</key><string>$HOME/Library/Logs/devbox.log</string>
<key>StandardErrorPath</key><string>$HOME/Library/Logs/devbox.log</string>
</dict></plist>
PLIST
launchctl unload "$plist" 2>/dev/null || true
launchctl load "$plist"
say " ✅ launchd agent loaded (KeepAlive). logs: ~/Library/Logs/devbox.log"
say " stop: launchctl unload $plist"
}
install_service_linux() {
unit="$HOME/.config/systemd/user/devbox.service"
mkdir -p "$HOME/.config/systemd/user"
cat > "$unit" <<UNIT
[Unit]
Description=devbox sync daemon
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=$DEVBOX start
Restart=always
RestartSec=3
[Install]
WantedBy=default.target
UNIT
if command -v systemctl >/dev/null 2>&1; then
systemctl --user daemon-reload
systemctl --user enable --now devbox.service
loginctl enable-linger "$USER" 2>/dev/null || say " (run 'sudo loginctl enable-linger $USER' so it starts before login)"
say " ✅ systemd user service enabled (Restart=always). logs: journalctl --user -u devbox -f"
say " stop: systemctl --user disable --now devbox"
else
say " wrote $unit — no systemd here; start manually with: $DEVBOX start"
fi
}
if [ "$WANT_SERVICE" = ask ]; then
if is_tty; then
printf 'Set up a keep-alive auto-restart service for the sync daemon? [Y/n] '
read -r ans </dev/tty || ans=""
case "$ans" in [Nn]*) WANT_SERVICE=0 ;; *) WANT_SERVICE=1 ;; esac
else
WANT_SERVICE=0
fi
fi
if [ "$WANT_SERVICE" = 1 ]; then
say "🔁 setting up keep-alive service"
if [ "$OS" = darwin ]; then install_service_macos; else install_service_linux; fi
fi
# --- macOS Full Disk Access -----------------------------------------------
# You can't grant FDA from a script (it's a hard TCC boundary) — but a background
# daemon syncing ~/Desktop, ~/Documents, ~/Downloads or iCloud will silently fail
# without it (it can't even show the per-folder prompt). So point the user at it.
if [ "$OS" = darwin ]; then
say ""
say "🔐 macOS Full Disk Access — needed only if you'll sync folders in ~/Desktop,"
say " ~/Documents, ~/Downloads, or iCloud Drive. Grant it to: $BIN_DIR/devbox"
say " System Settings → Privacy & Security → Full Disk Access → + (add the binary)"
say " ('devbox doctor' tells you if it's actually needed/missing.)"
if is_tty; then
printf ' open that settings pane now? [y/N] '
read -r ans </dev/tty || ans=""
case "$ans" in [Yy]*) open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles" 2>/dev/null || true ;; esac
fi
fi
say ""
say "🎉 done. Next: run 'devbox setup' to join a hub and start syncing."
[ "$INSTALL_HUB" = 1 ] && say " hub: 'devbox-hub serve --dashboard' — or use the Dockerfile for a NAS (see README)."