Blame 0025-dracut-initramfs-restore.sh-also-look-for-image-in-b.patch

Harald Hoyer a20c0e
From 449b0e0707ee13c1417c3708ea5f4b6bc5d50216 Mon Sep 17 00:00:00 2001
Harald Hoyer a20c0e
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer a20c0e
Date: Wed, 13 Mar 2013 13:09:13 +0100
Harald Hoyer a20c0e
Subject: [PATCH] dracut-initramfs-restore.sh: also look for image in boot
Harald Hoyer a20c0e
 loader spec dir
Harald Hoyer a20c0e
Harald Hoyer a20c0e
---
Harald Hoyer a20c0e
 dracut-initramfs-restore.sh | 19 +++++++++++++++----
Harald Hoyer a20c0e
 1 file changed, 15 insertions(+), 4 deletions(-)
Harald Hoyer a20c0e
Harald Hoyer a20c0e
diff --git a/dracut-initramfs-restore.sh b/dracut-initramfs-restore.sh
Harald Hoyer a20c0e
index 06e2939..33ae6bd 100644
Harald Hoyer a20c0e
--- a/dracut-initramfs-restore.sh
Harald Hoyer a20c0e
+++ b/dracut-initramfs-restore.sh
Harald Hoyer a20c0e
@@ -1,17 +1,28 @@
Harald Hoyer a20c0e
-#!/bin/sh
Harald Hoyer a20c0e
+#!/bin/bash
Harald Hoyer a20c0e
 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer a20c0e
 # ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer a20c0e
 
Harald Hoyer a20c0e
 set -e
Harald Hoyer a20c0e
+
Harald Hoyer a20c0e
+KERNEL_VERSION="$(uname -r)"
Harald Hoyer a20c0e
+
Harald Hoyer a20c0e
+[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
Harald Hoyer a20c0e
+
Harald Hoyer a20c0e
+if [[ $MACHINE_ID ]] && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
Harald Hoyer a20c0e
+    IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
Harald Hoyer a20c0e
+fi
Harald Hoyer a20c0e
+[[ -f $IMG ]] || IMG="/boot/initramfs-${KERNEL_VERSION}.img"
Harald Hoyer a20c0e
+
Harald Hoyer a20c0e
 cd /run/initramfs
Harald Hoyer a20c0e
-IMG="/boot/initramfs-$(uname -r).img"
Harald Hoyer a20c0e
+
Harald Hoyer a20c0e
 [ -f .need_shutdown -a -f "$IMG" ] || exit 1
Harald Hoyer a20c0e
-if zcat "$IMG"  | cpio -id >/dev/null 2>&1; then
Harald Hoyer a20c0e
+if zcat "$IMG"  | cpio -id --quiet >/dev/null; then
Harald Hoyer a20c0e
     rm .need_shutdown
Harald Hoyer a20c0e
-elif xzcat "$IMG"  | cpio -id >/dev/null 2>&1; then
Harald Hoyer a20c0e
+elif xzcat "$IMG"  | cpio -id --quiet >/dev/null; then
Harald Hoyer a20c0e
     rm .need_shutdown
Harald Hoyer a20c0e
 else
Harald Hoyer a20c0e
     # something failed, so we clean up
Harald Hoyer a20c0e
+    echo "Unpacking of $IMG to /run/initramfs failed" >&2
Harald Hoyer a20c0e
     rm -f /run/initramfs/shutdown
Harald Hoyer a20c0e
     exit 1
Harald Hoyer a20c0e
 fi