Last active
August 15, 2017 21:37
-
-
Save Gabelbombe/6e6b2f048015591b69f277cc1381f6ae to your computer and use it in GitHub Desktop.
Manually upgrading AMZ Linuz requires /boot/grub/menu.lst to be manually updated ~Le Sigh
This file contains hidden or 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 | |
## Run our update | |
yum update -y \ | |
--disablerepo='*' \ | |
--enablerepo='amzn-updates' \ | |
--exclude='docker' | |
## Cleanup old kernel versions | |
package-cleanup --count=2 --oldkernels | |
INSERT="title $(grep title /etc/grub.conf |head -1 | cut -d' ' -f2-) | |
root (hd0,0) | |
kernel $(grep kernel /etc/grub.conf |head -1 |awk '{print$2}') $(grep kernel /boot/grub/menu.lst |head -1 |cut -d' ' -f3-) | |
initrd $(grep initrd /etc/grub.conf |head -1 |awk '{print$2}') $(grep initrd /boot/grub/menu.lst |head -1 |cut -d' ' -f3-) | |
" | |
## Insert as `first in line` for kernel | |
awk -v insert="${INSERT}" -v before=title ' | |
$1 == before && ! inserted { | |
print insert | |
inserted++ | |
} | |
{print} | |
' /boot/grub/menu.lst > /boot/grub/menu.lst-backup | |
## Compare for static backup | |
diff /boot/grub/menu.lst \ | |
/boot/grub/menu.lst-backup | |
## Overwrite the sucka | |
mv /boot/grub/menu.lst-backup \ | |
/boot/grub/menu.lst | |
## #yolo | |
shutdown -r now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment