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