Blame 0065-51-dracut-rescue-postinst.sh-Rename-image-and-grub-e.patch

Harald Hoyer 4413d3
From 967db700905e0f54a159152352116b995ec38737 Mon Sep 17 00:00:00 2001
Harald Hoyer 4413d3
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 4413d3
Date: Wed, 20 Mar 2013 06:39:13 +0100
Harald Hoyer 4413d3
Subject: [PATCH] 51-dracut-rescue-postinst.sh: Rename image and grub entry
Harald Hoyer 4413d3
Harald Hoyer 4413d3
grub2-mkconfig ordered the rescue entries higher than the normal ones.
Harald Hoyer 4413d3
Harald Hoyer 4413d3
https://bugzilla.redhat.com/show_bug.cgi?id=923439
Harald Hoyer 4413d3
---
Harald Hoyer 4413d3
 51-dracut-rescue-postinst.sh | 22 +++++++++++++---------
Harald Hoyer 4413d3
 1 file changed, 13 insertions(+), 9 deletions(-)
Harald Hoyer 4413d3
Harald Hoyer 4413d3
diff --git a/51-dracut-rescue-postinst.sh b/51-dracut-rescue-postinst.sh
Harald Hoyer 4413d3
index d206496..8b4e6c3 100755
Harald Hoyer 4413d3
--- a/51-dracut-rescue-postinst.sh
Harald Hoyer 4413d3
+++ b/51-dracut-rescue-postinst.sh
Harald Hoyer 4413d3
@@ -13,8 +13,10 @@ KERNEL_IMAGE="$2"
Harald Hoyer 4413d3
 [[ $MACHINE_ID ]] || exit 1
Harald Hoyer 4413d3
 [[ -f $KERNEL_IMAGE ]] || exit 1
Harald Hoyer 4413d3
 
Harald Hoyer 4413d3
-INITRDFILE="/boot/initramfs-${MACHINE_ID}-rescue.img"
Harald Hoyer 4413d3
-[[ -f $INITRDFILE ]] && exit 0
Harald Hoyer 4413d3
+INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
Harald Hoyer 4413d3
+NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
Harald Hoyer 4413d3
+
Harald Hoyer 4413d3
+[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
Harald Hoyer 4413d3
 
Harald Hoyer 4413d3
 dropindirs_sort()
Harald Hoyer 4413d3
 {
Harald Hoyer 4413d3
@@ -46,15 +48,17 @@ done
Harald Hoyer 4413d3
 
Harald Hoyer 4413d3
 [[ $dracut_rescue_image != "yes" ]] && exit 0
Harald Hoyer 4413d3
 
Harald Hoyer 4413d3
-dracut --no-hostonly  -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
Harald Hoyer 4413d3
-((ret+=$?))
Harald Hoyer 4413d3
-
Harald Hoyer 4413d3
-cp "$KERNEL_IMAGE" "${KERNEL_IMAGE%/*}/vmlinuz-${MACHINE_ID}-rescue"
Harald Hoyer 4413d3
-((ret+=$?))
Harald Hoyer 4413d3
+if [[ ! -f $INITRDFILE ]]; then
Harald Hoyer 4413d3
+    dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
Harald Hoyer 4413d3
+    ((ret+=$?))
Harald Hoyer 4413d3
+fi
Harald Hoyer 4413d3
 
Harald Hoyer 4413d3
-KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-${MACHINE_ID}-rescue"
Harald Hoyer 4413d3
+if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
Harald Hoyer 4413d3
+    cp "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
Harald Hoyer 4413d3
+    ((ret+=$?))
Harald Hoyer 4413d3
+fi
Harald Hoyer 4413d3
 
Harald Hoyer 4413d3
-new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$PRETTY_NAME Rescue"
Harald Hoyer 4413d3
+new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"
Harald Hoyer 4413d3
 
Harald Hoyer 4413d3
 ((ret+=$?))
Harald Hoyer 4413d3