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