]> git.ipfire.org Git - thirdparty/dracut.git/blob - dracut-initramfs-restore.sh
ifcfg/write-ifcfg.sh: turn on IPV6INIT, if any inet6 address is found
[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 [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
10 SKIP="$dracutbasedir/skipcpio"
11 [[ -x $SKIP ]] || SKIP=cat
12
13 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
14
15 if [[ $MACHINE_ID ]] && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
16 IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
17 fi
18 [[ -f $IMG ]] || IMG="/boot/initramfs-${KERNEL_VERSION}.img"
19
20 cd /run/initramfs
21
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
29 else
30 # something failed, so we clean up
31 echo "Unpacking of $IMG to /run/initramfs failed" >&2
32 rm -f -- /run/initramfs/shutdown
33 exit 1
34 fi
35
36 exit 0