]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - etc/rc.d/zfs
MFC r299839,r299840,r299841:
[FreeBSD/stable/10.git] / etc / rc.d / zfs
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: zfs
7 # REQUIRE: mountcritlocal
8 # BEFORE: FILESYSTEMS var
9
10 . /etc/rc.subr
11
12 name="zfs"
13 rcvar="zfs_enable"
14 start_cmd="zfs_start"
15 stop_cmd="zfs_stop"
16 required_modules="zfs"
17
18 zfs_start_jail()
19 {
20         if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
21                 zfs mount -a
22         fi
23 }
24
25 zfs_start_main()
26 {
27         zfs mount -va
28         zfs share -a
29         if [ ! -r /etc/zfs/exports ]; then
30                 touch /etc/zfs/exports
31         fi
32 }
33
34 zfs_start()
35 {
36         if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
37                 zfs_start_jail
38         else
39                 zfs_start_main
40         fi
41 }
42
43 zfs_stop_jail()
44 {
45         if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
46                 zfs unmount -a
47         fi
48 }
49
50 zfs_stop_main()
51 {
52         zfs unshare -a
53         zfs unmount -a
54 }
55
56 zfs_stop()
57 {
58         if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
59                 zfs_stop_jail
60         else
61                 zfs_stop_main
62         fi
63 }
64
65 load_rc_config $name
66 run_rc_command "$1"