-
Notifications
You must be signed in to change notification settings - Fork 1
/
upgrade-kernel.sh
executable file
·59 lines (49 loc) · 1.68 KB
/
upgrade-kernel.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
#!/bin/bash
function show_help() {
usage="$(basename "$0") [-q]
Script to update kernel version
-q Non-interactive mode"
echo "$usage"
echo
}
while getopts :qh option; do
case "${option}" in
q)
QUIET=1
;;
h|\?)
show_help
exit 0
esac
done
echo "Upgrade to kernel version 5.12.19"
res=$(sudo dpkg --list | grep 5.12.19)
if [ -z "$res" ]; then
pushd .
mkdir -p /tmp/kernel_v5_12
cd /tmp/kernel_v5_12
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.12.19/amd64/linux-headers-5.12.19-051219-generic_5.12.19-051219.202107201136_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.12.19/amd64/linux-headers-5.12.19-051219_5.12.19-051219.202107201136_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.12.19/amd64/linux-image-unsigned-5.12.19-051219-generic_5.12.19-051219.202107201136_amd64.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.12.19/amd64/linux-modules-5.12.19-051219-generic_5.12.19-051219.202107201136_amd64.deb
sudo dpkg -i ./*
sudo apt --fix-broken install -y
sudo update-grub
echo "New kernel installed. You can change the configuration from GRUB or simply reboot the machine with the new kernel"
if [ -z ${QUIET+x} ]; then
while true; do
read -r -p "Would you like to reboot the server to apply the new configuration? (y/n) " yn
case $yn in
[Yy]* ) sudo reboot;;
[Nn]* ) break;;
* ) echo -e "${COLOR_RED}Please answer yes or no.${COLOR_OFF}";;
esac
done
else
# Do not ask anything and reboot
sudo reboot
fi
popd
else
echo "Kernel v5.12.19 is already installed."
fi