From af90b20f1271a3e73ed31458c25fc40fd5e6b66a Mon Sep 17 00:00:00 2001 From: Sander Declerck Date: Fri, 13 Mar 2026 14:09:50 +0100 Subject: [PATCH] Add uninstall scripts --- install-scripts/uninstall-endpoint-mac.sh | 50 ++++++++++++++++ .../uninstall-endpoint-windows.ps1 | 59 +++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 install-scripts/uninstall-endpoint-mac.sh create mode 100644 install-scripts/uninstall-endpoint-windows.ps1 diff --git a/install-scripts/uninstall-endpoint-mac.sh b/install-scripts/uninstall-endpoint-mac.sh new file mode 100644 index 0000000..b1ba6e4 --- /dev/null +++ b/install-scripts/uninstall-endpoint-mac.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +# Uninstalls SafeChain Ultimate endpoint on macOS +# +# Usage: curl -fsSL | sudo sh + +set -e # Exit on error + +# Configuration +UNINSTALL_SCRIPT="/Library/Application Support/AikidoSecurity/SafeChainUltimate/scripts/uninstall" + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' # No Color + +# Helper functions +info() { + printf "${GREEN}[INFO]${NC} %s\n" "$1" +} + +error() { + printf "${RED}[ERROR]${NC} %s\n" "$1" >&2 + exit 1 +} + +# Main uninstallation +main() { + # Check if we're running on macOS + if [ "$(uname -s)" != "Darwin" ]; then + error "This script is only supported on macOS." + fi + + # Check if we're running as root + if [ "$(id -u)" -ne 0 ]; then + error "Root privileges required. Please re-run with sudo, e.g.: curl -fsSL | sudo sh" + fi + + # Check if the uninstall script exists + if [ ! -f "$UNINSTALL_SCRIPT" ]; then + error "SafeChain Ultimate does not appear to be installed (uninstall script not found)." + fi + + info "Uninstalling SafeChain Ultimate..." + "$UNINSTALL_SCRIPT" + + info "SafeChain Ultimate uninstalled successfully!" +} + +main "$@" diff --git a/install-scripts/uninstall-endpoint-windows.ps1 b/install-scripts/uninstall-endpoint-windows.ps1 new file mode 100644 index 0000000..5de5bfe --- /dev/null +++ b/install-scripts/uninstall-endpoint-windows.ps1 @@ -0,0 +1,59 @@ +# Uninstalls SafeChain Ultimate endpoint on Windows +# +# Usage: iex (iwr '' -UseBasicParsing) + +# Configuration +$AppName = "SafeChain Ultimate" + +# Helper functions +function Write-Info { + param([string]$Message) + Write-Host "[INFO] $Message" -ForegroundColor Green +} + +function Write-Error-Custom { + param([string]$Message) + Write-Host "[ERROR] $Message" -ForegroundColor Red + exit 1 +} + +# Check if running as Administrator +function Test-Administrator { + $identity = [Security.Principal.WindowsIdentity]::GetCurrent() + $principal = New-Object Security.Principal.WindowsPrincipal($identity) + return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} + +# Main uninstallation +function Uninstall-Endpoint { + # Check if we're running as Administrator + if (-not (Test-Administrator)) { + Write-Error-Custom "Administrator privileges required. Please run this script in an elevated terminal (Run as Administrator)." + } + + # Find the installed product + Write-Info "Looking for SafeChain Ultimate installation..." + $app = Get-WmiObject -Class Win32_Product -Filter "Name='$AppName'" + + if (-not $app) { + Write-Error-Custom "SafeChain Ultimate does not appear to be installed." + } + + $productCode = $app.IdentifyingNumber + + Write-Info "Uninstalling SafeChain Ultimate..." + $process = Start-Process -FilePath "msiexec" -ArgumentList "/x", $productCode, "/qn", "/norestart" -Wait -PassThru + if ($process.ExitCode -ne 0) { + Write-Error-Custom "Uninstall failed (exit code: $($process.ExitCode))." + } + + Write-Info "SafeChain Ultimate uninstalled successfully!" +} + +# Run uninstallation +try { + Uninstall-Endpoint +} +catch { + Write-Error-Custom "Uninstallation failed: $_" +}