MacOS.sh 1.5 KB

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