From 63aa1778346e05a2a2ade92388d3a6d965536903 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Thu, 9 Mar 2017 18:30:37 -0500 Subject: [PATCH] Fix grub grepping code for RS Public Cloud It appears images in the public cloud uses Grub 2 instead of Grub 1 configuration. Change-Id: I138f8d118d81ae2b64bae84e1f0cc4a0f0d3771f Signed-off-by: Thanh Ha --- packer/provision/baseline.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packer/provision/baseline.sh b/packer/provision/baseline.sh index 1e60ea874..8a9971f78 100644 --- a/packer/provision/baseline.sh +++ b/packer/provision/baseline.sh @@ -11,14 +11,21 @@ ensure_kernel_install() { # run quietly, so we may not notice the failure. This script retries for a # few times before giving up. initramfs_ver=$(rpm -q kernel | tail -1 | sed "s/kernel-/initramfs-/") + grub_conf="/boot/grub/grub.conf" + # Public cloud does not use /boot/grub/grub.conf and uses grub2 instead. + if [ ! -e "$grub_conf" ]; then + echo "$grub_conf not found. Using Grub 2 conf instead." + grub_conf="/boot/grub2/grub.cfg" + fi + for i in $(seq 3); do - if grep "$initramfs_ver" /boot/grub/grub.conf; then + if grep "$initramfs_ver" "$grub_conf"; then break fi echo "Kernel initrd missing. Retrying to install kernel..." yum reinstall -y kernel done - if ! grep "$initramfs_ver" /boot/grub/grub.conf; then + if ! grep "$initramfs_ver" "$grub_conf"; then cat /boot/grub/grub.conf echo "ERROR: Failed to install kernel." exit 1 -- 2.36.6