freebsd-dev/libexec/rc/rc.d/zfs
Bjoern A. Zeeb 0696600c41 Move the rc framework out of sbin/init into libexec/rc.
The reasons for this are forward looking to pkgbase:
 * /sbin/init is a special binary; try not to replace it with
   every package update because an rc script was touched.
   (a follow-up commit will make init its own package)
 * having rc in its own place will allow more easy replacement
   of the rc framework with alternatives, such as openrc.

Discussed with:		brd (during BSDCam), kmoore
Requested by:		cem, bz
PR:			231522
Approved by:		re (gjb)
2018-10-17 16:49:11 +00:00

68 lines
872 B
Bash
Executable File

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: zfs
# REQUIRE: zfsbe
# BEFORE: FILESYSTEMS var
. /etc/rc.subr
name="zfs"
desc="Mount and share ZFS datasets"
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 -va
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"