Files
connector-macos/configure.d/lib/smb.sh
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

48 lines
1.2 KiB
Bash

#!/bin/bash
#
# Purpose : SMB shares: which are mounted, and mounting one the way Finder
# does. Sourced by configure.d/60-storage.sh and system/storage-mount.
# smb://user@host/share and //user@host/share (as mount shows it) the same
# way: no user, lower case, host without .local or Bonjour's ._smb._tcp.local,
# %20 as a space
share_key() {
local s="${1#smb:}" host share
s="${s#//}"
s="${s#*@}"
host="${s%%/*}"
share="${s#*/}"
host="${host%._smb._tcp.local}"
host="${host%.local}"
host="${host%.}"
echo "$host/${share//%20/ }" | tr '[:upper:]' '[:lower:]'
}
# The SMB shares mounted now: "//user@host/share|mount point" per line
smb_mounts() {
mount -t smbfs | sed -nE 's#^(//[^ ]+) on (.+) \(smbfs.*#\1|\2#p'
}
# The mount point of a share, if it's mounted
mounted_at() {
local key line
key="$(share_key "$1")"
while IFS= read -r line; do
if [ "$(share_key "${line%%|*}")" = "$key" ]; then
echo "${line#*|}"
return 0
fi
done < <(smb_mounts)
return 1
}
host_of() {
local s="${1#*://}"
s="${s#*@}"
echo "${s%%/*}"
}
mount_share() {
osascript -e 'on run argv' -e 'mount volume (item 1 of argv)' -e 'end run' "$1" > /dev/null 2>&1
}