xref: /freebsd/libexec/rc/rc.d/zpool (revision f99f0ee14e3af81c23150a6a340259ca8a33d01a)
174e2b24fSCy Schubert#!/bin/sh
274e2b24fSCy Schubert#
374e2b24fSCy Schubert#
474e2b24fSCy Schubert
574e2b24fSCy Schubert# PROVIDE: zpool
60cd66978SXin LI# REQUIRE: hostid disks
790802d88SXin LI# BEFORE: mountcritlocal
874e2b24fSCy Schubert# KEYWORD: nojail
974e2b24fSCy Schubert
1074e2b24fSCy Schubert. /etc/rc.subr
1174e2b24fSCy Schubert
1274e2b24fSCy Schubertname="zpool"
1374e2b24fSCy Schubertdesc="Import ZPOOLs"
1474e2b24fSCy Schubertrcvar="zfs_enable"
1574e2b24fSCy Schubertstart_cmd="zpool_start"
1674e2b24fSCy Schubertrequired_modules="zfs"
1774e2b24fSCy Schubert
1874e2b24fSCy Schubertzpool_start()
1974e2b24fSCy Schubert{
2074e2b24fSCy Schubert	local cachefile
2174e2b24fSCy Schubert
22a7841850SCy Schubert	for cachefile in /etc/zfs/zpool.cache /boot/zfs/zpool.cache; do
2374e2b24fSCy Schubert		if [ -r $cachefile ]; then
24f30f11f8SChuck Tuffli			zpool import -c $cachefile -a -N
25f30f11f8SChuck Tuffli			if [ $? -ne 0 ]; then
26f30f11f8SChuck Tuffli				echo "Import of zpool cache ${cachefile} failed," \
27f30f11f8SChuck Tuffli				    "will retry after root mount hold release"
28f30f11f8SChuck Tuffli				root_hold_wait
29f30f11f8SChuck Tuffli				zpool import -c $cachefile -a -N
30f30f11f8SChuck Tuffli			fi
31f30f11f8SChuck Tuffli			break
3274e2b24fSCy Schubert		fi
3374e2b24fSCy Schubert	done
3474e2b24fSCy Schubert}
3574e2b24fSCy Schubert
3674e2b24fSCy Schubertload_rc_config $name
37*f99f0ee1SAlexander Leidinger
38*f99f0ee1SAlexander Leidinger# doesn't make sense to run in a svcj
39*f99f0ee1SAlexander Leidingerzpool_svcj="NO"
40*f99f0ee1SAlexander Leidinger
4174e2b24fSCy Schubertrun_rc_command "$1"
42