-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_constants_and_install_next_untested_kernel.sh
More file actions
executable file
·50 lines (42 loc) · 1.48 KB
/
Copy pathcheck_constants_and_install_next_untested_kernel.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.48 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
#!/bin/sh
die() {
if [ $# -lt 1 ]; then
echo "ERROR: unexpected error, exiting."
else
echo "ERROR: $1, exiting."
fi
exit 1
}
CURRENT_KERN=$(uname -r)
if [ ! -f $CURRENT_KERN.res ]; then
echo "First, generating result for current $CURRENT_KERN kernel version"
./check_constants.sh || die "checking constants"
fi
# grab available kernels
if [ ! -f avail_kernels.txt ]; then
echo "avail_kernels.txt not present, generate it"
./list_avail_kernels.sh
fi
# check for the next kernel version for wich we did not have any constant result yet
TO_INSTALL=""
for K in $(cat avail_kernels.txt); do
VERSION=${K#linux-image-}
if [ ! -f $VERSION.res ]; then
TO_INSTALL=$K
break
fi
done
if [ -z "$TO_INSTALL" ]; then # all available kernel version were tested
echo "All available kernel were checked"
echo "You should now consider installing back your wanted kernel. Older ones have been backuped to /boot/backup"
echo "(move back your wanted kernel to /boot and run grub-update)"
exit 0
fi
# install next kernel
echo "Results for $TO_INSTALL are missing. I will installing it for you:"
sudo apt-get install "$TO_INSTALL" || die "apt-get install $TO_INSTALL"
# update grub to boot on it
sudo mkdir -p /boot/backup/ || die "mkdir -p /boot/backup/"
sudo mv /boot/*$CURRENT_KERN* /boot/backup/|| die "mv /boot/*$CURRENT_KERN* /boot/backup/"
sudo update-grub || die "update-grub"
echo "You can now reboot and relaunch this script!"