feat: doctor, update, uninstall, config, report, MA detect, spinner, reinstall
- doctor: pre-flight diagnostic (sudo, recovery, disk, libs, third-party FW) - update: self-update from GitHub latest release - uninstall: remove all Unleash traces (daemons, pf, hosts, backups, config) - config: persistent settings file (~/.unleash.conf) with show/set/unset - report: full markdown system status report - MA detect: scan for Migration Assistant MDM artifacts per user - spinner: visual progress indicator for long operations - reinstall: uninstall + persist + whitelist + monitor-install - Third-party firewall detection (Little Snitch, LuLu, Radio Silence, Vallum) - Load config on startup (WEBHOOK, LOG_LEVEL, LOG_FILE) - Bump 1.3.0 -> 1.4.0
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
do_self_update() {
|
||||
header "Unleash Update"
|
||||
|
||||
if ! command -v curl &>/dev/null; then
|
||||
error_exit "curl required for update"
|
||||
fi
|
||||
|
||||
local repo="mateussiqueira/unleash"
|
||||
local api_url="https://api.github.com/repos/${repo}/releases/latest"
|
||||
local tmp_dir
|
||||
tmp_dir=$(mktemp -d)
|
||||
local current_sha
|
||||
current_sha=$(git -C "$SCRIPT_DIR" rev-parse HEAD 2>/dev/null || echo "unknown")
|
||||
|
||||
begin "Checking latest release"
|
||||
local release_data
|
||||
release_data=$(curl -s "$api_url" 2>/dev/null || true)
|
||||
local latest_tag
|
||||
latest_tag=$(echo "$release_data" | grep '"tag_name"' | head -1 | sed -E 's/.*"v?([^"]+)".*/\1/')
|
||||
local latest_sha
|
||||
latest_sha=$(echo "$release_data" | grep '"target_commitish"' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
|
||||
if [ -z "$latest_tag" ]; then
|
||||
end_fail; echo " No network or invalid response"
|
||||
rm -rf "$tmp_dir"
|
||||
return 1
|
||||
fi
|
||||
end_ok; echo " Latest: v$latest_tag"
|
||||
|
||||
if [ "v$latest_tag" = "$(echo "v$VERSION")" ]; then
|
||||
success "Already up to date (v$VERSION)"
|
||||
rm -rf "$tmp_dir"
|
||||
return 0
|
||||
fi
|
||||
|
||||
info "Updating from v$VERSION to v$latest_tag..."
|
||||
|
||||
begin "Downloading latest unleash"
|
||||
local dl_url="https://raw.githubusercontent.com/${repo}/main/unleash"
|
||||
local tmp="$tmp_dir/unleash"
|
||||
if curl -sL "$dl_url" -o "$tmp" && [ -s "$tmp" ]; then
|
||||
end_ok
|
||||
else
|
||||
end_fail; error_exit "Download failed"
|
||||
fi
|
||||
|
||||
begin "Verifying syntax"
|
||||
if bash -n "$tmp" 2>/dev/null; then
|
||||
end_ok
|
||||
else
|
||||
end_fail; error_exit "Downloaded script has syntax errors"
|
||||
fi
|
||||
|
||||
local target="${0:-unleash}"
|
||||
if [ ! -w "$target" ]; then
|
||||
info "$target not writable, trying sudo..."
|
||||
cp "$tmp" "$target" 2>/dev/null || sudo cp "$tmp" "$target" 2>/dev/null || {
|
||||
error_exit "Cannot write to $target (run with sudo)"
|
||||
}
|
||||
else
|
||||
cp "$tmp" "$target"
|
||||
fi
|
||||
chmod +x "$target" 2>/dev/null || sudo chmod +x "$target" 2>/dev/null || true
|
||||
|
||||
rm -rf "$tmp_dir"
|
||||
success "Updated to v$latest_tag"
|
||||
info "Run again to use new version"
|
||||
}
|
||||
Reference in New Issue
Block a user