xref: /freebsd/libexec/rc/rc.d/zpool (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1#!/bin/sh
2#
3#
4
5# PROVIDE: zpool
6# REQUIRE: hostid disks
7# BEFORE: mountcritlocal
8# KEYWORD: nojail
9
10. /etc/rc.subr
11
12name="zpool"
13desc="Import ZPOOLs"
14rcvar="zfs_enable"
15start_cmd="zpool_start"
16required_modules="zfs"
17
18zpool_start()
19{
20	local cachefile
21
22	for cachefile in /etc/zfs/zpool.cache /boot/zfs/zpool.cache; do
23		if [ -r $cachefile ]; then
24			zpool import -c $cachefile -a -N
25			if [ $? -ne 0 ]; then
26				echo "Import of zpool cache ${cachefile} failed," \
27				    "will retry after root mount hold release"
28				root_hold_wait
29				zpool import -c $cachefile -a -N
30			fi
31			break
32		fi
33	done
34}
35
36load_rc_config $name
37run_rc_command "$1"
38