This repository has been archived by the owner on Mar 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install_downloads.sh
executable file
·247 lines (223 loc) · 7.37 KB
/
install_downloads.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
#!/bin/bash
#set -x
SUDO=sudo
#SUDO='echo #'
#SUDO=nothing
TAG=tag_file
TAGCMD=`pwd`/tools/tag
SLE=/System/Library/Extensions
LE=/Library/Extensions
EXCEPTIONS="Sensors|BrcmPatchRAM|BrcmNonPatchRAM|BrcmNonPatchRAM2|BrcmBluetoothInjector|BrcmFirmwareData|USBInjectAll"
# extract minor version (eg. 10.9 vs. 10.10 vs. 10.11)
MINOR_VER=$([[ "$(sw_vers -productVersion)" =~ [0-9]+\.([0-9]+) ]] && echo ${BASH_REMATCH[1]})
# install to /Library/Extensions for 10.11 or greater
if [[ $MINOR_VER -ge 11 ]]; then
KEXTDEST=$LE
else
KEXTDEST=$SLE
fi
# this could be removed if 'tag' can be made to work on old systems
function tag_file
{
if [[ $MINOR_VER -ge 9 ]]; then
$SUDO "$TAGCMD" "$@"
fi
}
function check_directory
{
for x in $1; do
if [ -e "$x" ]; then
return 1
else
return 0
fi
done
}
function nothing
{
:
}
function install_kext
{
if [ "$1" != "" ]; then
echo installing $1 to $KEXTDEST
#$SUDO rm -Rf $SLE/`basename $1` $KEXTDEST/`basename $1`
$SUDO mv $SLE/`basename $1` $SLE/`basename $1.bak`
$TAG -a Red $SLE/`basename $1`.bak
$SUDO mv $KEXTDEST/`basename $1` $KEXTDEST/`basename $1.bak`
$TAG -a Red $KEXTDEST/`basename $1.bak`
$SUDO cp -Rf $1 $KEXTDEST
$TAG -a Gray $KEXTDEST/`basename $1`
fi
}
function install_app
{
if [ "$1" != "" ]; then
echo installing $1 to /Applications/Utilities
$SUDO rm -Rf /Applications/Utilities/`basename $1`
$SUDO cp -Rf $1 /Applications/Utilities
$TAG -a Gray /Applications/Utilities/`basename $1`
fi
}
function install_binary
{
if [ "$1" != "" ]; then
echo installing $1 to /usr/bin
#$SUDO rm -f /usr/bin/`basename $1`
$SUDO mv /usr/bin/`basename $1` /usr/bin/`basename $1.bak`
$SUDO cp -f $1 /usr/bin
$TAG -a Gray /usr/bin/`basename $1`
fi
}
function install
{
installed=0
out=${1/.zip/}
rm -Rf $out/* && unzip -q -d $out $1
check_directory $out/Release/*.kext
if [ $? -ne 0 ]; then
for kext in $out/Release/*.kext; do
# install the kext when it exists regardless of filter
kextname="`basename $kext`"
if [[ -e "$SLE/$kextname" || -e "$KEXTDEST/$kextname" || "$2" == "" || "`echo $kextname | grep -vE "$2"`" != "" ]]; then
install_kext $kext
fi
done
installed=1
fi
check_directory $out/*.kext
if [ $? -ne 0 ]; then
for kext in $out/*.kext; do
# install the kext when it exists regardless of filter
kextname="`basename $kext`"
if [[ -e "$SLE/$kextname" || -e "$KEXTDEST/$kextname" || "$2" == "" || "`echo $kextname | grep -vE "$2"`" != "" ]]; then
install_kext $kext
fi
done
installed=1
fi
check_directory $out/Release/*.app
if [ $? -ne 0 ]; then
for app in $out/Release/*.app; do
install_app $app
done
installed=1
fi
check_directory $out/*.app
if [ $? -ne 0 ]; then
for app in $out/*.app; do
install_app $app
done
installed=1
fi
if [ $installed -eq 0 ]; then
check_directory $out/*
if [ $? -ne 0 ]; then
for tool in $out/*; do
install_binary $tool
done
fi
fi
}
if [ "$(id -u)" != "0" ]; then
echo "This script requires superuser access..."
fi
# unzip/install tools
check_directory ./downloads/tools/*.zip
if [ $? -ne 0 ]; then
echo Installing tools...
cd ./downloads/tools
for tool in *.zip; do
install $tool
done
cd ../..
fi
if [ "$1" != "toolsonly" ]; then
# unzip/install kexts
check_directory ./downloads/kexts/*.zip
if [ $? -ne 0 ]; then
echo Installing kexts...
cd ./downloads/kexts
for kext in *.zip; do
install $kext "$EXCEPTIONS"
done
if [[ $MINOR_VER -ge 11 ]]; then
# 10.11 needs BrcmPatchRAM2.kext
cd RehabMan-BrcmPatchRAM*/Release && install_kext BrcmPatchRAM2.kext && cd ../..
# 10.11 needs USBInjectAll.kext
cd RehabMan-USBInjectAll*/Release && install_kext USBInjectAll.kext && cd ../..
# remove BrcPatchRAM.kext just in case
#$SUDO rm -Rf $SLE/BrcmPatchRAM.kext $KEXTDEST/BrcmPatchRAM.kext
$SUDO mv $SLE/BrcmPatchRAM.kext $SLE/BrcmPatchRAM.kext.bak
$SUDO mv $KEXTDEST/BrcmPatchRAM.kext $KEXTDEST/BrcmPatchRAM.kext.bak
# remove injector just in case
$SUDO rm -Rf $SLE/BrcmBluetoothInjector.kext $KEXTDEST/BrcmBluetoothInjector.kext
else
# prior to 10.11, need BrcmPatchRAM.kext
cd RehabMan-BrcmPatchRAM*/Release && install_kext BrcmPatchRAM.kext && cd ../..
# remove BrcPatchRAM2.kext just in case
$SUDO rm -Rf $SLE/BrcmPatchRAM2.kext $KEXTDEST/BrcmPatchRAM2.kext
# remove injector just in case
$SUDO rm -Rf $SLE/BrcmBluetoothInjector.kext $KEXTDEST/BrcmBluetoothInjector.kext
fi
# this guide does not use BrcmFirmwareData.kext
$SUDO rm -Rf $SLE/BrcmFirmwareData.kext $KEXTDEST/BrcmFirmwareData.kext
# now using IntelBacklight.kext instead of ACPIBacklight.kext
$SUDO rm -Rf $SLE/ACPIBacklight.kext $KEXTDEST/ACPIBacklight.kext
# since EHCI #1 is disabled, FakePCIID_XHCIMux.kext cannot be used
#$SUDO rm -Rf $KEXTDEST/FakePCIID_XHCIMux.kext
# deal with some renames
#if [[ -e $KEXTDEST/FakePCIID_Broadcom_WiFi.kext ]]; then
# remove old FakePCIID_BCM94352Z_as_BCM94360CS2.kext
#$SUDO rm -Rf $SLE/FakePCIID_BCM94352Z_as_BCM94360CS2.kext $KEXTDEST/FakePCIID_BCM94352Z_as_BCM94360CS2.kext
#fi
#if [[ -e $KEXTDEST/FakePCIID_Intel_HD_Graphics.kext ]]; then
# remove old FakePCIID_HD4600_HD4400.kext
#$SUDO rm -Rf $SLE/FakePCIID_HD4600_HD4400.kext $KEXTDEST/FakePCIID_HD4600_HD4400.kext
#fi
cd ../..
fi
# install kexts in the repo itself
# patching AppleHDA
HDA=ALC235
$SUDO rm -Rf $KEXTDEST/AppleHDA_$HDA.kext
$SUDO rm -Rf $KEXTDEST/AppleHDAHCD_$HDA.kext
$SUDO rm -f $SLE/AppleHDA.kext/Contents/Resources/*.zml*
./patch_hda.sh "$HDA"
if [[ $MINOR_VER -le 9 ]]; then
# dummyHDA configuration
make AppleHDA_$HDA.kext
install_kext AppleHDA_$HDA.kext
else
# alternate configuration (requires .xml.zlib .zml.zlib AppleHDA patch)
#make AppleHDAHCD_$HDA.kext
#install_kext AppleHDAHCD_$HDA.kext
$SUDO cp AppleHDA_${HDA}_Resources/*.zml* $SLE/AppleHDA.kext/Contents/Resources
$TAG -a Gray $SLE/AppleHDA.kext
fi
#if [[ $MINOR_VER -ge 11 ]]; then
# create custom AppleBacklightInjector.kext and install
#./patch_backlight.sh
#install_kext AppleBacklightInjector.kext
# remove ACPIBacklight.kext if it is installed (doesn't work with 10.11)
#if [ -d $SLE/ACPIBacklight.kext ]; then
# $SUDO rm -Rf $SLE/ACPIBacklight.kext
#fi
#fi
#check_directory *.kext
#if [ $? -ne 0 ]; then
# for kext in *.kext; do
# install_kext $kext
# done
#fi
# force cache rebuild with output
$SUDO touch $SLE && $SUDO kextcache -u /
# install VoodooPS2Daemon
echo Installing VoodooPS2Daemon to /usr/bin and /Library/LaunchDaemons...
cd ./downloads/kexts/RehabMan-Voodoo-*
$SUDO cp ./Release/VoodooPS2Daemon /usr/bin
$TAG -a Gray /usr/bin/VoodooPS2Daemon
$SUDO cp ./org.rehabman.voodoo.driver.Daemon.plist /Library/LaunchDaemons
$TAG -a Gray /Library/LaunchDaemons/org.rehabman.voodoo.driver.Daemon.plist
cd ../../..
fi # "toolsonly"