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>
28 lines
865 B
Bash
Executable File
28 lines
865 B
Bash
Executable File
#!/bin/bash
|
|
|
|
LOGGER_BIN="/usr/bin/logger -ist '$0'"
|
|
UUID=$(system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }')
|
|
HOSTNAME=$(hostname -s)
|
|
BACKUPDIR="$HOME/Library/Mobile Documents/com~apple~CloudDocs/BACKUP/$HOSTNAME - $UUID"
|
|
|
|
# Check for Homebrew to be present, install if it's missing
|
|
if test ! $(which brew); then
|
|
echo "Installing homebrew..."
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
|
fi
|
|
BREW_BIN=$(which brew)
|
|
BREW_PREFX=$(brew --prefix)
|
|
CASK_DIR=$(brew --caskroom)
|
|
|
|
# Update homebrew recipes
|
|
$BREW_BIN update
|
|
MACKUP_DIR="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Mackup"
|
|
MACKUP_BIN=$(which mackup)
|
|
$MACKUP_BIN -f backup
|
|
|
|
mkdir -vp "$BACKUPDIR"
|
|
pushd "$BACKUPDIR" >/dev/null
|
|
cp -vf Brewfile{,.bak}
|
|
$BREW_BIN bundle dump --describe --quiet --force | $LOGGER_BIN
|
|
popd >/dev/null
|