This repository has been archived by the owner on Nov 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathget-kexts.sh
executable file
·131 lines (111 loc) · 3.49 KB
/
get-kexts.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
#!/bin/bash
join () {
local IFS="$1"
shift
echo "$*"
}
xcode-select --install
wifi_enabled=0
lilu_friends=()
github=()
echo ""
read -p 'Do you want to enable Intel WiFi support? (experimental) [y/N]: ' wifi_input
# lowercase
wifi_input=$(echo "$wifi_input" | tr '[:upper:]' '[:lower:]')
if [[ $wifi_input == 'y' ]]; then
echo 'Enabled Intel WiFi support'
echo 'This kext is not considered production-ready yet. Use at own risk.'
echo ""
wifi_enabled=1
sleep 1
fi
if [[ $wifi_enabled -eq 1 ]]; then
# remove newline, add new info and re-append newline
perl -pi -e 'chomp if eof' kexts.txt
echo -e "\nOpenIntelWireless-Factory 1hbb 0" >> kexts.txt
fi
itlwm_enabled_already=$(/usr/libexec/PlistBuddy -c "Print :Kernel:Add:9:Enabled" EFI/OC/config.plist)
if [ "$wifi_enabled" -eq 0 ] && [[ "$itlwm_enabled_already" == "true" ]]; then
echo "Resetting itlwm enabled state in config.plist"
/usr/libexec/PlistBuddy -c "Set :Kernel:Add:9:Enabled false" EFI/OC/config.plist
fi
while IFS=$'\t' read -r -a kext_lines
do
if [[ ${kext_lines[2]} -eq 1 ]]
then
lilu_friends+=( ${kext_lines[0]} )
else
github+=( ${kext_lines[0]} ${kext_lines[1]} )
fi
done < kexts.txt
if [ ! -d lilu-and-friends ]; then
git clone https://github.com/corpnewt/lilu-and-friends
fi
echo ""
echo "Using Lilu-and-Friends by CorpNewt to build kexts"
echo "Available at: https://github.com/corpnewt/lilu-and-friends"
echo ""
cd lilu-and-friends
kext_list=$(join , "${lilu_friends[@]}")
sleep 2
chmod +x ./Run.command
./Run.command -rk ${kext_list[*]}
echo ""
echo "Some kexts weren't available to build from source."
echo "Attempting to find their GitHub release"
echo ""
sleep 2
if [ -f errors.txt ]; then
rm errors.txt
fi
echo "Fetching jq"
echo ""
curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 --output jq
chmod +x ./jq || echo "ERROR: jq" >> errors.txt
for ((i=0; i<${#github[@]}; i++))
do
echo "Downloading ${github[$i]}"
url=$(curl -L https://api.github.com/repos/${github[$i+1]}/${github[$i]}/releases | ./jq --raw-output '.[0].assets[0] | .browser_download_url')
echo "Fetching from $url"
(( i++ ))
(cd Kexts; curl --silent -LOJ $url)
done
echo ""
echo "Extracting and moving kexts"
cd Kexts
find . -name "*.zip" -exec unzip {} \;
find . -name "IntelBluetoothInjector.kext" -type d -exec rm -r {} +
find . -name "XHCI-unsupported.kext" -type d -exec rm -r {} +
if [[ $wifi_enabled -eq 1 ]]; then
find . -name "itlwmx.kext" -type d -exec rm -r {} +
fi
find . -name "*.kext" -exec cp -r {} ../../EFI/OC/Kexts/ \;
if [[ $wifi_enabled -eq 1 ]]; then
echo ""
echo "The Intel WiFi driver (AirportItlwm.kext) has been moved to EFI/OC/Kexts."
sleep 2
echo "This should no longer require HeliPort to function."
sleep 2
echo "For more help, go to https://github.com/OpenIntelWireless."
sleep 2
echo ""
echo "Patching config.plist"
/usr/libexec/PlistBuddy -c "Set :Kernel:Add:9:Enabled true" ../../EFI/OC/config.plist
sed -i '' -e '$ d' ../../kexts.txt
fi
if [ -f ../errors.txt ]; then
echo ""
echo "ERROR ENCOUNTERED DURING BUILD"
sleep 2
echo "Errors were encountered downloading additional kexts."
sleep 2
echo "This will result in the NUC not being able to boot correctly."
sleep 2
echo "Please try again, or if it persists, consider raising an issue on the GitHub page."
echo ""
echo "BUILD FAILED"
fi
cd ../../
echo ""
echo "Cleaning up"
rm -rf lilu-and-friends