Set up a Mac for a Federated Core, like CoreDesktop's configure

A macOS counterpart of CoreDesktop's configure, with the same drop-in
items in configure.d/:

- core: Mail, Calendar and Contacts through a configuration profile,
  Superpanel as an app, Nextcloud files through the Nextcloud app, and
  Element; with test-and-fix, password change and removal
- tailscale: join the Core's network through headscale
- backup: restic to Nextcloud through rclone, run by launchd through an
  app that can be given Full Disk Access
- storage: SMB shares mounted the way Finder does, again at login and
  on network changes
- agents, claude, opencode, hermes, sandbox: install the agents and run
  them in Anthropic's sandbox runtime (Seatbelt on macOS)
- ai-servers: LLM servers on this Mac or the network, for the agents

Apps and tools macOS lacks are offered for download, checked against
their makers' Team IDs and notarization, or published SHA-256 sums.
Everything runs on macOS' bash 3.2 with only built-in tools.

smoketest/ runs scenarios in fresh macOS VMs with Tart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 08:34:42 -07:00
co-authored by Claude Opus 5.5
commit 08e6b2ee4f
45 changed files with 4517 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
#!/bin/bash
# configure reads TITLE and DESCRIPTION
# shellcheck disable=SC2034
TITLE="Tailscale"
# shellcheck disable=SC2034
DESCRIPTION="Join your Core's Tailscale network"
CORE_CONF="$CONF_DIR/core.conf"
TAILSCALE_CONF="$CONF_DIR/tailscale.conf"
source "$CONNECTOR/configure.d/lib/json.sh"
source "$CONNECTOR/configure.d/lib/apps.sh"
[ -f "$CORE_CONF" ] && source "$CORE_CONF"
[ -f "$TAILSCALE_CONF" ] && source "$TAILSCALE_CONF"
# The Tailscale app's own command line, in both the App Store and the
# standalone app
tailscale() {
local app
app="$(app_path tailscale)" || return 1
"$app/Contents/MacOS/Tailscale" "$@"
}
running() {
tailscale status --json 2> /dev/null | json_get 'd.BackendState === "Running"' > /dev/null
}
# Tailscale has no status field naming its login server, so tailscale.conf
# records which Core it was set up for
joined() {
[ -n "$TAILSCALE_DOMAIN" ] && running
}
# Done when on the main Core's network
is_configured() {
[ -n "$CORE_DOMAIN" ] && [ "$TAILSCALE_DOMAIN" = "$CORE_DOMAIN" ] && joined
}
# Log out rather than only disconnect, so this Mac's key is expired on
# headscale and it's off the network until it joins again
leave_network() {
tailscale logout || return 1
rm -f "$TAILSCALE_CONF"
echo "This Mac has left your Core's Tailscale network. To join again: configure tailscale"
}
# The first time it opens, Tailscale asks you to allow its VPN configuration
# (and, for the standalone app, its system extension); until then its command
# line can't reach it
tailscale_ready() {
tailscale status --json 2> /dev/null | json_get 'd.BackendState' > /dev/null
}
run_configure() {
local choice
if joined &> /dev/null; then
echo "This Mac is on $TAILSCALE_DOMAIN's Tailscale network (headscale.$TAILSCALE_DOMAIN)."
echo
if [ "$TAILSCALE_DOMAIN" = "$CORE_DOMAIN" ]; then
echo " 1) Join it again"
else
echo " 1) Join your main Core's network instead (headscale.$CORE_DOMAIN)"
fi
echo " 2) Leave the network"
echo " q) Leave it as it is"
echo
read -rp "Choose: " choice
case "$choice" in
1) ;;
2) leave_network; return ;;
*) return 0 ;;
esac
fi
if [ -z "$CORE_DOMAIN" ]; then
echo "This joins your Core's Tailscale network, so set up your Core first: configure core"
return 1
fi
app_ensure tailscale "It joins this Mac to your Core's network." || return 1
if ! tailscale_ready; then
open -a "$(app_path tailscale)"
echo "Tailscale is opening. If it asks to add a VPN configuration or allow a system"
echo "extension, allow it (System Settings may open for that)."
wait_until 300 tailscale_ready || { echo "Tailscale isn't ready yet. Run this again when it is."; return 1; }
fi
# --reset and --force-reauth move the Mac from any other tailnet
echo "Open the link below to sign in to your Core's Tailscale network (headscale.$CORE_DOMAIN)."
tailscale up --reset --force-reauth --login-server "https://headscale.$CORE_DOMAIN" \
--accept-routes || return 1
mkdir -p "$(dirname "$TAILSCALE_CONF")"
printf 'TAILSCALE_DOMAIN=%q\n' "$CORE_DOMAIN" > "$TAILSCALE_CONF"
echo "This Mac is on your Core's Tailscale network."
}