Fix 'unexpected operator' bashism
[zfs.git] / dracut / 90zfs / parse-zfs.sh.in
1 #!/bin/sh
2
3 . /lib/dracut-lib.sh
4
5 # Let the command line override our host id.
6 spl_hostid=`getarg spl_hostid=`
7 if [ "${spl_hostid}" != "" ] ; then
8         info "ZFS: Using hostid from command line: ${spl_hostid}"
9         echo "${spl_hostid}" > /etc/hostid
10 elif [ -f /etc/hostid ] ; then
11         info "ZFS: Using hostid from /etc/hostid: `cat /etc/hostid`"
12 else
13         warn "ZFS: No hostid found on kernel command line or /etc/hostid.  "
14         warn "ZFS: Pools may not import correctly."
15 fi
16
17 case "$root" in
18         ""|zfs|zfs:)
19                 # We'll take root unset, root=zfs, or root=zfs:
20                 # No root set, so we want to read the bootfs attribute.  We
21                 # can't do that until udev settles so we'll set dummy values
22                 # and hope for the best later on.
23                 root="zfs:AUTO"
24                 rootok=1
25                 wait_for_zfs=1
26
27                 info "ZFS: Enabling autodetection of bootfs after udev settles."
28                 ;;
29
30         ZFS\=*|zfs:*|zfs:FILESYSTEM\=*|FILESYSTEM\=*)
31                 # root is explicit ZFS root.  Parse it now.  We can handle
32                 # a root=... param in any of the following formats:
33                 # root=ZFS=rpool/ROOT
34                 # root=zfs:rpool/ROOT
35                 # root=zfs:FILESYSTEM=rpool/ROOT
36                 # root=FILESYSTEM=rpool/ROOT
37
38                 # Strip down to just the pool/fs
39                 root="${root#zfs:}"
40                 root="${root#FILESYSTEM=}"
41                 root="zfs:${root#ZFS=}"
42                 rootok=1
43                 wait_for_zfs=1
44
45                 info "ZFS: Set ${root} as bootfs."
46                 ;;
47 esac
48
49 # Make sure Dracut is happy that we have a root and will wait for ZFS
50 # modules to settle before mounting.
51 if [ "${wait_for_zfs}" = "1" ]; then
52         ln -s /dev/null /dev/root 2>/dev/null
53         echo '[ -e /dev/zfs ]' > $hookdir/initqueue/finished/zfs.sh
54 fi