Files
System-Sync-Restore/bin/ssr
T
Oliver Surke 51fb589ef2 fix(mackup): safer defaults + recovery after broken symlink sync
- Default-off SSR_MACKUP_PRESYMLINK for DynamicProfiles pre-symlink (was
  risking empty/wrong iCloud trees and breaking iTerm2).
- Remove incorrect skip entries: built-in cfgs use different paths than
  ~/.zsh, ~/.vscode*, ~/.iterm2 — skipping hid real overlap from scan only
  but the presymlink change was the main footgun.
- Add `ssr mackup unlink` → `mackup -f link uninstall` to copy configs back
  from Mackup storage and drop symlinks (official undo).
- Docs: ssr.conf.example, README sync/restore wording, completions.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 20:09:23 +02:00

77 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# ssr — System Sync & Restore CLI dispatcher.
# Resolves the repository root, sources libs, and forwards to a subcommand.
set -euo pipefail
# Resolve script directory even when invoked via a symlink (e.g. /usr/local/bin/ssr).
SOURCE="${BASH_SOURCE[0]}"
while [[ -L "$SOURCE" ]]; do
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE"
done
SSR_BIN_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SSR_ROOT="$(cd "$SSR_BIN_DIR/.." && pwd)"
export SSR_ROOT SSR_BIN_DIR
# shellcheck source=../lib/common.sh
source "$SSR_ROOT/lib/common.sh"
usage() {
cat <<EOF
ssr — System Sync & Restore for macOS
Usage:
ssr <command> [options]
Commands:
install First-time install: links binary, seeds config, schedules sync.
sync Run a backup: brew bundle dump + mackup link install → cloud.
restore [Brewfile] Restore a machine: brew bundle + mackup link + macOS defaults.
update [--dry-run] Pull latest ssr code, refresh launchd if needed.
schedule on|off Enable/disable the scheduled launchd sync job.
config show|edit Print or edit the active config file.
completions Install or remove shell completions (zsh/bash/fish).
status Show last sync time, cloud target, and scheduled state.
mackup scan|list|clean|unlink Mackup ssr-*.cfg helpers + symlink revert.
version Print version.
Options:
-c, --config PATH Use a specific config file (default: ~/.config/ssr/ssr.conf).
-h, --help Show this help.
Environment:
SSR_CONFIG Same as --config.
Docs: see README.md in the repository root.
EOF
}
# Parse global flags.
while [[ $# -gt 0 ]]; do
case "$1" in
-c|--config) export SSR_CONFIG="$2"; shift 2 ;;
-h|--help) usage; exit 0 ;;
--) shift; break ;;
-*) ssr::die "Unknown global flag: $1 (use -h for help)" ;;
*) break ;;
esac
done
[[ $# -gt 0 ]] || { usage; exit 1; }
cmd="$1"; shift
case "$cmd" in
install|sync|restore|update|schedule|config|completions|status|mackup)
target="$SSR_BIN_DIR/ssr-$cmd"
[[ -x "$target" ]] || ssr::die "Subcommand not executable: $target"
exec "$target" "$@"
;;
version|-v|--version)
cat "$SSR_ROOT/VERSION" 2>/dev/null || echo "dev"
;;
help|-h|--help) usage ;;
*) ssr::err "Unknown command: $cmd"; usage; exit 1 ;;
esac