]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - libexec/rc/rc.d/zfs
OpenSSL: update to 3.0.12
[FreeBSD/FreeBSD.git] / libexec / rc / rc.d / zfs
1 #!/bin/sh
2 #
3 #
4
5 # PROVIDE: zfs
6 # REQUIRE: zfsbe
7 # BEFORE: FILESYSTEMS var
8
9 . /etc/rc.subr
10
11 name="zfs"
12 desc="Mount and share ZFS datasets"
13 rcvar="zfs_enable"
14 start_cmd="zfs_start"
15 start_postcmd="zfs_poststart"
16 stop_cmd="zfs_stop"
17 required_modules="zfs"
18
19 zfs_start_jail()
20 {
21         if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
22                 zfs mount -a
23         fi
24 }
25
26 zfs_start_main()
27 {
28         zfs mount -va
29         zfs share -a
30         if [ ! -r /etc/zfs/exports ]; then
31                 touch /etc/zfs/exports
32         fi
33 }
34
35 zfs_start()
36 {
37         if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
38                 zfs_start_jail
39         else
40                 zfs_start_main
41         fi
42 }
43
44 zfs_poststart()
45 {
46         # Some of the keys to decrypt datasets are potentially stored on ZFS
47         # datasets that just got mounted. Let's try to load those keys and
48         # mount the datasets.
49         if checkyesno zfskeys_enable; then
50                 /etc/rc.d/zfskeys start
51                 zfs_start
52         fi
53 }
54
55 zfs_stop_jail()
56 {
57         if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
58                 zfs unmount -a
59         fi
60 }
61
62 zfs_stop_main()
63 {
64         zfs unshare -a
65         zfs unmount -a
66 }
67
68 zfs_stop()
69 {
70         if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
71                 zfs_stop_jail
72         else
73                 zfs_stop_main
74         fi
75 }
76
77 load_rc_config $name
78 run_rc_command "$1"