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