do not use dracut shutdown, if something failed while unpacking
[platform/upstream/dracut.git] / dracut-initramfs-restore.sh
1 #!/bin/sh
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 cd /run/initramfs
7 IMG="/boot/initramfs-$(uname -r).img"
8 [ -f .need_shutdown -a -f "$IMG" ] || exit 1
9 if zcat "$IMG"  | cpio -id >/dev/null 2>&1; then
10     rm .need_shutdown
11 elif xzcat "$IMG"  | cpio -id >/dev/null 2>&1; then
12     rm .need_shutdown
13 else
14     # something failed, so we clean up
15     rm -f /run/initramfs/shutdown
16     exit 1
17 fi
18
19 exit 0