Files
System-Sync-Restore/bin/ssr-status
T
Oliver Surke a4465f37c6 Improve schedule and mackup reliability
- bin/ssr-schedule: use `launchctl bootstrap`/`bootout` (modern API) with
  legacy `load -w` fallback. The previous `load -w`-only flow silently
  no-op'd on macOS 10.15+ in some configurations, leaving `ssr status`
  reporting `inactive` after a successful `ssr schedule on`.
- bin/ssr-status: query the service via `launchctl print`/`list <label>`
  for consistent active/inactive detection.
- lib/mackup.sh: pre-materialize iCloud placeholders via `brctl download`
  and retry `mackup -f backup` up to three times to dodge the recurring
  `OSError [Errno 66] Directory not empty` race between mackup's rmtree
  and iCloud's filesystem provider. Soft-fails so the rest of `ssr sync`
  still runs even if mackup never settles; logs actionable hints.

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

41 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# ssr-status — print current state: config, cloud target, last sync, schedule.
set -euo pipefail
SSR_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# shellcheck source=../lib/common.sh
source "$SSR_ROOT/lib/common.sh"
# shellcheck source=../lib/cloud.sh
source "$SSR_ROOT/lib/cloud.sh"
ssr::load_config
cfg="${SSR_CONFIG:-$HOME/.config/ssr/ssr.conf}"
provider="${SSR_CLOUD_PROVIDER:-icloud}"
echo "ssr status"
echo " repo: $SSR_ROOT"
echo " config: $cfg $([[ -f "$cfg" ]] && echo '(present)' || echo '(missing)')"
echo " provider: $provider"
if cloud_dir="$(ssr::cloud::resolve_dir 2>/dev/null)"; then
echo " cloud dir: $cloud_dir $([[ -d "$cloud_dir" ]] && echo '(ok)' || echo '(unreachable)')"
echo " backup dir: $(ssr::cloud::backup_dir 2>/dev/null || echo 'n/a')"
fi
state_dir="${SSR_STATE_DIR:-$HOME/.local/state/ssr}"
if [[ -f "$state_dir/last-sync" ]]; then
echo " last sync: $(cat "$state_dir/last-sync")"
else
echo " last sync: never"
fi
label="${SSR_LAUNCHD_LABEL:-de.surke.ssr.sync}"
service_target="gui/$(id -u)/${label}"
if launchctl print "$service_target" >/dev/null 2>&1 \
|| launchctl list "$label" >/dev/null 2>&1; then
echo " schedule: active ($label)"
else
echo " schedule: inactive"
fi