bash: initial commit of fix-kernel-install.bash as a friend to fixgrub.bash

Yes, this is a horrible hack that looks horrible.
This commit is contained in:
Aminda Suomalainen 2024-05-03 19:51:05 +03:00
parent a68d08c515
commit 1057879d5e
Signed by: Mikaela
SSH Key Fingerprint: SHA256:CXLULpqNBdUKB6E6fLA1b/4SzG0HvKD19PbIePU175Q
2 changed files with 36 additions and 0 deletions

View File

@ -118,5 +118,11 @@ if [ -f /root/fixgrub.bash ]; then
/root/fixgrub.bash /root/fixgrub.bash
fi fi
# Lumina & Sedric have been having kernel update issues, let's see if this
# script could detect and suggest action for that.
if [ -f /root/fix-kernel-install.bash ]; then
/root/fix-kernel-install.bash
fi
# Hide commands being executed again # Hide commands being executed again
set +x set +x

30
bash/fix-kernel-install.bash Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
#set -x
export LC_ALL=C.utf8
# Check for existence of /etc/machine-id/
if [ -f /etc/machine-id ]; then
# Check for existence of the /boot/<machine-id> directory
if [ -d /boot/efi/"$(cat /etc/machine-id)" ]; then
# Store the latest installed kernel to $EXPECTEDKERNEL
EXPECTEDKERNEL="$(find /lib/modules -maxdepth 1 -printf '%P\n' | sort | tail -n -1)"
# And actual kernel in the boot/efi directory
ACTUALKERNEL="$(find /boot/efi/"$(cat /etc/machine-id)"/ -maxdepth 1 -printf '%P\n' | sort | tail -n -1)"
# Are they the same? Everything OK!
if [ "$EXPECTEDKERNEL" == "$ACTUALKERNEL" ]; then
echo "The kernel situation seems OK."
else
printf "\nWARNING! Kernels mismatch! Suggested action:\n"
printf "\tsudo kernel-install add %b /lib/modules/%b/vmlinuz\n" "$EXPECTEDKERNEL" "$EXPECTEDKERNEL"
fi
fi
fi
#set +x