forked from dmhacker/arch-linux-surface
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·190 lines (158 loc) · 6.59 KB
/
setup.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
#!/usr/bin/bash
echo "This script was created to simplify the setup process for Surface devices running Arch Linux."
echo
cache_folder=.cache_setup
patches_repository=git://github.com/jakeday/linux-surface.git
patches_src_folder=linux-surface
firmware_src_folder="$cache_folder/$patches_src_folder/firmware"
############################### CACHE CREATION ###############################
# This cache is purely temporary (fixes issues with superuser permissions)
echo "Creating temporary cache ..."
mkdir -p $cache_folder
cd $cache_folder
# Only the patches repository needs to be tracked
if [ -d $patches_src_folder ]; then
cd $patches_src_folder && git pull && cd ..
else
git clone $patches_repository $patches_src_folder
fi
# Exit the cache folder
cd ..
############################### INSTALLATION ###############################
# Prompt for installation of root files
echo
read -r -p "Copy config files from jakeday's kernel to root? [y/N] "
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Unpacking files to / ..."
cp -r $cache_folder/$patches_src_folder/root/etc/* /etc
mkdir -p /lib/systemd/system-sleep
cp $cache_folder/$patches_src_folder/root/lib/systemd/system-sleep/sleep /lib/systemd/system-sleep
echo "Making /lib/systemd/system-sleep/sleep executable ..."
chmod a+x /lib/systemd/system-sleep/sleep
echo "Done copying config files."
fi
# Prompt for replacement of suspend with hibernate
echo
read -r -p "Replace suspend with hibernate? [y/N] "
# User selected 'yes' option
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Symlinking suspend target/service to hibernate target/service ..."
ln -sf /lib/systemd/system/hibernate.target /etc/systemd/system/suspend.target
ln -sf /lib/systemd/system/systemd-hibernate.service /etc/systemd/system/systemd-suspend.service
echo "Done replacing suspend with hibernate."
fi
# Prompt for installation of WiFi firmware
echo
read -r -p "Install WiFi firmware (marvel, mwlwifi)? [y/N] "
# User selected 'yes' option
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "Unpacking files to /lib/firmware/mrvl ..."
mkdir -p /lib/firmware/mrvl/
unzip -o $firmware_src_folder/mrvl_firmware.zip -d /lib/firmware/mrvl
echo "Done installing marvel firmware."
echo "Unpacking files to /lib/firmware/mwlwifi ..."
mkdir -p /lib/firmware/mwlwifi/
unzip -o $firmware_src_folder/mwlwifi_firmware.zip -d /lib/firmware/mwlwifi
echo "Done installing mwlwifi firmware."
fi
# Prompt for installation for model-based firmware
echo
read -r -p "Install device-specific firmware (touchscreen, wireless, GPU)? [y/N] "
# User selected 'yes' option
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "What Surface model is your device? Enter the number corresponding to your selection."
select SURFACE_MODEL in "Surface Pro 3" "Surface Pro 4" "Surface Pro 2017" "Surface Pro 6" "Surface Laptop" "Surface Book" "Surface Book 2 13\"" "Surface Book 2 15\"" "Surface Go"; do
break;
done
echo "$SURFACE_MODEL selected. Installing firmware ..."
i915_folder=/lib/firmware/i915/
intel_ipts_folder=/lib/firmware/intel/ipts/
nvidia_folder=/lib/firmware/nvidia/gp108/
ath10k_folder=/lib/firmware/ath10k
case $SURFACE_MODEL in
"Surface Pro 3")
echo "Unpacking files to $i915_folder ..."
mkdir -p $i915_folder
unzip -o $firmware_src_folder/i915_firmware_bxt.zip -d $i915_folder
;;
"Surface Pro 4")
echo "Unpacking files to $intel_ipts_folder ..."
mkdir -p $intel_ipts_folder
unzip -o $firmware_src_folder/ipts_firmware_v78.zip -d $intel_ipts_folder
echo "Unpacking files to $i915_folder ..."
mkdir -p $i915_folder
unzip -o $firmware_src_folder/i915_firmware_skl.zip -d $i915_folder
;;
"Surface Pro 2017")
echo "Unpacking files to $intel_ipts_folder ..."
mkdir -p $intel_ipts_folder
unzip -o $firmware_src_folder/ipts_firmware_v102.zip -d $intel_ipts_folder
echo "Unpacking files to $i915_folder ..."
mkdir -p $i915_folder
unzip -o $firmware_src_folder/i915_firmware_kbl.zip -d $i915_folder
;;
"Surface Pro 6")
echo "Unpacking files to $intel_ipts_folder ..."
mkdir -p $intel_ipts_folder
unzip -o $firmware_src_folder/ipts_firmware_v102.zip -d $intel_ipts_folder
echo "Unpacking files to $i915_folder ..."
mkdir -p $i915_folder
unzip -o $firmware_src_folder/i915_firmware_kbl.zip -d $i915_folder
;;
"Surface Laptop")
echo "Unpacking files to $intel_ipts_folder ..."
mkdir -p $intel_ipts_folder
unzip -o $firmware_src_folder/ipts_firmware_v79.zip -d $intel_ipts_folder
echo "Unpacking files to $i915_folder ..."
mkdir -p $i915_folder
unzip -o $firmware_src_folder/i915_firmware_skl.zip -d $i915_folder
;;
"Surface Book")
echo "Unpacking files to $intel_ipts_folder ..."
mkdir -p $intel_ipts_folder
unzip -o $firmware_src_folder/ipts_firmware_v76.zip -d $intel_ipts_folder
echo "Unpacking files to $i915_folder ..."
mkdir -p $i915_folder
unzip -o $firmware_src_folder/i915_firmware_skl.zip -d $i915_folder
;;
"Surface Book 2 13\"")
echo "Unpacking files to $intel_ipts_folder ..."
mkdir -p $intel_ipts_folder
unzip -o $firmware_src_folder/ipts_firmware_v137.zip -d $intel_ipts_folder
echo "Unpacking files to $i915_folder ..."
mkdir -p $i915_folder
unzip -o $firmware_src_folder/i915_firmware_kbl.zip -d $i915_folder
echo "Unpacking files to $nvidia_folder ..."
mkdir -p $nvidia_folder
unzip -o $firmware_src_folder/nvidia_firmware_gp108.zip -d $nvidia_folder
;;
"Surface Book 2 15\"")
echo "Unpacking files to $intel_ipts_folder ..."
mkdir -p $intel_ipts_folder
unzip -o $firmware_src_folder/ipts_firmware_v101.zip -d $intel_ipts_folder
echo "Unpacking files to $i915_folder ..."
mkdir -p $i915_folder
unzip -o $firmware_src_folder/i915_firmware_kbl.zip -d $i915_folder
echo "Unpacking files to $nvidia_folder ..."
mkdir -p $nvidia_folder
unzip -o $firmware_src_folder/nvidia_firmware_gp108.zip -d $nvidia_folder
;;
"Surface Go")
echo "Unpacking files to $ath10k_folder ..."
mkdir -p $ath10k_folder
unzip -o $firmware_src_folder/ath10k_firmware.zip -d $ath10k_folder
;;
*)
echo "Invalid selection. Moving on."
;;
esac
fi
############################### CACHE REMOVAL ###############################
# Remove the cache folder to handle permission issues
echo ""
echo "Removing temporary cache ..."
rm -rf $cache_folder
# Yay! All done.
echo
echo "Setup process finished!"
echo "Install your patched kernel and then reboot."