539a8fc28f
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>
48 lines
1.4 KiB
Bash
Executable File
48 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ssr-install — local install: symlink CLI, seed config, optionally schedule.
|
|
|
|
set -euo pipefail
|
|
SSR_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
# shellcheck source=../lib/common.sh
|
|
source "$SSR_ROOT/lib/common.sh"
|
|
|
|
ssr::require_macos
|
|
|
|
PREFIX="${SSR_PREFIX:-$HOME/.local/bin}"
|
|
CONFIG_DIR="${SSR_CONFIG_DIR:-$HOME/.config/ssr}"
|
|
CONFIG_FILE="$CONFIG_DIR/ssr.conf"
|
|
|
|
ssr::log "Installing ssr"
|
|
ssr::log " prefix: $PREFIX"
|
|
ssr::log " config: $CONFIG_FILE"
|
|
|
|
ssr::ensure_dir "$PREFIX"
|
|
ssr::ensure_dir "$CONFIG_DIR"
|
|
|
|
# Symlink the main CLI so `ssr` works from anywhere.
|
|
ln -sfn "$SSR_ROOT/bin/ssr" "$PREFIX/ssr"
|
|
ssr::ok "Linked $PREFIX/ssr → $SSR_ROOT/bin/ssr"
|
|
|
|
# Seed config from the example (do not overwrite an existing user config).
|
|
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
cp "$SSR_ROOT/config/ssr.conf.example" "$CONFIG_FILE"
|
|
chmod 600 "$CONFIG_FILE"
|
|
ssr::ok "Seeded $CONFIG_FILE (chmod 600)"
|
|
else
|
|
ssr::log "Config already exists, leaving untouched: $CONFIG_FILE"
|
|
fi
|
|
|
|
# Path hint if PREFIX is not on PATH.
|
|
case ":$PATH:" in
|
|
*":$PREFIX:"*) ;;
|
|
*) ssr::warn "$PREFIX is not on your PATH — add it to your shell rc:"
|
|
echo " export PATH=\"$PREFIX:\$PATH\"" ;;
|
|
esac
|
|
|
|
# Offer to enable the scheduled sync.
|
|
if ssr::confirm "Enable daily scheduled sync (launchd)?" 30; then
|
|
"$SSR_ROOT/bin/ssr-schedule" on
|
|
fi
|
|
|
|
ssr::ok "Install complete. Run: ssr status"
|