Created
January 22, 2019 19:46
-
-
Save andrewpsp/89a246caa233fe4f5f626032d6b5b8ac to your computer and use it in GitHub Desktop.
Script to update the Grub.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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