From b48f55e83516773c0440d8809d534a07af26094a Mon Sep 17 00:00:00 2001 From: Aminda Suomalainen Date: Fri, 3 May 2024 20:02:38 +0300 Subject: [PATCH] fix-kernel-install.bash: just store the machine-id to a variable as it's called so much --- bash/fix-kernel-install.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bash/fix-kernel-install.bash b/bash/fix-kernel-install.bash index 776a968..fc17f53 100755 --- a/bash/fix-kernel-install.bash +++ b/bash/fix-kernel-install.bash @@ -7,14 +7,19 @@ export LC_ALL=C.utf8 # Check for existence of /etc/machine-id/ if [ -f /etc/machine-id ]; then + # How about we just store the machine-id instead of fetching it + # constantly? + MACHINEID="$(cat /etc/machine-id)" + #echo "Our machine-id is $MACHINEID" + # Check for existence of the /boot/ directory - if [ -d /boot/efi/"$(cat /etc/machine-id)" ]; then + if [ -d /boot/efi/"$MACHINEID" ]; 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)" + ACTUALKERNEL="$(find /boot/efi/"$MACHINEID"/ -maxdepth 1 -printf '%P\n' | sort | tail -n -1)" # Are they the same? Everything OK! if [ "$EXPECTEDKERNEL" == "$ACTUALKERNEL" ]; then @@ -22,7 +27,7 @@ if [ -f /etc/machine-id ]; then else printf "\nWARNING! Kernels mismatch! Suggested actions:\n" - printf "\tsudo mkdir /boot/\"$(cat /etc/machine-id)\"/%b\n" "$EXPECTEDKERNEL" + printf "\tsudo mkdir /boot/%b\"/%b\n" "$EXPECTEDKERNEL" "$EXPECTEDKERNEL" printf "\tsudo kernel-install add %b /lib/modules/%b/vmlinuz\n" "$EXPECTEDKERNEL" "$EXPECTEDKERNEL" fi fi