Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/rc.d/zfs
Show All 12 Lines | |||||
rcvar="zfs_enable" | rcvar="zfs_enable" | ||||
start_cmd="zfs_start" | start_cmd="zfs_start" | ||||
start_postcmd="zfs_poststart" | start_postcmd="zfs_poststart" | ||||
stop_cmd="zfs_stop" | stop_cmd="zfs_stop" | ||||
required_modules="zfs" | required_modules="zfs" | ||||
zfs_start_jail() | zfs_start_jail() | ||||
{ | { | ||||
if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then | if check_jail mount_allowed; then | ||||
zfs mount -a | zfs mount -a | ||||
fi | fi | ||||
} | } | ||||
zfs_start_main() | zfs_start_main() | ||||
{ | { | ||||
zfs mount -va | zfs mount -va | ||||
zfs share -a | zfs share -a | ||||
if [ ! -r /etc/zfs/exports ]; then | if [ ! -r /etc/zfs/exports ]; then | ||||
touch /etc/zfs/exports | touch /etc/zfs/exports | ||||
fi | fi | ||||
} | } | ||||
zfs_start() | zfs_start() | ||||
{ | { | ||||
if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then | if check_jail jailed; then | ||||
zfs_start_jail | zfs_start_jail | ||||
else | else | ||||
zfs_start_main | zfs_start_main | ||||
fi | fi | ||||
} | } | ||||
zfs_poststart() | zfs_poststart() | ||||
{ | { | ||||
# Some of the keys to decrypt datasets are potentially stored on ZFS | # Some of the keys to decrypt datasets are potentially stored on ZFS | ||||
# datasets that just got mounted. Let's try to load those keys and | # datasets that just got mounted. Let's try to load those keys and | ||||
# mount the datasets. | # mount the datasets. | ||||
if checkyesno zfskeys_enable; then | if checkyesno zfskeys_enable; then | ||||
/etc/rc.d/zfskeys start | /etc/rc.d/zfskeys start | ||||
zfs_start | zfs_start | ||||
fi | fi | ||||
} | } | ||||
zfs_stop_jail() | zfs_stop_jail() | ||||
{ | { | ||||
if [ `$SYSCTL_N security.jail.mount_allowed` -eq 1 ]; then | if check_jail mount_allowed; then | ||||
zfs unmount -a | zfs unmount -a | ||||
fi | fi | ||||
} | } | ||||
zfs_stop_main() | zfs_stop_main() | ||||
{ | { | ||||
zfs unshare -a | zfs unshare -a | ||||
zfs unmount -a | zfs unmount -a | ||||
} | } | ||||
zfs_stop() | zfs_stop() | ||||
{ | { | ||||
if [ `$SYSCTL_N security.jail.jailed` -eq 1 ]; then | if check_jail jailed; then | ||||
zfs_stop_jail | zfs_stop_jail | ||||
else | else | ||||
zfs_stop_main | zfs_stop_main | ||||
fi | fi | ||||
} | } | ||||
load_rc_config $name | load_rc_config $name | ||||
# doesn't make sense to run in a svcj: mounting / config setting | # doesn't make sense to run in a svcj: mounting / config setting | ||||
zfs_svcj="NO" | zfs_svcj="NO" | ||||
run_rc_command "$1" | run_rc_command "$1" |