xref: /freebsd/libexec/rc/rc.d/zpool (revision f30f11f878fe2aa535cd286810d31c92793a3d95)
174e2b24fSCy Schubert#!/bin/sh
274e2b24fSCy Schubert#
374e2b24fSCy Schubert# $FreeBSD$
474e2b24fSCy Schubert#
574e2b24fSCy Schubert
674e2b24fSCy Schubert# PROVIDE: zpool
70cd66978SXin LI# REQUIRE: hostid disks
890802d88SXin LI# BEFORE: mountcritlocal
974e2b24fSCy Schubert# KEYWORD: nojail
1074e2b24fSCy Schubert
1174e2b24fSCy Schubert. /etc/rc.subr
1274e2b24fSCy Schubert
1374e2b24fSCy Schubertname="zpool"
1474e2b24fSCy Schubertdesc="Import ZPOOLs"
1574e2b24fSCy Schubertrcvar="zfs_enable"
1674e2b24fSCy Schubertstart_cmd="zpool_start"
1774e2b24fSCy Schubertrequired_modules="zfs"
1874e2b24fSCy Schubert
1974e2b24fSCy Schubertzpool_start()
2074e2b24fSCy Schubert{
2174e2b24fSCy Schubert	local cachefile
2274e2b24fSCy Schubert
23a7841850SCy Schubert	for cachefile in /etc/zfs/zpool.cache /boot/zfs/zpool.cache; do
2474e2b24fSCy Schubert		if [ -r $cachefile ]; then
25*f30f11f8SChuck Tuffli			zpool import -c $cachefile -a -N
26*f30f11f8SChuck Tuffli			if [ $? -ne 0 ]; then
27*f30f11f8SChuck Tuffli				echo "Import of zpool cache ${cachefile} failed," \
28*f30f11f8SChuck Tuffli				    "will retry after root mount hold release"
29*f30f11f8SChuck Tuffli				root_hold_wait
30*f30f11f8SChuck Tuffli				zpool import -c $cachefile -a -N
31*f30f11f8SChuck Tuffli			fi
32*f30f11f8SChuck Tuffli			break
3374e2b24fSCy Schubert		fi
3474e2b24fSCy Schubert	done
3574e2b24fSCy Schubert}
3674e2b24fSCy Schubert
3774e2b24fSCy Schubertload_rc_config $name
3874e2b24fSCy Schubertrun_rc_command "$1"
39