#!/bin/sh

SCRIPT_PATH=$(CDPATH="" cd -- "$(dirname -- "$0")" && pwd -P)/$(basename -- "$0")

exec >/dev/console 2>&1

# Do not bother if we have an "exitrd" (shutdown ramfs) and we are not in it yet.
# (see zfs.mkinitcpio-generate-shutdown-ramfs.tmpfiles and sd-zfs-shutdown.initcpio.install)
if ! test -e /etc/initrd-release \
&& test -e /run/initramfs/shutdown \
&& test -e /run/initramfs/"$SCRIPT_PATH"; then
	set -x
	exit 0
fi

set -x

# We don't have an `umount` in the exitrd (mkinitcpio's busybox doesn't have it)
#umount -R /oldroot

zpool export -af

# vim: ft=sh ts=8 noet:
