Skip to content

Add FileVault auto-detect + unlock + user artifact cleanup - #178

Open
mateussiqueira wants to merge 1 commit into
assafdori:mainfrom
mateussiqueira:fix/filevault-autodetect
Open

Add FileVault auto-detect + unlock + user artifact cleanup#178
mateussiqueira wants to merge 1 commit into
assafdori:mainfrom
mateussiqueira:fix/filevault-autodetect

Conversation

@mateussiqueira

Copy link
Copy Markdown

Problem

Issue #143 reports that the script fails silently on FileVault-encrypted Macs. The data volume can't be written to until unlocked, so all dscl/hosts/profile operations fail with no clear error.

Additionally:

Changes

FileVault auto-detect: Before any write operations, the script detects FileVault using two signals (keychain file + diskutil output). If enabled, prompts for the recovery key or volume password and unlocks with diskutil apfs unlockVolume.

User-level artifact cleanup: After removing system config profiles, iterates all users on the Data volume and removes MDM preferences and caches (com.apple.mdm.plist, com.apple.mdmclient.plist, com.apple.enrollmenttool).

Smarter volume detection: System volume is found by looking for SystemVersion.plist across all mounted volumes, not by hardcoded name. Data volume falls back to APFS listing.

Expanded blocking: Added albert.apple.com and gdmf.apple.com to the hosts blocklist.

Restored missing menu options: "Disable Notification (SIP)", "Disable Notification (Recovery)", and "Check MDM Enrollment" were missing from the menu in the original script — restored.

Testing

Tested on macOS 26 Tahoe with FileVault enabled (Apple Silicon M4). Unlock flow works with both recovery key and volume password. Reboot no longer triggers re-enrollment after user artifact cleanup.

- Auto-detect FileVault encrypted volumes before attempting writes
- Prompt for recovery key or volume password to unlock data volume
- Clean user-level MDM artifacts in /Users/*/Library
- Expand domain blocking to 5 MDM-related Apple domains
- Fix 'Not a known DirStatus' by detecting system volume via SystemVersion.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant