1#!/bin/sh
2# shellcheck disable=SC2034,SC2154
3
4# shellcheck source=zfs-lib.sh.in
5. /lib/dracut-zfs-lib.sh
6
7# Let the command line override our host id.
8spl_hostid=$(getarg spl_hostid=)
9if [ -n "${spl_hostid}" ] ; then
10	info "ZFS: Using hostid from command line: ${spl_hostid}"
11	zgenhostid -f "${spl_hostid}"
12elif [ -f "/etc/hostid" ] ; then
13	info "ZFS: Using hostid from /etc/hostid: $(hostid)"
14else
15	warn "ZFS: No hostid found on kernel command line or /etc/hostid."
16	warn "ZFS: Pools may not import correctly."
17fi
18
19if decode_root_args; then
20	if [ "$root" = "zfs:AUTO" ]; then
21		info "ZFS: Boot dataset autodetected from bootfs=."
22	else
23		info "ZFS: Boot dataset is ${root}."
24	fi
25
26	rootok=1
27	# Make sure Dracut is happy that we have a root and will wait for ZFS
28	# modules to settle before mounting.
29	if [ -n "${wait_for_zfs}" ]; then
30		ln -s null /dev/root
31		echo '[ -e /dev/zfs ]' > "${hookdir}/initqueue/finished/zfs.sh"
32	fi
33else
34	info "ZFS: no ZFS-on-root."
35fi
36