You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.8 KiB

  1. #!/bin/bash
  2. echo 'Unpatcher starting. If this fails, try recreating the installer USB using'
  3. echo 'createinstallmedia.'
  4. echo
  5. # Check for --no-sync option
  6. if [ "x$1" = "x--no-sync" ]
  7. then
  8. SKIP_SYNC="YES"
  9. shift
  10. fi
  11. # Allow the user to drag-and-drop the USB stick in Terminal, to specify the
  12. # path to the USB stick in question. (Otherwise it will try hardcoded paths
  13. # for a presumed Big Sur Golden Master/public release, beta 2-or-later,
  14. # and beta 1, in that order.)
  15. if [ -z "$1" ]
  16. then
  17. for x in "Install macOS Big Sur" "Install macOS Big Sur Beta" "Install macOS Beta"
  18. do
  19. if [ -d "/Volumes/$x/$x.app" ]
  20. then
  21. VOLUME="/Volumes/$x"
  22. APPPATH="$VOLUME/$x.app"
  23. break
  24. fi
  25. done
  26. if [ ! -d "$APPPATH" ]
  27. then
  28. echo "Failed to locate Big Sur recovery USB stick for unpatching."
  29. echo "If all else fails, try specifying the path to the USB stick"
  30. echo "as a command line parameter to this script."
  31. echo
  32. echo "Unpatcher cannot continue and will now exit."
  33. exit 1
  34. fi
  35. else
  36. VOLUME="$1"
  37. # The use of `echo` here is to force globbing.
  38. APPPATH=`echo -n "$VOLUME"/Install\ macOS*.app`
  39. if [ ! -d "$APPPATH" ]
  40. then
  41. echo "Failed to locate Big Sur recovery USB stick for unpatching."
  42. echo "Make sure you specified the correct volume. You may also try"
  43. echo "not specifying a volume and allowing the unpatcher to find"
  44. echo "the volume itself."
  45. echo
  46. echo "Unpatcher cannot continue and will now exit."
  47. exit 1
  48. fi
  49. fi
  50. if [ ! -e "$VOLUME/Patch-Version.txt" ]
  51. then
  52. echo 'Patch not detected on USB stick, but proceeding with unpatch anyway.'
  53. echo 'This should do no harm. Any subsequent error messages are,'
  54. echo 'in all likelihood, harmless.'
  55. echo
  56. fi
  57. # Undo the boot-time compatibility check patch, if present
  58. echo 'Checking for boot-time compatibility check patch (v0.0.1/v0.0.2).'
  59. if [ -e "$VOLUME/System/Library/CoreServices/PlatformSupport.plist.inactive" ]
  60. then
  61. echo 'Removing boot-time compatibility check patch.'
  62. mv "$VOLUME/System/Library/CoreServices/PlatformSupport.plist.inactive" \
  63. "$VOLUME/System/Library/CoreServices/PlatformSupport.plist"
  64. else
  65. echo 'Boot-time compatibility check patch not present; continuing.'
  66. fi
  67. echo
  68. # Undo the com.apple.Boot.plist patch, if present
  69. echo 'Checking for com.apple.Boot.plist patch (v0.0.3+).'
  70. if [ -e "$VOLUME/Library/Preferences/SystemConfiguration/com.apple.Boot.plist.original" ]
  71. then
  72. echo 'Removing com.apple.Boot.plist patch.'
  73. cat "$VOLUME/Library/Preferences/SystemConfiguration/com.apple.Boot.plist.original" > "$VOLUME/Library/Preferences/SystemConfiguration/com.apple.Boot.plist"
  74. rm "$VOLUME/Library/Preferences/SystemConfiguration/com.apple.Boot.plist.original"
  75. else
  76. echo 'com.apple.Boot.plist patch not present; continuing.'
  77. fi
  78. echo
  79. if [ -d "$APPPATH/Contents/MacOS/InstallAssistant.app" ]
  80. then
  81. echo 'Removing trampoline.'
  82. TEMPAPP="$VOLUME/tmp.app"
  83. mv -f "$APPPATH/Contents/MacOS/InstallAssistant.app" "$TEMPAPP"
  84. rm -rf "$APPPATH"
  85. mv -f "$TEMPAPP" "$APPPATH"
  86. else
  87. echo 'Looked for trampoline (v0.2.0+) but trampoline is not present. Continuing...'
  88. fi
  89. echo 'Removing kexts, shell scripts, patcher version info, etc.'
  90. # For v0.0.9 and earlier
  91. rm -rf "$VOLUME"/*.kext
  92. rm -f "$VOLUME"/*.kext.zip
  93. # For v0.0.10 and later
  94. rm -rf "$VOLUME"/kexts
  95. # For v0.3.3 and later
  96. rm -f "$VOLUME"/kmutil*
  97. # For v0.4.2 and later
  98. rm -f "$VOLUME"/bless*
  99. # For v0.4.5pre
  100. rm -f "$VOLUME"/patch.*
  101. # For v0.5.0 and later
  102. rm -rf "$VOLUME"/bin
  103. # For all versions
  104. rm -f "$VOLUME"/*.sh "$VOLUME/Patch-Version.txt"
  105. echo 'Remvoing Hax dylibs...'
  106. rm -f "$VOLUME"/Hax*.dylib
  107. rm -rf "$VOLUME"/Hax*.app
  108. if [ "x$SKIP_SYNC" != "xYES" ]
  109. then
  110. echo
  111. echo 'Syncing.'
  112. sync
  113. fi
  114. echo
  115. echo 'Unpatcher finished.'