forked from RehabMan/OS-X-Clover-Laptop-Config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_downloads.sh
executable file
·193 lines (178 loc) · 5.62 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
#set -x
SUDO=sudo
#SUDO='echo #'
#SUDO=nothing
TAG=tag_file
TAGCMD=`pwd`/tools/tag
SLE=/System/Library/Extensions
LE=/Library/Extensions
EXCEPTIONS="Sensors|FakePCIID_AR9280|BrcmPatchRAM|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 cp -Rf $1 $KEXTDEST
$TAG -a Gray $KEXTDEST/`basename $1`
fi
}
function install_app
{
if [ "$1" != "" ]; then
echo installing $1 to /Applications
$SUDO rm -Rf /Applications/`basename $1`
$SUDO cp -Rf $1 /Applications
$TAG -a Gray /Applications/`basename $1`
fi
}
function install_binary
{
if [ "$1" != "" ]; then
echo installing $1 to /usr/bin
$SUDO rm -f /usr/bin/`basename $1`
$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 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
# 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
# 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
# force cache rebuild with output
$SUDO touch $SLE && $SUDO kextcache -u /
# 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
# 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 ../..