Last active
April 14, 2026 20:00
-
-
Save rmtbb/4dcaf60b8735b3cb16665bfd9bc8b7b7 to your computer and use it in GitHub Desktop.
macOS decommission prep — tears down Tailscale + openclaw before Erase All Content and Settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # ------------------------------------------------------------------ | |
| # mac-decom-prep — tears down Tailscale + openclaw so a Mac can be | |
| # factory-reset cleanly. Assumes iCloud is NOT signed in (otherwise | |
| # sign out first to avoid Activation Lock). | |
| # | |
| # ONE-SHOT USAGE (copy/paste into a zsh terminal): | |
| # curl -fsSL https://gist.githubusercontent.com/rmtbb/4dcaf60b8735b3cb16665bfd9bc8b7b7/raw/mac-decom-prep.sh | sudo bash | |
| # | |
| # Short URL for this gist: https://tinyurl.com/macwipe-openclaw | |
| # | |
| # OR download and run locally: | |
| # chmod +x ~/Desktop/mac-decom-prep.sh | |
| # sudo ~/Desktop/mac-decom-prep.sh | |
| # | |
| # After this finishes: System Settings → General → Transfer or Reset | |
| # → Erase All Content and Settings | |
| # ------------------------------------------------------------------ | |
| set -u | |
| log() { printf '[%s] %s\n' "$(date '+%H:%M:%S')" "$*"; } | |
| if [[ $EUID -ne 0 ]]; then | |
| echo "Re-run with sudo: sudo $0" | |
| exit 1 | |
| fi | |
| # Tailscale: log out so the node drops off the tailnet | |
| if command -v tailscale >/dev/null 2>&1; then | |
| log "Logging out of Tailscale..." | |
| tailscale logout || log " (already disconnected)" | |
| else | |
| log "Tailscale CLI not found — skipping." | |
| fi | |
| # Unload tailscaled (standalone install) | |
| for plist in /Library/LaunchDaemons/com.tailscale.tailscaled.plist; do | |
| [[ -f "$plist" ]] || continue | |
| log "Unloading $plist" | |
| launchctl unload "$plist" 2>/dev/null || true | |
| done | |
| # Quit the Mac App Store Tailscale app if present | |
| osascript -e 'quit app "Tailscale"' 2>/dev/null || true | |
| # openclaw: unload any launchd jobs and kill stragglers | |
| log "Stopping openclaw services..." | |
| for plist in /Library/LaunchDaemons/*openclaw* \ | |
| /Library/LaunchAgents/*openclaw* \ | |
| /Users/*/Library/LaunchAgents/*openclaw*; do | |
| [[ -f "$plist" ]] || continue | |
| log " unloading $plist" | |
| launchctl unload "$plist" 2>/dev/null || true | |
| done | |
| pkill -f openclaw 2>/dev/null && log " killed running openclaw processes" || true | |
| log "Prep complete." | |
| cat <<'MSG' | |
| Next step — erase the machine: | |
| System Settings → General → Transfer or Reset | |
| → Erase All Content and Settings | |
| Or from Terminal: | |
| open "/System/Library/CoreServices/Applications/Erase Assistant.app" | |
| MSG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment