xref: /freebsd/libexec/rc/rc.d/zpool (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
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
37
38# doesn't make sense to run in a svcj
39zpool_svcj="NO"
40
41run_rc_command "$1"
42