summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/zfs
blob: cabbcf6ef49fbb5a3766a080fe51a0beca54f1e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: zfs
# REQUIRE: mountcritlocal

. /etc/rc.subr

name="zfs"
rcvar="zfs_enable"
start_cmd="zfs_start"
stop_cmd="zfs_stop"
required_modules="zfs"

zfs_start_jail()
{
	if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
		zfs mount -a
	fi
}

zfs_start_main()
{
	zfs mount -a
	zfs share -a
	if [ ! -r /etc/zfs/exports ]; then
		touch /etc/zfs/exports
	fi
}

zfs_start()
{
	if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
		zfs_start_jail
	else
		zfs_start_main
	fi
}

zfs_stop_jail()
{
	if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then
		zfs unmount -a
	fi
}

zfs_stop_main()
{
	zfs unshare -a
	zfs unmount -a
}

zfs_stop()
{
	if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then
		zfs_stop_jail
	else
		zfs_stop_main
	fi
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud