]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.d/zfs
This commit was generated by cvs2svn to compensate for changes in r177572,
[FreeBSD/FreeBSD.git] / etc / rc.d / zfs
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5
6 # PROVIDE: zfs
7 # REQUIRE: mountcritlocal
8 # BEFORE:  mountcritremote
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 volinit
28         zfs mount -a
29         zfs share -a
30         if [ ! -r /etc/zfs/exports ]; then
31                 touch /etc/zfs/exports
32         fi
33         # Enable swap on ZVOLs with property org.freebsd:swap=on.
34         zfs list -H -o org.freebsd:swap,name -t volume | \
35         while read state name; do
36                 case "${state}" in
37                 [oO][nN])
38                         swapon /dev/zvol/${name}
39                         ;;
40                 esac
41         done
42 }
43
44 zfs_start()
45 {
46         if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
47                 zfs_start_jail
48         else
49                 zfs_start_main
50         fi
51 }
52
53 zfs_stop_jail()
54 {
55         if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
56                 zfs unmount -a
57         fi
58 }
59
60 zfs_stop_main()
61 {
62         # Disable swap on ZVOLs with property org.freebsd:swap=on.
63         zfs list -H -o org.freebsd:swap,name -t volume | \
64         while read state name; do
65                 case "${state}" in
66                 [oO][nN])
67                         swapoff /dev/zvol/${name}
68                         ;;
69                 esac
70         done
71         zfs unshare -a
72         zfs unmount -a
73         zfs volfini
74 }
75
76 zfs_stop()
77 {
78         if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
79                 zfs_stop_jail
80         else
81                 zfs_stop_main
82         fi
83 }
84
85 load_rc_config $name
86 run_rc_command "$1"