]>
git.ipfire.org Git - thirdparty/dracut.git/blob - dracut-initramfs-restore.sh
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
7 KERNEL_VERSION
="$(uname -r)"
9 [[ $dracutbasedir ]] || dracutbasedir
=/usr
/lib
/dracut
10 SKIP
="$dracutbasedir/skipcpio"
11 [[ -x $SKIP ]] || SKIP
=cat
13 [[ -f /etc
/machine-id
]] && read MACHINE_ID
< /etc
/machine-id
15 if [[ $MACHINE_ID ]] && [[ -d /boot
/${MACHINE_ID} ||
-L /boot
/${MACHINE_ID} ]] ; then
16 IMG
="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
18 [[ -f $IMG ]] || IMG
="/boot/initramfs-${KERNEL_VERSION}.img"
22 [ -f .need_shutdown
-a -f "$IMG" ] ||
exit 1
23 if $SKIP "$IMG" | zcat |
cpio -id --no-absolute-filenames --quiet >/dev
/null
; then
24 rm -f -- .need_shutdown
25 elif $SKIP "$IMG" | xzcat |
cpio -id --no-absolute-filenames --quiet >/dev
/null
; then
26 rm -f -- .need_shutdown
27 elif $SKIP "$IMG" | lz4
-d -c |
cpio -id --no-absolute-filenames --quiet >/dev
/null
; then
28 rm -f -- .need_shutdown
30 # something failed, so we clean up
31 echo "Unpacking of $IMG to /run/initramfs failed" >&2
32 rm -f -- /run
/initramfs
/shutdown