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>
This commit is contained in:
+10
-3
@@ -31,6 +31,16 @@ EOF
|
||||
[[ "${1:-}" == "-h" || "${1:-}" == "--help" ]] && { usage; exit 0; }
|
||||
|
||||
ssr::log "ssr restore starting"
|
||||
|
||||
# Resolve cloud dir early so we can check availability before prompting.
|
||||
_cloud_dir="$(ssr::cloud::resolve_dir 2>/dev/null)" || true
|
||||
if [[ -z "$_cloud_dir" || ! -d "$_cloud_dir" ]]; then
|
||||
ssr::warn "Cloud directory not yet accessible: ${_cloud_dir:-<unknown>}"
|
||||
ssr::warn "Sign in to ${SSR_CLOUD_PROVIDER:-iCloud} and ensure the drive is mounted, then press Enter."
|
||||
ssr::confirm "Cloud drive ready — proceed with restore?" 120 \
|
||||
|| ssr::die "Aborted by user"
|
||||
fi
|
||||
|
||||
ssr::cloud::ensure_available
|
||||
backup_dir="$(ssr::cloud::backup_dir)"
|
||||
mackup_dir="$(ssr::cloud::mackup_dir)"
|
||||
@@ -39,9 +49,6 @@ brewfile="${1:-$backup_dir/Brewfile}"
|
||||
[[ -f "$brewfile" ]] || ssr::die "Brewfile not found: $brewfile"
|
||||
ssr::log "Using Brewfile: $brewfile"
|
||||
|
||||
ssr::confirm "Configure iCloud / cloud drive and proceed with restore?" 60 \
|
||||
|| ssr::die "Aborted by user"
|
||||
|
||||
ssr::macos::disable_gatekeeper
|
||||
ssr::macos::install_rosetta
|
||||
|
||||
|
||||
Reference in New Issue
Block a user