Commit Graph

6 Commits

Author SHA1 Message Date
Oliver Surke 488a9a2140 feat: pre-auth sudo once before brew bundle install with keepalive
Homebrew cask installers call sudo internally for each package that needs
admin privileges. Without pre-authentication, macOS prompts for a password
on every such package across a long brew bundle run.

_ssr_sudo_keepalive_start:
  Calls 'sudo -v' once (prompts user if not already cached), then spawns a
  background loop that calls 'sudo -n true' every 60s to prevent the
  default 5-minute credential cache from expiring mid-run.

_ssr_sudo_keepalive_stop:
  Kills the keepalive loop after brew bundle completes.

If sudo is unavailable (non-admin user), a warning is shown and the run
continues — individual cask installers that need sudo will prompt as before.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 09:49:34 +02:00
Oliver Surke 634487b9d8 feat: restore state/resume/report + single Spotlight index after mas installs
lib/brew.sh:
  Set MAS_NO_AUTO_INDEX=1 before brew bundle install to suppress the
  per-app mdimport call that mas otherwise runs after each App Store
  installation. Run one mdimport /Applications batch pass afterwards.

lib/restore-state.sh (new):
  Lightweight key=value state file (~/.local/state/ssr/restore-state).
  ssr::rs::init / ssr::rs::run / ssr::rs::set/get / ssr::rs::error /
  ssr::rs::report — tracks step outcomes and accumulated errors.

bin/ssr-restore:
  --resume flag: skip steps already marked ok in state file.
  Each step (brew_install, brew_restore, mackup_restore, macos_defaults,
  prefs_import) wrapped in ssr::rs::run; errors accumulate without abort.
  Formatted report printed at end of every run.

bin/ssr-status:
  ssr status restore — full restore step report + error log
  ssr status backup  — Brewfile lines, unmanaged apps, prefs snapshot
  ssr status         — general view now shows one-line last-restore
                       summary and hint to run 'ssr status restore'

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 09:39:48 +02:00
Oliver Surke d06a6e47d7 fix: soft-fail brew bundle install; update .gitignore
lib/brew.sh:
  brew bundle exits non-zero when any single package fails (network error,
  cask version mismatch, missing tap, etc.). Previously this killed the
  entire ssr restore via set -euo pipefail before mackup / defaults / prefs
  had a chance to run. Capture the exit code, emit a clear warning, and
  continue. The user can rerun the manual command shown in the warning.

.gitignore:
  Replace minimal gitignore with the comprehensive macOS + Cursor + VSCode
  template generated by toptal gitignore.io. Preserve the original ssr-
  specific custom rules (.local/, .config/, *.log, *.plist.local) in the
  custom section at the bottom.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 21:22:27 +02:00
Oliver Surke aef5877641 fix: remove --no-lock from brew bundle install (flag removed in modern brew-bundle)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 20:57:38 +02:00
Oliver Surke 8489180d51 Fix ssr restore: skip iCloud prompt when available, bail early on missing sudo
lib/brew.sh:
  - Before running the Homebrew installer, check `sudo -n true`. If sudo
    is not available, print a clear actionable error message with the
    manual install command and exit instead of running NONINTERACTIVE=1
    and crashing with "Need sudo access ... Administrator!" mid-way.

bin/ssr-restore:
  - Drop the unconditional "Configure iCloud / cloud drive?" prompt.
    Instead check whether the cloud directory is already mounted; if it
    is, proceed silently (the common case on an already-configured Mac).
    The prompt only appears when the directory is missing, i.e. iCloud
    is not yet signed in or the drive is not mounted — with an
    appropriate message explaining what to do.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 20:51:18 +02:00
Oliver Surke 539a8fc28f Initial ssr repository
Convert the legacy system_sync.sh and system_restore.sh into a modular
shareable repository:

- bin/ssr CLI dispatcher with install/sync/restore/schedule/config/status
- lib/ split: common, cloud, brew, mackup, macos
- Cloud provider abstraction (icloud, dropbox, googledrive, onedrive, custom)
- launchd template for scheduled daily sync (renderable via sed)
- ssr.conf.example with whitelisted KEY=VALUE config loader
- macos-defaults.sh extracted from inline block, overridable
- install.sh bootstrap symlinks CLI into ~/.local/bin
- README with usage, config table, migration map, security notes
- Original scripts archived under legacy/ for reference

Fixes vs originals: set -euo pipefail, quoted vars, find -print0,
spctl --global-disable (was --master-disable), MACOS=".macos" bug,
zero-width char before ln, Apple Silicon brew shellenv, config injection
hardening.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 15:05:17 +02:00