MacOS.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. [ -f "/usr/bin/sudo" ] || exit 1;
  3. [ "$(sudo whoami)" == "root" ] || exit 1;
  4. sudo nvram -c >/dev/null 2>&1
  5. sudo nvram StartupMute=%01
  6. sudo defaults write com.apple.loginwindow TALLogoutSavesState -bool FALSE
  7. sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist 2>/dev/null
  8. sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.spindump.plist 2>/dev/null
  9. sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.tailspind.plist 2>/dev/null
  10. sudo find /private/var/folders -name com.apple.dock.launchpad |xargs -I {} rm -rf {} && killall Dock
  11. sipStatus="$(csrutil status |cut -d':' -f2 |grep -io 'enable\|disable')"
  12. ssvStatus="$(csrutil authenticated-root status |cut -d':' -f2 |grep -io 'enable\|disable')"
  13. [ "$sipStatus" == "disable" ] && [ "$ssvStatus" == "disable" ] || {
  14. echo -e "\n# SIP status [Command + R]\n--> csrutil disable\n--> csrutil authenticated-root disable\n"
  15. exit 1;
  16. }
  17. [ "$1" == "-" ] || exit 0
  18. temp="/tmp/MacOS"
  19. volume="/Volumes/$(ls -1 /Volumes|head -n1)"
  20. disk=`sudo mount |grep ' on / ' |cut -d' ' -f1 |cut -b1-12`
  21. [ -n "$volume" ] && [ -n "$disk" ] || exit 1
  22. mkdir -p "$temp" || exit 1
  23. echo -e "Volume: $volume\nDisk: $disk\nTemp: $temp"
  24. sudo umount "$disk" >/dev/null 2>&1
  25. sudo mount -o nobrowse -t apfs "$disk" "$temp"
  26. [ $? -eq 0 ] || exit 1
  27. read -p "Please Edit System File and Press <ENTER> to continue..."
  28. sudo bless --folder "$temp/System/Library/CoreServices" --bootefi --create-snapshot
  29. [ $? -ne 0 ] && echo "Create Snapshot Fail." && exit 1
  30. sudo diskutil apfs listSnapshots "$volume"