Skip to content

Instantly share code, notes, and snippets.

@andrewpsp
Created January 22, 2019 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewpsp/89a246caa233fe4f5f626032d6b5b8ac to your computer and use it in GitHub Desktop.
Save andrewpsp/89a246caa233fe4f5f626032d6b5b8ac to your computer and use it in GitHub Desktop.
Script to update the Grub.
#!/bin/bash
# current version
CURRENT=$(uname -r)
#highest version in on system
HIGH=$(rpm -qa kernel | cut -c 8- | sort| head -n 1)
#number of Kernels on the system
TOTAL_KERNEL_COUNT=$(sudo egrep "^title" /boot/grub/grub.conf > number_of_brains.txt)
#highest kernel in the grub
HIGH_KERNEL_GRUB=$(grep -in `rpm -qa kernel | cut -c 8- | sort| head -n 1` number_of_brains.txt | cut -b 1)
if [ $CURRENT = $HIGH ]
then
echo " Everything up-to-date "
else
cp /boot/grub/grub.conf /boot/grub/grub.bak
default=$(expr $HIGH_KERNEL_GRUB - 1)
sed -i "s/default*/default=${default}/" /boot/grub/grub.conf
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment