Fix grub grepping code for RS Public Cloud 06/53106/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 9 Mar 2017 23:30:37 +0000 (18:30 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Thu, 9 Mar 2017 23:30:39 +0000 (18:30 -0500)
It appears images in the public cloud uses Grub 2 instead of Grub 1
configuration.

Change-Id: I138f8d118d81ae2b64bae84e1f0cc4a0f0d3771f
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
packer/provision/baseline.sh

index 1e60ea874c913c739b08aa222561cd9c0dd3628e..8a9971f78ec93db84515067a0603d175c89b33ad 100644 (file)
@@ -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