Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # === FUNCTIONS ===
- # Function to show a notification
- show_notification() {
- local title="$1"
- local message="$2"
- osascript <<EOF
- display notification "$message" with title "$title" subtitle "Script completed successfully"
- beep
- EOF
- }
- # Function to crash an app or process and check if it was killed
- crash_process() {
- local process_name="$1"
- local process_path="$2"
- # Check if the process exists
- if pgrep -f "$process_path" > /dev/null; then
- echo "Attempting to kill process $process_name..."
- pkill -f "$process_path" 2>/dev/null || true
- sleep 2 # Wait for the process to terminate
- # Check if the process is still running
- if pgrep -f "$process_path" > /dev/null; then
- echo "❌ Failed to kill $process_name. It is still running."
- else
- echo "✅ Successfully killed $process_name."
- fi
- else
- echo "⚠️ Process $process_name not found. It may not be running."
- fi
- }
- # === MAIN EXECUTION ===
- # Show initial notification
- show_notification "Mosyle App Crashing" "Starting to crash Mosyle apps and processes to unblock your apps..."
- # List of Mosyle processes and paths to kill
- MOSYLE_PROCESSES=(
- "/Library/Application Support/Mosyle/MosyleAuth.app/Contents/MacOS/MosyleAuth"
- "/Library/Application Support/Mosyle/Mosyle.app/Contents/MacOS/Mosyle"
- "/Library/Application Support/Mosyle/Mosyle MDM Agent.app/Contents/MacOS/Mosyle MDM Agent"
- "/Library/Application Support/Mosyle/Notification Center.app/Contents/MacOS/Notification Center"
- "/Library/Application Support/Mosyle/MosyleMonitor.app/Contents/MacOS/MosyleMonitor"
- "/Library/Application Support/Mosyle/MosyleMDM.app/Contents/MacOS/MosyleMDM"
- "/Library/Application Support/Mosyle/Mosyle.app/Contents/MacOS/msnotificationd"
- )
- # Loop through each process and try to kill it
- for process_path in "${MOSYLE_PROCESSES[@]}"; do
- process_name=$(basename "$process_path")
- crash_process "$process_name" "$process_path"
- done
- # Final notification
- show_notification "Process Check Complete" "All Mosyle processes have been checked. See the terminal for details."
- # Optional: Add a message in the console
- echo "✅ Script completed. All Mosyle processes have been checked. See above for details."
- # Optional: Wait a bit so user sees the popup
- sleep 3
- # Exit cleanly
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment