-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
96 lines (65 loc) · 3.21 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
#!/bin/sh
#check if invoked with sudo/root rights or not
#https://stackoverflow.com/questions/18215973/how-to-check-if-running-as-root-in-a-bash-script/28776100#28776100
usercheck=$(id -u)
if test $usercheck -ne 0; then
echo ""
echo "######################## Warning ###############################"
echo ""
echo "Please run the script as root or with root privileges (sudo)."
echo "Script will exit now."
echo ""
echo "################################################################"
echo ""
#successfully finished, therefore exit 0, exit 1 would indicate an error
exit 0
fi
echo ""
echo "######################## Warning ###############################"
echo ""
echo " This Script will add non-free repositories to your system"
echo ""
echo "################################################################"
echo ""
read -r -p "Press Enter to continue or Ctrl+C to exit." key
#https://serverfault.com/questions/16204/how-to-make-bash-scripts-print-out-every-command-before-it-executes
set -v
#### sets non-free repos and install missing packages ####
#firmware for GPU and microcode for CPU
sed -e '/main$/s/$/ contrib non-free/' /etc/apt/sources.list > /etc/apt/sources.list.new
mv /etc/apt/sources.list.new /etc/apt/sources.list
apt-get update
apt-get dist-upgrade
apt-get install firmware-misc-nonfree intel-microcode
#### install systemd services ####
## for touchscreen and keyboard/touchpad
cp ./systemd/after_boot.sh ./systemd/after_resume.sh /usr/local/bin/
cp ./systemd/after_boot.service ./systemd/after_resume.service /etc/systemd/system/
chmod a+x /usr/local/bin/after_boot.sh
chmod a+x /usr/local/bin/after_resume.sh
systemctl enable after_resume.service
systemctl enable after_boot.service
#just in case, if old .service files were present
#https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/sect-managing_services_with_systemd-unit_files
systemctl daemon-reload
#### install grub conf changes ####
## for enabling surface dock Ethernet and str (suspend-to-ram)
#replace line "GRUB_CMDLINE_LINUX_DEFAULT="quiet"" with GRUB_CMDLINE_LINUX_DEFAULT="usbcore.quirks=045e:07c6:k mem_sleep_default=deep quiet" and create a backup of the original file *_orig
#https://likegeeks.com/sed-linux/#Modifying-Lines
sed -i_orig '/GRUB_CMDLINE_LINUX_DEFAULT/c GRUB_CMDLINE_LINUX_DEFAULT="usbcore.quirks=045e:07c6:k mem_sleep_default=deep quiet"' /etc/default/grub
#https://wiki.debian.org/Grub#Configuring_GRUB_v2
update-grub
#### enable suspend-then-hibernate, so after 24h automatically go from suspend -> hibernate ####
#https://askubuntu.com/questions/1072504/lid-closed-suspend-then-hibernate
#not yet implemented in the script, was not working atm, seems to conflict with the type-cover systemd service
#### install firmware-atheros + board.bin for QCA6174 ####
apt-get update
apt-get install firmware-atheros
#md5sum ./firmware/board.bin
#bc52aa5640b27fa50f9d4d144f81e169
#remove board bins from debian package
rm /lib/firmware/ath10k/QCA6174/hw3.0/board-2.bin
rm /lib/firmware/ath10k/QCA6174/hw3.0/board.bin
cp ./firmware/board.bin /lib/firmware/ath10k/QCA6174/hw3.0
set +v
read -r -p "Finished. Press Enter to exit and then please reboot system." key