]> git.ipfire.org Git - thirdparty/dracut.git/blob - dracut-initramfs-restore.sh
dracut: Implement ACPI table overriding
[thirdparty/dracut.git] / dracut-initramfs-restore.sh
1 #!/bin/bash
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4
5 set -e
6
7 KERNEL_VERSION="$(uname -r)"
8
9 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
10
11 if [[ $MACHINE_ID ]] && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
12 IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
13 fi
14 [[ -f $IMG ]] || IMG="/boot/initramfs-${KERNEL_VERSION}.img"
15
16 cd /run/initramfs
17
18 [ -f .need_shutdown -a -f "$IMG" ] || exit 1
19 if zcat "$IMG" | cpio -id --quiet >/dev/null; then
20 rm -f -- .need_shutdown
21 elif xzcat "$IMG" | cpio -id --quiet >/dev/null; then
22 rm -f -- .need_shutdown
23 else
24 # something failed, so we clean up
25 echo "Unpacking of $IMG to /run/initramfs failed" >&2
26 rm -f -- /run/initramfs/shutdown
27 exit 1
28 fi
29
30 exit 0