xref: /freebsd/libexec/rc/rc.d/zfs (revision 3cbb4cc200f8a0ad7ed08233425ea54524a21f1c)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: zfs
7# REQUIRE: zfsbe
8# BEFORE: FILESYSTEMS var
9# KEYWORD: shutdown
10
11. /etc/rc.subr
12
13name="zfs"
14desc="Mount and share ZFS datasets"
15rcvar="zfs_enable"
16start_cmd="zfs_start"
17stop_cmd="zfs_stop"
18required_modules="zfs"
19
20zfs_start_jail()
21{
22	if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
23		zfs mount -a
24	fi
25}
26
27zfs_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
36zfs_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
45zfs_stop_jail()
46{
47	if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
48		zfs unmount -a
49	fi
50}
51
52zfs_stop_main()
53{
54	zfs unshare -a
55	zfs unmount -a
56}
57
58zfs_stop()
59{
60	if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
61		zfs_stop_jail
62	else
63		zfs_stop_main
64	fi
65}
66
67load_rc_config $name
68run_rc_command "$1"
69