Files
davidandClaude Opus 5.5 f92dbcb3bd Add an installer and update command
curl -fsSL https://federated.sh/mac | bash

install.sh checks the Mac (macOS 13+, not root, internet; warns if the
account isn't an administrator), then downloads the latest commit as an
archive from Gitea, as macOS has no git without the Command Line Tools.
It installs into ~/.local/share/federated-connector/connector, links
configure and update into ~/.local/bin and puts that on PATH at the top
of ~/.zprofile and ~/.bash_profile, then offers to run configure. Piped
into bash, it runs only once read in full, and asks from /dev/tty.

The folder never moves, so the backup and storage jobs and the Federated
Backup app (with its Full Disk Access) keep pointing at it. update shows
the commits since the installed one and swaps the new files in with two
renames.

If configure ran from another folder before, the installer says what
still runs from there; backup and storage now show as to do until
they're set up again from the installed copy.

smoketest: 05-install pipes install.sh into bash with the working copy,
runs update, then installs the published version from Gitea.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 09:21:17 -07:00

51 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# Purpose : Update Federated Connector to the latest version on Gitea.
#
# Usage: update Update, showing what changed
# update --version Show the version installed
#
# The installer does the work (install.sh --update): it downloads the new
# version and swaps it in, so the jobs and the Federated Backup app keep
# pointing at the same place. Your settings, the profiles, keychain items and
# downloaded tools are left as they are.
# Wrapped in { ...; exit; } so bash reads the whole script up front; the
# update replaces this file while it runs.
{
# This script, through the link in ~/.local/bin
self="$0"
while [ -L "$self" ]; do
link="$(readlink "$self")"
case "$link" in
/*) self="$link" ;;
*) self="$(dirname "$self")/$link" ;;
esac
done
CONNECTOR="$(cd "$(dirname "$self")" && pwd -P)"
case "$1" in
--version|-v)
echo "Federated Connector $(cut -c1-7 "$CONNECTOR/.version" 2> /dev/null || echo "(not installed with install.sh)")"
exit 0 ;;
-h|--help)
sed -n '4,6p' "$self" | sed 's/^# \{0,1\}//'
exit 0 ;;
esac
if [ ! -f "$CONNECTOR/.version" ]; then
echo "This copy wasn't installed with install.sh, so update can't replace it. Install with:"
echo " curl -fsSL https://federated.sh/mac | bash"
exit 1
fi
# Run from a copy: the update replaces install.sh along with everything else
copy="$(mktemp)" || exit 1
cp "$CONNECTOR/install.sh" "$copy" || exit 1
bash "$copy" --update
status=$?
rm -f "$copy"
exit $status
}