Files
connector-macos/system/storage-mount
T
davidandClaude Opus 5.5 08e6b2ee4f 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>
2026-11-11 08:34:42 -07:00

50 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# Purpose : Mount the shared folders `configure storage` added, at login and
# whenever the network changes (launchd starts this then).
#
# A share whose server can't be reached, e.g. away from home, is skipped
# quietly. macOS signs in with the password you saved in your keychain when
# you added the share. If it can't, it asks; if you cancel, this doesn't ask
# again for an hour.
#
# Usage: storage-mount [--list] (--list: show each share and whether it's mounted)
# Wrapped in { ...; exit; } so bash reads the whole script up front
{
CONF_DIR="$HOME/Library/Application Support/Federated Connector"
STORAGE_CONF="$CONF_DIR/storage"
FAILED_DIR="${TMPDIR:-/tmp}/federated-storage-failed"
RETRY_AFTER=3600
source "$(cd "$(dirname "$0")/.." && pwd)/configure.d/lib/smb.sh" || exit 1
[ -f "$STORAGE_CONF" ] || exit 0
if [ "$1" = --list ]; then
while IFS= read -r url; do
[ -n "$url" ] || continue
if point="$(mounted_at "$url")"; then echo "$url|$point"; else echo "$url|"; fi
done < "$STORAGE_CONF"
exit 0
fi
mkdir -p "$FAILED_DIR"
while IFS= read -r url; do
[ -n "$url" ] || continue
mounted_at "$url" > /dev/null && continue
nc -z -G 3 "$(host_of "$url")" 445 > /dev/null 2>&1 || continue
marker="$FAILED_DIR/$(share_key "$url" | tr '/ ' '__')"
if [ -f "$marker" ] && [ $(($(date +%s) - $(stat -f %m "$marker"))) -lt $RETRY_AFTER ]; then
continue
fi
if mount_share "$url"; then
rm -f "$marker"
else
touch "$marker"
fi
done < "$STORAGE_CONF"
exit 0
}