]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rc/rc.d/zpool
zfs: merge openzfs/zfs@a94860a6d
[FreeBSD/FreeBSD.git] / libexec / rc / rc.d / zpool
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
12 name="zpool"
13 desc="Import ZPOOLs"
14 rcvar="zfs_enable"
15 start_cmd="zpool_start"
16 required_modules="zfs"
17
18 zpool_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
36 load_rc_config $name
37 run_rc_command "$1"