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:
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Purpose : Configuration profiles (.mobileconfig) for configure.d items.
|
||||
# Source this file; it uses wait_until from configure.
|
||||
#
|
||||
# A configuration profile is how macOS itself sets up Mail, Calendar and
|
||||
# Contacts accounts: each account is a payload in the profile, and installing
|
||||
# the profile adds the accounts, with their passwords in the keychain.
|
||||
# Removing the profile removes them again.
|
||||
#
|
||||
# Since macOS 11 only you can install a profile (profiles install no longer
|
||||
# works without device management), so profile_install opens it, which puts
|
||||
# it under Downloaded in System Settings > Profiles, and waits until you've
|
||||
# installed it there. A profile with the same PayloadIdentifier as one that's
|
||||
# installed replaces it, and payloads keep their PayloadUUID between versions,
|
||||
# so the accounts are changed rather than added again.
|
||||
|
||||
PROFILES_PANE="x-apple.systempreferences:com.apple.Profiles-Settings.extension"
|
||||
|
||||
xml_escape() {
|
||||
local s="$1"
|
||||
s="${s//&/\&}"
|
||||
s="${s//</\<}"
|
||||
s="${s//>/\>}"
|
||||
s="${s//\"/\"}"
|
||||
printf '%s' "$s"
|
||||
}
|
||||
|
||||
# The same UUID each time for the same name, so a payload is the same account
|
||||
# in each version of the profile
|
||||
stable_uuid() {
|
||||
md5 -q -s "$1" | tr a-f A-F \
|
||||
| sed -E 's/^(.{8})(.{4})(.{4})(.{4})(.{12})$/\1-\2-\3-\4-\5/'
|
||||
}
|
||||
|
||||
# The installed configuration profiles, as XML. The form of the command
|
||||
# changed in macOS 10.13; the old one still works on some versions.
|
||||
profiles_xml() {
|
||||
profiles show -type configuration -output stdout-xml 2> /dev/null \
|
||||
|| profiles -P -o stdout-xml 2> /dev/null
|
||||
}
|
||||
|
||||
# profile_installed <identifier> [uuid]: with a UUID, only that version
|
||||
profile_installed() {
|
||||
local xml
|
||||
xml="$(profiles_xml)" || return 1
|
||||
grep -qF "<string>$1</string>" <<< "$xml" || return 1
|
||||
[ -z "$2" ] || grep -qF "<string>$2</string>" <<< "$xml"
|
||||
}
|
||||
|
||||
# profile_install <file> <identifier> <uuid> <name>
|
||||
# Opens the profile and waits for you to install it in System Settings. The
|
||||
# file has passwords in it, so the caller deletes it afterwards either way.
|
||||
profile_install() {
|
||||
local file="$1" id="$2" uuid="$3" name="$4"
|
||||
open "$file" || return 1
|
||||
sleep 1
|
||||
open "$PROFILES_PANE" 2> /dev/null
|
||||
echo
|
||||
echo "System Settings shows \"$name\" under Downloaded (in Privacy & Security >"
|
||||
echo "Profiles, or General > Device Management). Double-click it, choose Install,"
|
||||
echo "and enter your Mac password when asked."
|
||||
if wait_until 480 profile_installed "$id" "$uuid"; then
|
||||
echo "Installed \"$name\"."
|
||||
return 0
|
||||
fi
|
||||
echo "\"$name\" wasn't installed. macOS forgets a downloaded profile after a few"
|
||||
echo "minutes; to try again, run this again."
|
||||
return 1
|
||||
}
|
||||
|
||||
# Removing a profile you installed yourself works from the command line on
|
||||
# most versions of macOS; if it doesn't, you remove it in System Settings.
|
||||
profile_remove() {
|
||||
local id="$1" name="$2"
|
||||
profile_installed "$id" || return 0
|
||||
profiles remove -identifier "$id" > /dev/null 2>&1 \
|
||||
|| profiles -R -p "$id" > /dev/null 2>&1
|
||||
profile_installed "$id" || return 0
|
||||
open "$PROFILES_PANE" 2> /dev/null
|
||||
echo "In System Settings > Profiles, choose \"$name\", then the - button to remove it."
|
||||
wait_until 300 not_installed "$id"
|
||||
}
|
||||
|
||||
not_installed() {
|
||||
! profile_installed "$1"
|
||||
}
|
||||
Reference in New Issue
Block a user