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 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
11 if [[ $MACHINE_ID ]] && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
12 IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
14 [[ -f $IMG ]] || IMG="/boot/initramfs-${KERNEL_VERSION}.img"
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
24 # something failed, so we clean up
25 echo "Unpacking of $IMG to /run/initramfs failed" >&2
26 rm -f -- /run/initramfs/shutdown