1#!/bin/sh 2# 3# $FreeBSD$ 4# 5 6# PROVIDE: zfs 7# REQUIRE: zfsbe 8# BEFORE: FILESYSTEMS var 9 10. /etc/rc.subr 11 12name="zfs" 13desc="Mount and share ZFS datasets" 14rcvar="zfs_enable" 15start_cmd="zfs_start" 16stop_cmd="zfs_stop" 17required_modules="zfs" 18 19zfs_start_jail() 20{ 21 if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then 22 zfs mount -a 23 fi 24} 25 26zfs_start_main() 27{ 28 local cachefile 29 30 for cachefile in /boot/zfs/zpool.cache /etc/zfs/zpool.cache; do 31 if [ -r $cachefile ]; then 32 zpool import -c $cachefile -a 33 fi 34 done 35 zfs mount -va 36 zfs share -a 37 if [ ! -r /etc/zfs/exports ]; then 38 touch /etc/zfs/exports 39 fi 40} 41 42zfs_start() 43{ 44 if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then 45 zfs_start_jail 46 else 47 zfs_start_main 48 fi 49} 50 51zfs_stop_jail() 52{ 53 if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then 54 zfs unmount -a 55 fi 56} 57 58zfs_stop_main() 59{ 60 zfs unshare -a 61 zfs unmount -a 62} 63 64zfs_stop() 65{ 66 if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then 67 zfs_stop_jail 68 else 69 zfs_stop_main 70 fi 71} 72 73load_rc_config $name 74run_rc_command "$1" 75