-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathkernel.sh
More file actions
70 lines (60 loc) · 1.81 KB
/
kernel.sh
File metadata and controls
70 lines (60 loc) · 1.81 KB
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
#!/bin/bash
# This script is used to add the XanMod kernel repository, fetch additional keys from the keyserver,
# and install the appropriate version of the XanMod kernel based on CPU instruction set.
# Ensure running as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi
# Detect CPU instruction set and set kernel version
level=$(awk 'BEGIN {
while (!/flags/) if (getline < "/proc/cpuinfo" != 1) exit 1
if (/lm/&&/cmov/&&/cx8/&&/fpu/&&/fxsr/&&/mmx/&&/syscall/&&/sse2/) level = 1
if (level == 1 && /cx16/&&/lahf/&&/popcnt/&&/sse4_1/&&/sse4_2/&&/ssse3/) level = 2
if (level == 2 && /avx/&&/avx2/&&/bmi1/&&/bmi2/&&/f16c/&&/fma/&&/abm/&&/movbe/&&/xsave/) level = 3
if (level == 3 && /avx512f/&&/avx512bw/&&/avx512cd/&&/avx512dq/&&/avx512vl/) level = 4
if (level > 0) { print level; exit level + 1 }
exit 1
}')
case "$level" in
1)
kernel_package="linux-xanmod-lts-x64v1"
;;
2)
kernel_package="linux-xanmod-lts-x64v2"
;;
3)
kernel_package="linux-xanmod-lts-x64v3"
;;
4)
# kernel_package="linux-xanmod-lts-x64v4"
kernel_package="linux-xanmod-lts-x64v3"
;;
*)
echo "Unable to determine appropriate Xanmod kernel version."
exit 1
;;
esac
# Download the XanMod kernel
echo "Downloading $kernel_package"
curl -L -o ${kernel_package}.deb https://github.com/dler-io/script/raw/main/kernel/${kernel_package}.deb
if [ $? -ne 0 ]; then
echo "Failed to download $kernel_package"
exit 1
fi
# Install the XanMod kernel
echo "Installing $kernel_package"
dpkg -i ${kernel_package}.deb
if [ $? -ne 0 ]; then
echo "Failed to install $kernel_package"
exit 1
fi
update-grub
echo "The system will reboot in 10 seconds. Press Ctrl+C to cancel."
for i in {10..1}
do
echo "$i..."
sleep 1
done
echo "Rebooting now!"
reboot