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