Skip to content

Instantly share code, notes, and snippets.

@dp-singh
Created November 29, 2024 12:12
Show Gist options
  • Save dp-singh/237ac86d2cad9ab6851a15a0c201380d to your computer and use it in GitHub Desktop.
Save dp-singh/237ac86d2cad9ab6851a15a0c201380d to your computer and use it in GitHub Desktop.
Arctic Wolf Agent Uninstallation Script
#!/bin/bash
# Check if the uninstall script exists
if [ -f /Library/ArcticWolfNetworks/Agent/uninstall.sh ]; then
echo "Uninstall script found. Proceeding with uninstallation."
# Check if the Arctic Wolf Agent is running
if pgrep -f "ArcticWolfNetworks" > /dev/null; then
echo "Arctic Wolf Agent is running. Stopping the service..."
# Attempt to stop the service
sudo launchctl unload /Library/LaunchDaemons/com.arcticwolf.agent.plist 2>/dev/null
if [ $? -eq 0 ]; then
echo "Service stopped successfully."
else
echo "Failed to stop the service. Proceeding with uninstallation anyway."
fi
else
echo "Arctic Wolf Agent is not running."
fi
# Run the uninstall script
sudo /Library/ArcticWolfNetworks/Agent/uninstall.sh
if [ $? -eq 0 ]; then
echo "Arctic Wolf Agent uninstalled successfully."
exit 0
else
echo "Uninstallation script encountered an error."
exit 1
fi
else
echo "Uninstall script not found. Arctic Wolf Agent may not be installed."
exit 1
fi
@dp-singh
Copy link
Author

Script Name: Arctic Wolf Agent Uninstallation Script

Description:
This script is designed to uninstall the Arctic Wolf Agent from macOS devices. It performs the following actions:

  1. Checks if the Arctic Wolf Agent uninstall script exists.
  2. Verifies if the Arctic Wolf Agent is currently running.
  3. Stops the Arctic Wolf Agent service if it is running.
  4. Executes the uninstall script to remove the Arctic Wolf Agent.
  5. Returns an appropriate exit code to indicate success (exit 0) or failure (exit 1).

Use Case:
This script is intended for use in environments where the Arctic Wolf Agent needs to be removed from managed macOS devices, such as through an MDM platform like Kandji. It ensures a clean and graceful uninstallation process, even if the agent is actively running.

Key Features:

  • Detects if the Arctic Wolf Agent is running and stops it before uninstallation.
  • Handles scenarios where the uninstall script is missing or the service cannot be stopped.
  • Provides clear logging for troubleshooting and monitoring.
  • Returns appropriate exit codes for integration with MDM platforms.

Requirements:

  • macOS device with the Arctic Wolf Agent installed.
  • Administrative/root privileges to execute the script.
  • The uninstall script must be located at /Library/ArcticWolfNetworks/Agent/uninstall.sh.

Exit Codes:

  • 0: Uninstallation completed successfully.
  • 1: Uninstallation failed (e.g., uninstall script not found, service stop failed, or uninstall script error).

Notes:

  • The script assumes the Arctic Wolf Agent is managed by a LaunchDaemon (com.arcticwolf.agent.plist). Update the script if the service name differs.
  • Test the script on a single device before deploying it to a larger group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment