From 1057879d5e4eceec15860c53acf8cf759e91fc42 Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Fri, 3 May 2024 19:51:05 +0300 Subject: [PATCH] bash: initial commit of fix-kernel-install.bash as a friend to fixgrub.bash Yes, this is a horrible hack that looks horrible. --- bash/deb-update.bash | 6 ++++++ bash/fix-kernel-install.bash | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 bash/fix-kernel-install.bash diff --git a/bash/deb-update.bash b/bash/deb-update.bash index 39e89db..bd71203 100755 --- a/bash/deb-update.bash +++ b/bash/deb-update.bash @@ -118,5 +118,11 @@ if [ -f /root/fixgrub.bash ]; then /root/fixgrub.bash 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 set +x diff --git a/bash/fix-kernel-install.bash b/bash/fix-kernel-install.bash new file mode 100755 index 0000000..ca0c421 --- /dev/null +++ b/bash/fix-kernel-install.bash @@ -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/ 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