Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nk-gears/f14e6fb9d7361e1c94ee19c5cc713cc6 to your computer and use it in GitHub Desktop.
Save nk-gears/f14e6fb9d7361e1c94ee19c5cc713cc6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Taken from (and freely modified as no license was specified):
# https://gist.github.com/ecompayment/b1054421eb90f296bbca226683c7ff7e
# https://gist.github.com/pwnsdx/1217727ca57de2dd2a372afdd7a0fc21
# Before running this script, you must:
# - Disable FileVault (if it is enabled) Note: You will not be able to re-enable FileVault AND keep these customisations.
# - Reboot your Mac into Recovery Mode.
# - Select Terminal from top menu and run the following commands:
# csrutil authenticated-root disable
# reboot
csrutil_status="$(csrutil status|cut -f2 -d:|tr -d ' .')"
csrutil_root_status="$(csrutil authenticated-root status|cut -f2 -d:|tr -d ' .')"
fde_status="$(fdesetup isactive)"
if [[ "$fde_status" != "false" ]]; then echo "You must disable FileVault. Exiting!"; exit; fi
if [[ "$csrutil_status" != "disabled" ]]; then echo "You must disable csrutil first. Exiting!"; exit; fi
if [[ "$csrutil_root_status" != "disabled" ]]; then echo "You must disable csrutil authenticated-root first. Exiting!"; exit; fi
## https://apple.stackexchange.com/a/395509
DISK_PATH="$(mount|grep ' on / '|cut -f1 -d ' '|grep -o '/dev/disk[0-9]*s[0-9]*')"
MOUNT_PATH="${HOME}/mnt"
mkdir -p "$MOUNT_PATH" && chmod 777 "$MOUNT_PATH"
sudo mount -o nobrowse -t apfs "$DISK_PATH" "$MOUNT_PATH" || exit
TODISABLE=()
# CLOUD
TODISABLE+=('/System/Library/LaunchAgents/com.apple.cloudd.plist' \
'/System/Library/LaunchAgents/com.apple.cloudpaird.plist' \
'/System/Library/LaunchAgents/com.apple.cloudphotod.plist' \
'/System/Library/LaunchAgents/com.apple.cloudphotosd.plist' \
'/System/Library/LaunchAgents/com.apple.followupd.plist' \
'/System/Library/LaunchAgents/com.apple.icloud.searchpartyuseragent.plist' \
'/System/Library/LaunchAgents/com.apple.icloud.plist' \
'/System/Library/LaunchAgents/com.apple.iCloudNotificationAgent.plist' \
'/System/Library/LaunchAgents/com.apple.iCloudUserNotifications.plist' \
'/System/Library/LaunchAgents/com.apple.itunescloudd.plist' \
'/System/Library/LaunchAgents/com.apple.protectedcloudstorage.protectedcloudkeysyncing.plist' \
'/System/Library/LaunchAgents/com.apple.webinspectord.plist' \
'/System/Library/LaunchAgents/com.apple.security.cloudkeychainproxy3' \
# SAFARI
'/System/Library/LaunchAgents/com.apple.Safari.SafeBrowsing.Service.plist' \
'/System/Library/LaunchAgents/com.apple.SafariBookmarksSyncAgent.plist' \
'/System/Library/LaunchAgents/com.apple.SafariCloudHistoryPushAgent.plist' \
'/System/Library/LaunchAgents/com.apple.safaridavclient.plist' \
'/System/Library/LaunchAgents/com.apple.SafariHistoryServiceAgent.plist' \
'/System/Library/LaunchAgents/com.apple.SafariLaunchAgent.plist' \
'/System/Library/LaunchAgents/com.apple.SafariNotificationAgent.plist' \
'/System/Library/LaunchAgents/com.apple.SafariPlugInUpdateNotifier.plist' \
'/System/Library/LaunchAgents/com.apple.swcd.plist' \
'/System/Library/LaunchAgents/com.apple.WebKit.PluginAgent.plist' \
'/System/Library/LaunchAgents/com.apple.Safari.PasswordBreachAgent.plist' \
# AD RELATED
'/System/Library/LaunchAgents/com.apple.ap.adprivacyd.plist' \
'/System/Library/LaunchAgents/com.apple.ap.adservicesd.plist' \
'/System/Library/LaunchAgents/com.apple.ap.promotedcontentd.plist' \
# Game Center / Passbook / Apple TV / Homekit...
'/System/Library/LaunchAgents/com.apple.gamed.plist' \
'/System/Library/LaunchAgents/com.apple.passd.plist' \
'/System/Library/LaunchAgents/com.apple.Maps.pushdaemon.plist' \
'/System/Library/LaunchAgents/com.apple.videosubscriptionsd.plist' \
'/System/Library/LaunchAgents/com.apple.homed.plist' \
# SIRI
'/System/Library/LaunchAgents/com.apple.assistant_service.plist' \
'/System/Library/LaunchAgents/com.apple.assistantd.plist' \
'/System/Library/LaunchAgents/com.apple.parsec-fbf.plist' \
'/System/Library/LaunchAgents/com.apple.siri-distributed-evaluation.plist' \
'/System/Library/LaunchAgents/com.apple.Siri.agent.plist' \
'/System/Library/LaunchAgents/com.apple.siri.context.service.plist' \
'/System/Library/LaunchAgents/com.apple.siriknowledged.plist' \
# Screensharing
'/System/Library/LaunchAgents/com.apple.screensharing.MessagesAgent.plist' \
'/System/Library/LaunchAgents/com.apple.screensharing.agent.plist' \
'/System/Library/LaunchAgents/com.apple.screensharing.menuextra.plist' \
# Sidecar
'/System/Library/LaunchAgents/com.apple.sidecar-hid-relay.plist' \
'/System/Library/LaunchAgents/com.apple.sidecar-relay.plist' \
# Screentime
'/System/Library/LaunchAgents/com.apple.ScreenTimeAgent.plist' \
'/System/Library/LaunchAgents/com.apple.UsageTrackingAgent.plist' \
# Parental Control
'/System/Library/LaunchAgents/com.apple.familycircled.plist' \
'/System/Library/LaunchAgents/com.apple.familycontrols.useragent.plist' \
'/System/Library/LaunchAgents/com.apple.familynotificationd.plist' \
'/System/Library/LaunchAgents/com.apple.parentalcontrols.check.plist' \
# Classroom
'/System/Library/LaunchAgents/com.apple.progressd.plist' \
# Spotlight
'/System/Library/LaunchAgents/com.apple.corespotlightd.plist' \
'/System/Library/LaunchAgents/com.apple.corespotlightservice.plist' \
'/System/Library/LaunchAgents/com.apple.Spotlight.plist' \
'/System/Library/LaunchAgents/com.apple.metadata.mdwrite.plist' \
'/System/Library/LaunchAgents/com.apple.metadata.mdbulkimport.plist' \
'/System/Library/com.apple.metadata.mdflagwriter.plist' \
'/System/Library/com.apple.mdworker.mail.plist' \
'/System/Library/com.apple.mdmclient.agent.plist' \
'/System/Library/com.apple.mdworker.shared.plist' \
'/System/Library/com.apple.mdworker.sizing.plist' \
'/System/Library/com.apple.mdworker.single.plist.plist' \
'/System/Library/com.apple.mdworker.single.arm64.plist' \
'/System/Library/com.apple.mdworker.single.x86_64.plist' \
'/System/Library/com.apple.mdworker.sizing.plist' \
'/System/Library/com.apple.mdworker.bundles.plist' \
# iMessage / Facetime
'/System/Library/com.apple.avconferenced.plist' \
'/System/Library/com.apple.findmymacmessenger.plist' \
'/System/Library/com.apple.imagent.plist' \
'/System/Library/com.apple.imautomatichistorydeletionagent.plist' \
'/System/Library/com.apple.imklaunchagent.plist' \
'/System/Library/com.apple.imtransferagent.plist' \
# Others
'/System/Library/com.apple.macos.studentd.plist' \
'/System/Library/com.apple.photoanalysisd.plist' \
'/System/Library/com.apple.photolibraryd.plist' \
'/System/Library/com.apple.PhotoLibraryMigrationUtility.XPC.plist' \
'/System/Library/com.apple.podcasts.PodcastContentService.plist' \
'/System/Library/com.apple.softwareupdate_notify_agent.plist' \
'/System/Library/com.apple.SoftwareUpdateNotificationManager.plist' \
'/System/Library/com.apple.suggestd.plist' \
'/System/Library/com.apple.syncdefaultsd.plist' \
'/System/Library/com.apple.UsageTrackingAgent.plist' \
'/System/Library/com.apple.identityservicesd.plist' \
'/System/Library/com.apple.touristd.plist' \
'/System/Library/com.apple.appstoreagent.plist' \
'/System/Library/com.apple.storedownloadd' \
'/System/Library/LaunchDaemons/com.apple.analyticsd.plist' \
'/System/Library/LaunchDaemons/com.apple.cloudd.plist' \
'/System/Library/LaunchDaemons/com.apple.iCloudStats.plist' \
'/System/Library/LaunchDaemons/com.apple.icloud.searchpartyd.plist' \
# Spotlight
'/System/Library/LaunchDaemons/com.apple.metadata.mds.index.plist' \
'/System/Library/LaunchDaemons/com.apple.metadata.mds.plist' \
'/System/Library/LaunchDaemons/com.apple.metadata.mds.spindump.plist' \
'/System/Library/LaunchDaemons/com.apple.metadata.mds.scan.plist' \
# Others
'/System/Library/LaunchDaemons/com.apple.appleseed.fbahelperd.plist' \
'/System/Library/LaunchDaemons/com.apple.familycontrols.plist' \
'/System/Library/LaunchDaemons/com.apple.findmymac.plist' \
'/System/Library/LaunchDaemons/com.apple.findmymacmessenger.plist' \
'/System/Library/LaunchDaemons/com.apple.locate.plist' \
'/System/Library/LaunchDaemons/com.apple.locationd.plist' \
'/System/Library/LaunchDaemons/com.apple.metadata.mds.index.plist' \
'/System/Library/LaunchDaemons/com.apple.metadata.mds.scan.plist' \
'/System/Library/LaunchDaemons/com.apple.metadata.mds.spindump.plist' \
'/System/Library/LaunchDaemons/com.apple.metadata.mds.plist' \
'/System/Library/LaunchDaemons/com.apple.SubmitDiagInfo.plist' \
'/System/Library/LaunchDaemons/com.apple.mobile.softwareupdated.plist' \
'/System/Library/LaunchDaemons/com.apple.softwareupdated.plist' \
'/System/Library/LaunchDaemons/com.apple.siriinferenced'
'/System/Library/LaunchDaemons/com.apple.siri.morphunassetsupdaterd')
for plist in "${TODISABLE[@]}"; do sudo launchctl disable "user/0${MOUNT_PATH}/${plist}"; done
#----------------------- REMOVE APPS ------------------------------
APPDISABLE=()
APPDISABLE+=('/System/Applications/App Store.app' \
'/System/Applications/Books.app' \
'/System/Applications/Chess.app' \
'/System/Applications/FaceTime.app' \
'/System/Applications/Home.app' \
'/System/Applications/Maps.app' \
'/System/Applications/Messages.app' \
'/System/Applications/Music.app' \
'/System/Applications/News.app' \
'/System/Applications/Photo Booth.app' \
'/System/Applications/Photos.app' \
'/System/Applications/Podcasts.app' \
'/System/Applications/Siri.app' \
'/System/Applications/Stickies.app' \
'/System/Applications/Stocks.app' \
'/System/Applications/TV.app' \
'/System/Applications/VoiceMemos.app' \
'/System/Applications/QuickTime Player.app' \
'/Library/Apple/System/Library/CoreServices/MRT.app' \
'/System/Library/Templates/Data/Library/Apple/System/Library/CoreServices/MRT.app')
for app in "${APPDISABLE[@]}"; do if [[ -f "${MOUNT_PATH}/${app}" ]]; then sudo mv "${MOUNT_PATH}/${app}" "${MOUNT_PATH}/${app}.bak"; fi; done
# Disable Mission Control
defaults write com.apple.dock mcx-expose-disabled -bool TRUE
# Disable Dashboard
defaults write com.apple.dashboard mcx-disabled -bool TRUE
# Disable Spotlight
sudo mdutil -a -i off
sudo chmod 0 "${MOUNT_PATH}/System/Library/CoreServices/Spotlight.app"
killall Dock
## bless the system and create a persistent snapshot
sudo bless --folder "${MOUNT_PATH}/System/Library/CoreServices" --bootefi --create-snapshot
sudo umount "$MOUNT_PATH"
echo "Finished. Please review any stderr of this script and reboot."
#sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment